What is the difference between “public” and “private” access modifiers in Java?
A. “public” members can be accessed by any code, while “private” members can only be accessed within the same class
B. “private” members can be accessed by any code, while “public” members can only be accessed within the same class
C. “public” members can be accessed only by subclasses, while “private” members can be accessed by any code
D. “private” members can be accessed only by subclasses, while “public” members can be accessed by any code
Answer:A
What is the difference between “public” and “private” access modifiers in Java?
A. “public” members can be accessed by any code, while “private” members can only be accessed within the same class B. “private” members can be accessed by any code, while “public” members can only be accessed within the same class C. “public” members can be accessed only by subclasses, while “private” members can be accessed by any code D. “private” members can be accessed only by subclasses, while “public” members can be accessed by any code