Java OCA OCP Practice Question 1943

Question

Which statements about nested classes are true?.

Select the two correct answers.

  • (a) An instance of a static member class has an inherent outer instance.
  • (b) A static member class can contain non-static fields.
  • (c) A static member interface can contain non-static fields.
  • (d) A static member interface has an inherent outer instance.
  • (e) An instance of the outer class can be associated with many instances of a non-static member class.


(b) and (e)

Note

A static member class is in many respects like a top-level class and can contain non-static fields.

Instances of non-static member classes are created in the context of an outer instance.

The outer instance is inherently associated with the inner instance.

Several non-static member class instances can be created and associated with the same outer instance.

Static member classes do not have any inherent outer instance.

A static member interface, just like top-level interfaces, cannot contain non-static fields.

Nested interfaces are always static.




PreviousNext

Related