Java OCA OCP Practice Question 1951

Question

Which statement is true?.

Select the one correct answer.

  • (a) Non-static member classes must have either default or public accessibility.
  • (b) All nested classes can declare static member classes.
  • (c) Methods in all nested classes can be declared static.
  • (d) All nested classes can be declared static.
  • (e) Static member classes can contain non-static methods.


(e)

Note

Non-static member classes, unlike top-level classes, can have any accessibility modifier.

Static member classes can only be declared in top-level or nested static member classes and interfaces.

Only static member classes can be declared static.

Declaring a class static only means that instances of the class are created without having an outer instance.

This has no bearing on whether the members of the class can be static or not.




PreviousNext

Related