Mastering Java: The Ultimate 2026 All-In-One Quiz to Excel in 'Thinking in Java

Question: 1 / 510

Which access level prevents a class member from being accessed by any class outside its own package, except for subclasses?

Private

Protected

In Java, there are four different access levels public, protected, default (package access), and private. Out of these four, only the protected access level allows a class member to be accessed by a subclass outside of its package. The private access level would restrict access to only within the same class, the public access level would allow access by any class, and the default access level would only restrict access within the same package. Therefore, the protected access level is the correct choice as it meets the criteria set in the question while also providing context on why the other options are incorrect.

Get further explanation with Examzify DeepDiveBeta

Public

Package access

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy