Which two may precede the word "class" in a class declaration?

Which two may precede the word “class” in a class declaration?

Which two may precede the word “class” in a class declaration?

A.
local

B.
public

C.
static

D.
volatile

E.
synchronized

Explanation:
B: A class can be declared as public or private.
C: You can declare two kinds of classes: top-level classes and inner classes.
You define an inner class within a top-level class. Depending on how it is defined, an inner class
can be one of the following four types: Anonymous, Local, Member and Nested top-level.
A nested top-level class is a member classes with a static modifier. A nested top-level class is just
like any other top-level class except that it is declared within another class or interface. Nested
top-level classes are typically used as a convenient way to group related classes without creating
a new package.
The following is an example:
public class Main {
static class Killer {



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Fredy Jimenez Rendon

Fredy Jimenez Rendon

Only B

drmorriarti

drmorriarti

https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are called static nested classes. Non-static nested classes are called inner classes.

A nested class is a member of its enclosing class. Non-static nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private. Static nested classes do not have access to other members of the enclosing class. As a member of the OuterClass, a nested class can be declared private, public, protected, or package private. (Recall that outer classes can only be declared public or package private.)