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

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

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

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 do you invoke a protected method from a subclass?

  1. Directly, if in the same package

  2. Using super keyword

  3. By creating an object of the superclass

  4. It is not accessible from a subclass

The correct answer is: Directly, if in the same package

Directly invoking a protected method from a subclass is possible if they are in the same package. If the subclass is not in the same package as the superclass, then the method cannot be directly invoked. B and C are incorrect because they do not refer to the protection level of the method or the package. D is incorrect because a protected method can be accessed from a subclass, in this case, as long as they are in the same package.