• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Confused with a particular sentence in Kathry's and Bert's Book

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which statement(s) are true? (Choose all that apply.)
A. Has-a relationships always rely on inheritance.
B. Has-a relationships always rely on instance variables.
C. Has-a relationships always require at least two class types.
D. Has-a relationships always rely on polymorphism.
E. Has-a relationships are always tightly coupled.
Answer:
® 3 B is correct.
®˚ A and D describe other OO topics. C is incorrect because a class can have an instance of
itself
. E is incorrect because while has-a relationships can lead to tight coupling, it is by no
means always the case. (Objective 5.5)
2. Given:
class Clidders

Guys ,

I'm not able to convince my mind with answer C above,could anyone please give me an example for this kind of Has-A relationship.
 
author & internet detective
Posts: 41250
849
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose you have a bag class. It could have an attribute for another bag. (I smaller one that you roll up and put inside.) So a Bag would "have" a Bag. One class.
 
lowercase baba
Posts: 13069
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
another example would be a linked list. each node has-a reference to a previous or a next node.
 
Hussain Sabir
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That explains everything(Wondering, why I didn't thought this way,probably because my Brain battery was down last night ).
cheers guys, Javaranch Rocks!!
 
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic