Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Encapsulation??

 
Louis - Jean Morisset
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a question that the answer I don't understand??? I thought did understand encapsulation....
A class can not be called "tightly encapsulated" unless which of the following is true?
a. The class is declared final.
b. All local variables are declared private.
c. All method parameters are declared final.
d. No method returns a reference to any object that is referenced by an internal data member.
e. None of the above

The answer is e, but I would have answered b?? I understand the there needs to be more then b for a class to be tightly encapsulated!!! But it also needs for b to be true, so I thought???
Another question is ... is there another sort of encapsulation that is not thight??? Aren't you just encapsulated or not?? Can you be loosely encapsulated and if so, what's the point??
thanks
Louis
 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The local variables can not be private. Try it you will find. I guess you missunderstood it to be class variable.
 
Louis - Jean Morisset
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, that's exactly what I did. Thanks, I understand after all. OUFFFFFF!!!
I'm going for the exam on Monday, I think I just need to relax. Maybe I'll have a beer tonight!!!
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Barkat Mardhani:
The local variables can not be private. Try it you will find. I guess you missunderstood it to be class variable.
Don't get mixed up between "class variable" and "instance variables"! Instance variables should be declared private. Class variables (static variables) usually are not declared private.
 
Doug Dunn
Author
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
trick question...if you find yourself jumping for an answer I would advise slowing down and rereading. This question makes it perfectly clear that the exam includes trick questions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic