What is the difference between a public variable and a private variable in Java?
A. A public variable can only be accessed within the same class, while a private variable can be accessed by any class in the same package.
B. A public variable can be accessed by any class, while a private variable can only be accessed within the same class.
C. A public variable and a private variable are the same thing in Java.
D. None of the above.
Answer:B
What is the difference between a public variable and a private variable in Java?
A. A public variable can only be accessed within the same class, while a private variable can be accessed by any class in the same package. B. A public variable can be accessed by any class, while a private variable can only be accessed within the same class. C. A public variable and a private variable are the same thing in Java. D. None of the above.