File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "doubt on uCertify question" Watch "doubt on uCertify question" New topic

doubt on uCertify question

zhong chen

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

Joined: Feb 24, 2006
Posts: 6662

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
I agree. Here's the link:
subject: doubt on uCertify question
It's not a secret anymore!