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 access level does a class member have if no access specifier is provided?

  1. Private

  2. Protected

  3. Public

  4. Package access

The correct answer is: Package access

Without an access specifier, a class member would have package access. This means that the member can be accessed by classes within the same package, but not by classes outside of that package. Options A, B, and C refer to specific access specifiers in Java and are therefore incorrect. Option C, public, would give all classes access to the member, while options A and B would limit the access to the class within which the member is declared or inherited classes. Package access is the default access level in Java if no access specifier is provided.