Practice mode Java

Which access levels can a top-level Java class be declared with?

Correct answer B. public or package-private

Explanation

A top-level class is either public, and visible everywhere, or has no modifier and is visible only inside its package. The modifiers protected and private apply only to member classes, because they describe access relative to an enclosing class. Declaring a top-level class private is a compile-time error.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.