What is the difference between a public and private access modifier in Java?
A. A public method or variable can be accessed from any class, while a private method or variable can only be accessed from within the same class.
B. A public method or variable can only be accessed from within the same class, while a private method or variable can be accessed from any class.
C. A public method or variable is final and cannot be changed, while a private method or variable can be changed.
D. None of the above
Answer:A
What is the difference between a public and private access modifier in Java?
A. A public method or variable can be accessed from any class, while a private method or variable can only be accessed from within the same class. B. A public method or variable can only be accessed from within the same class, while a private method or variable can be accessed from any class. C. A public method or variable is final and cannot be changed, while a private method or variable can be changed. D. None of the above