Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


How does an inner class access the members of its enclosing class?

  1. Through a passed-in reference

  2. Directly

  3. Using reflection

  4. With public getter methods

The correct answer is: Directly

An inner class can access the members of its enclosing class directly, without the need for a passed-in reference, reflection, or public getter methods. Option A is incorrect because an inner class does not need to be passed in a reference to access its enclosing class members. Option C is incorrect because reflection involves using Java APIs to manipulate classes and objects at runtime, which is not necessary in this case. Option D is incorrect because getter methods are not required to access members of the enclosing class from an inner class.