Bird
0
0

What is the visibility of a class member declared with the public access modifier in Java?

easy📝 Conceptual Q1 of 15
Java - Packages and Access Control
What is the visibility of a class member declared with the public access modifier in Java?
AIt is accessible from any other class in any package.
BIt is accessible only within the same class.
CIt is accessible only within the same package.
DIt is accessible only to subclasses.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the meaning of public modifier

    The public modifier allows access from any other class regardless of package.
  2. Step 2: Compare with other access levels

    Other modifiers like private, protected, and default restrict access more than public.
  3. Final Answer:

    It is accessible from any other class in any package. -> Option A
  4. Quick Check:

    Public access = accessible everywhere [OK]
Quick Trick: Public means accessible from anywhere in the program [OK]
Common Mistakes:
  • Confusing public with private or protected
  • Thinking public restricts access to package only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes