It is possible to define a class within a class termed as nested class. There…

2016

It is possible to define a class within a class termed as nested class. There are _____ types of nested classes.

  1. A.

    2

  2. B.

    3

  3. C.

    4

  4. D.

    5

Attempted by 420 students.

Show answer & explanation

Correct answer: A

Answer: 2 (two types of nested classes)

  • Static nested class: A nested class declared static. It does not have access to instance members of the enclosing class unless through an object reference.

  • Non-static inner class: A nested class that is associated with an instance of the enclosing class and can access its instance members directly.

Note: Non-static inner classes are commonly further categorized into three kinds: member inner class, local inner class, and anonymous inner class.

Explore the full course: Mppsc Assistant Professor