About Question enthuware.ocajp.i.v7.2.1213 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
The_Nick

About Question enthuware.ocajp.i.v7.2.1213 :

Post by The_Nick »

Hi
What is the exact difference between coupling and encapsulation?
Thanks a lot in advance.

The_Nick

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Post by admin »

Coupling means how interconnected classes are. Tight coupling means that the classes know a lot of internal details such as instance fields and methods (which are not exposed by an interface) of each other.

Encapsulation basically hides the instance variables by making them private. This reduces coupling because other classes cannot directly access those fields.
If you like our products and services, please help us by posting your review here.


hamzaBlm
Posts: 18
Joined: Thu May 23, 2019 11:58 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Post by hamzaBlm »

I understand than Encapsulation does its job to reduce coupling between classes by hiding internal details.

My question is:
Can we reduce coupling by following the principle of "program to interfaces not to implementations"?

I think by following the principle we can have low coupling because now the classes depend on the interface, not the implementation. am I correct?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Post by admin »

The measure of these parameters is quite subjective. So, yes, one could argue that. But it would not be too beneficial to discuss this here as we are focused more on the certification. You will get better answer for it on sites such as coderanch.com
If you like our products and services, please help us by posting your review here.

enthunoob
Posts: 60
Joined: Thu Apr 15, 2021 12:21 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Post by enthunoob »

May I suggest a bit of interpunction just to improve the absolute dive readability of this sentence:

"When a class, whose members should be accessible only to members of that class, is coded such a way that its members are accessible to other classes as well, this is called ..."


Instead of

"When a class whose members should be accessible only to members of that class is coded such a way that its members are accessible to other classes as well, this is called ..."

Assuming 'decrypting' of code is part of the exam, but not decrypting of bad spelling.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1213 :

Post by admin »

Fixed.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests