112k views
1 vote
Which of the following statements about an inner class is true? An inner class is used for a utility class that should be visible elsewhere in the program. An inner class that is defined inside a method is publicly accessible. An inner class that is defined inside a method is not publicly accessible. An inner class that is defined inside an enclosing class but outside of its methods is not available to all methods of the enclosing class.

User Elrond
by
4.1k points

1 Answer

1 vote

Answer:

(c) An inner class that is defined inside a method is not publicly accessible.

Step-by-step explanation:

In programming languages such as Java, inner class (also called nested class) basically means a class inside another class or interface. The following are a few things to note about an inner class

i. Inner classes are used to group classes logically so that they are easy to use and maintained.

ii. An inner class defined inside a method of an enclosing class is not publicly accessible. They are called method local inner class

iii. An inner class that is defined inside an enclosing class but outside of its methods are available to all methods of the enclosing class

iv. An inner class has access to members, including private members, of its enclosing class.

User Rodrigo Murillo
by
4.8k points