What is the difference between private and protected in Java?
I'll answer
Earn 20 gold coins for an accepted answer.20
Earn 20 gold coins for an accepted answer.
40more
40more
Works at the International Labour Organization, Lives in Geneva, Switzerland.
A private member is only accessible within the same class as it is declared. A member with no access modifier is only accessible within classes in the same package. A protected member is accessible within all classes in the same package and within subclasses in other packages.
2023-05-13 12:30:24
评论(499)
Helpful(122)
Helpful
Helpful(2)

Isabella Wilson
QuesHub.com delivers expert answers and knowledge to you.
A private member is only accessible within the same class as it is declared. A member with no access modifier is only accessible within classes in the same package. A protected member is accessible within all classes in the same package and within subclasses in other packages.