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

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

Want to excel in Java? Test your knowledge with our ultimate quiz based on 'Thinking in Java'. Engage with multiple-choice questions and in-depth explanations. Boost your understanding and prepare for your exam with confidence.

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.


What kind of access does the 'protected' keyword provide?

  1. Package access

  2. Private access

  3. Public access

  4. Inheritance and package access

The correct answer is: Inheritance and package access

'Protected' is a keyword used in object-oriented programming languages, such as Java, to control the level of access to a class member. This keyword provides inheritance and package access, allowing subclasses and other classes in the same package to access the protected member. Option A, package access, provides access only within the same package, while option B, private access, only allows access within the same class. Option C, public access, allows access from any class.