• 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

coupling problem

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


sun preevaluation test




Which is true?
a. These classes are NOT coupled.
b. These classes are loosely coupled.
c. These classes are tightly coupled.
d. These classes are abstractly coupled.

my answer is c;is it correct
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah..c is the right answer
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but Class Two accesses field of One through accessor method. Is it because the method getX is package visible....
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please explain why it is tightly coupled and not loosely coupled? I'm not sure in questions about coupling and cohesion. I think loose coupling means that class Two doesn't know the implementation details about class One and uses it's API(interface), so I would say that b is correct - where am I wrong?

Thanks for answering
[ August 29, 2008: Message edited by: Rasto Slivensky ]
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think, these classes are loosely coupled, because class Two is accessing the variable x using accessor method. and in both classes instance variables are private.

so option 'b' is true.

Can anyone tell what is this "abstractly coupled" and in which case two classes are NOT coupled
 
Ranch Hand
Posts: 814
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think these classes are loosely coupled which use methods to acces variable
[ August 30, 2008: Message edited by: Ninad Kulkarni ]
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If these two classes belongs to the same pprograme than it is loose coupling if difffrent than Class two can't see the implementation of Class one. so it is tight coupling.

note:
----------------------------------------------
please let me know whether am I right or not ?
----------------------------------------------
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the two classes are tightly coupled,Because class Two's y depends on the implementation of getX() of class One.
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Classes are tightly coupled if they depend on the internal implementation of each other. But I don't think that acessor and mutator methods are considered internal implementations. My only concern is still that getX is not public....
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These two classes are loosly coupled and not tightly. So option B is correct. In tightly coupled methods if change code in class A then it do not affect class B so they not tighly coupled. Both implementation do not affect each other. and class B is using class A so there is loose coupling. I hope this thread is now clear.
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right Narendra,I got it wrong first place. More explanation on this at sun
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic