File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Coupling doubt.

 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This Question is from MasterExam:-

Which istantiation creates the tightest coupling?

A BioDiesel b1 = new BioDiesel();

B BioDiesel b2 = new BioDiesel(new String("canola"));

C BioDiesel b3 = new BioDiesel(new Integer(42));

D BioDiesel b4 = new BioDiesel(new Viscosity());


The answer is D ,but someone can explain me why it is D.Thanks..
 
chander shivdasani
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ashok Pradhan:
This Question is from MasterExam:-

Which istantiation creates the tightest coupling?

A BioDiesel b1 = new BioDiesel();

B BioDiesel b2 = new BioDiesel(new String("canola"));

C BioDiesel b3 = new BioDiesel(new Integer(42));

D BioDiesel b4 = new BioDiesel(new Viscosity());


The answer is D ,but someone can explain me why it is D.Thanks..


Coupling means high Dependency on some other class. So when the other class is changed, this class is affected drastically.

in option 1, the class has no dependency on any other class

in option 2, class depends on String class, which is final. So the class definition will be constant.

in option 3, class depends on Integer class, which also is final.

in option 4, class depends on a class called Viscosity, which is developed by some other user. So there are very high chances that if Viscosity class is changed,the Biodiesel class will be affected drastically.

Hence, option 4 is correct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic