🎴 Flashcard Mode

Simple Java Quiz

Card1 / 10
Mastered0
Review0
QuestionClick to flip

Which methods can access to private attributes of a class

AnswerClick to flip back
A
C. Only methods those defined in the same class
💡 Explanation:

Private attributes of a class can only be accessed by methods defined within the same class. This is encapsulation - private members are invisible outside the class boundary. Static methods are subject to the same rules as instance methods (no special access). Instances of the same class can't directly access private members of other instances. Classes in the same package have no special access to private members - they would need protected or package-private access modifiers.

Change Mode