Which statement about instance variables is correct?
public so methods can use them.Explanation
The word instance is the clue: each instance of the class gets its own storage for the variable. This is what lets two objects of the same class hold different values at the same time.
- B is not correct: a value shared by every object of the class is a class variable, which is a different kind of declaration.
- C is not correct: the methods of a class can use its instance variables regardless of access designation, so
publicis not required for that. - D is not correct: this reverses the situation; the declaring class is exactly where an instance variable is always usable.