• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding Encapsulation

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following are th benefits of tight encapsulation :

1. It provides for higher program performance
2. It results in reduced need for constructor methods
3. It involves the separation of the implementation of classes from the interface.
4. It allows greater security of programs by limiting the access to methods
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe option 4 is correct as the data is accessed through methods rather than directly with tight encapsulation. Any comments from others?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would agree - Number 4 is one of the benifits of encapsulation.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think answer 3 is definitely correct. Encapsulation hides how data is stored and manipulated by a class so it hides the implementation behind a class

I'm not sure on option 4 since it depends upon how I read it! If you read it as the only way to use a class is via its methods, that is, you have no access to the actual variables in a class instance, then option 4 is correct. If you read it as only certain users of a program can access certain methods then I'm not sure that it could be defined as encapsulation.

I would hate to find a question like that on the exam!
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this really an official mock or exam question?

#3 doesnt sound like a benefit of tight encapsulation to me, rather it is a way of achieving tight encapsulation. Quite different really!

Regarding #4, imo it depends on the meaning of the word security in this context. It's obviously a rather simple process using reflection to access methods that are protected as part of encapsulation, but if secure is being used in the 'robust' sort of meaning then I guess #4 could be considered true. I'd probably go with that if I had to answer it.
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with David, 3 and 4.

But I am more convinced than David that 4 is correct. Because I read "greater security" as he first read it, not as security from access by unauthorized users.
I think security in the ideas of the makers of the exam stands for program safety - in respect of exceptions thrown, etc.
A encapsulated int variable e.g. cannot be set to sub zero accidently, if the setter doesn't provide negative values. This kind of things.

3 is also correct as David said. Because the interface (API, do not mix up with interface {} ) shows only how the class can be used, and not how the class actually performs its tricks.


David also wrote:

I would hate to find a question like that on the exam!

I'm afraid the sentence should start: "I will hate ..."


Andi:

#3 doesnt sound like a benefit of tight encapsulation to me, rather it is a way of achieving tight encapsulation. Quite different really!


Hm... First you achieve it, and then you have the benefits?


If this was from a mock exam, was the correct answer provided?

If only one answer was allowed, I'd favourite 4 over 3


Yours,
Bu.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question is from www.examulator.com (and other sites I think )
The correct answer is #3
About #4 they say, that encapsulation has nothing with security of programs.
 
Jae Stryker
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It depends what is interrupted by 'Security of programs' - I really do not like the ambiguous question as they leave too much to interpretation.

I suspose for it to be number 4 then it would have been worded 'Security of classes' � Still these q�s are never that clear.
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think #4 is more closely related to the concept of tight or loose coupling than encapsulation.
 
Suguna Gollapally
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, this Question is from examsimulator..

I selected 3 and 4 options but it says wrong..ie y i just posted to have your opinion..

Thanks for the explanation
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic