aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt on uCertify question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "doubt on uCertify question" Watch "doubt on uCertify question" New topic
Author

doubt on uCertify question

zhong chen
Greenhorn

Joined: Oct 12, 2009
Posts: 24

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

Joined: Feb 24, 2006
Posts: 6662
    
    5

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


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Atwal Usha
Ranch Hand

Joined: Sep 10, 2009
Posts: 137
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.


Java Certification Exam Mock Tests: SCJA  SCJP 5  SCJP 6  SCJP 6 (Online Training)  SCJP 6 (Instructor Led Training)   SCWCD 5   SCBCD 5  SCEA 5
 
jQuery in Action, 2nd edition
 
subject: doubt on uCertify question