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

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

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

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.