| 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,<br />T.Srinivasan,<br />SCWCD 1.4(89%),SCJP 5.0(75%)<br />"That service is the noblest which is rendered for its own sake." - Mahatma Gandhi
|
 |
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
|
 |
 |
|
|
subject: Encapsulation Question
|
|
|