wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Encapsulation?? 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??" Watch "Encapsulation??" New topic
Author

Encapsulation??

Louis - Jean Morisset
Greenhorn

Joined: Aug 25, 2003
Posts: 20
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

Joined: Aug 05, 2002
Posts: 787
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

Joined: Aug 25, 2003
Posts: 20
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

Joined: May 05, 2000
Posts: 13974
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.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Doug Dunn
Author
Ranch Hand

Joined: Aug 03, 2003
Posts: 66
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.


Download a copy of <a href="http://www.javarules.com" target="_blank" rel="nofollow"><i>"Mastering The Fundamentals of The Java Programming Language"</i></a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Encapsulation??