aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Encapsulation Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Encapsulation Question" Watch "Encapsulation Question" New topic
Author

Encapsulation Question

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707

Question 5

A class can not be called "tightly encapsulated" unless which of the following are true?
a. The data members can not be directly manipulated by external code.
b. The class is declared final.
c. It has no public mutator methods.
d. The superclass is tightly encapsulated.


The answer is given: a,d
Description to "d", if the super class is not tightly encapsulated no subclasses can be tightly encapsulated.
Please clarify.


Source of the question



Thanks and Regards,
cmbhatt


cmbhatt
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hey Chandra,

Come on...! Super Class can easily break option (a) given in qustion, which you have selected as a rule for tight encapsulation !.

Thats why we should select (d) too.


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Another way to put this might be: If the superclass is weak or vulnerable, then any subclasses will inherit that weakness or vulnerability.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707

If the superclass is weak or vulnerable, then any subclasses will inherit that weakness or vulnerability.


I liked this!


Thanks marc!

cmbhatt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Encapsulation Question
 
Similar Threads
K&B encapsulation concept
Dan's exam: Mutator method
Tightly encapsulated classes
Dan's definition of encapsulated class
Encapsulation