What is the difference between a public method and a private method in Java?
A. A public method can be accessed from any class, while a private method can only be accessed within the same class.
B. A private method can be accessed from any class, while a public method can only be accessed within the same class.
C. A public method has a return type, while a private method does not.
D. A private method is used to create objects, while a public method is used to modify objects.
Answer:A
What is the difference between a public method and a private method in Java?
A. A public method can be accessed from any class, while a private method can only be accessed within the same class. B. A private method can be accessed from any class, while a public method can only be accessed within the same class. C. A public method has a return type, while a private method does not. D. A private method is used to create objects, while a public method is used to modify objects.