Forums Register Login

possible ambiguous question(encapsulation effects polymorphism ) in whizlab ocajp 7 mock

+Pie Number of slices to send: Send
from whizlab ocajp 7 mock

Given:


Which is true?
Select one:
A. The class is fully encapsulated.
B. The code demonstrates polymorphism.
C. The owner variable breaks encapsulation & would eventually affect polymorphism.
D. The simId and talkTime variables break polymorphism.
E. The setSimInfo method breaks encapsulation. Incorrect

The answer is C

But I couldn't understand the statement

& would eventually affect polymorphism



Could somebody please explain how lack of encapsulation affects polymorphism ?
1
+Pie Number of slices to send: Send
First of all let us agree that this class is not well-encapsulated. I think that's the most important observation to take from this question

Don't know what they mean with "lack of encapsulation affects polymorphism". But let me give it a shot with the following example:


For an old Nokia we want the owner to be stored in upper case. So we override the setSimInfo method. But because owner is public, it can be set without invoking setSimInfo and that would thus affect polymorphism.
+Pie Number of slices to send: Send
Thanks a lot Roel . That makes sense. Excellent explanation.
Popeye has his spinach. I have this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1382 times.
Similar Threads
Q on Kathy's Mock Test (Topic:encapsulation)
K&B encapsulation concept
output clarification
Doubt on Mocktest
doubt on uCertify question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:38:21.