• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt on uCertify question

 
zhong chen
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Question is: Which of the following statements is true:
A: Encapsulation breaks due to both int i and string name.
B: Encapsulation breaks due to int i.
C: Encapsulation breaks due to string name.
D: Encapsulation breaks due to int j
E: The class is fully Encapsulated.

The answer is A.
I think protected instance variable should be considered as proper encapsulation so the answer should be C. Am I right?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A class that extends this class should be able to access the internal variable. You can consider that as an information leak from this class, which should justify the answer
 
Atwal Usha
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Encapsulation is broken if by any means the internal data of a class could be directly modified. Protected access modifier could also be considered as a cause of it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic