• 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

Confirmation

 
Ranch Hand
Posts: 144
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,,

me and a couple of friends discussed below two points ,,, but i think we need some body else's idea bout them
1- in the below code we can not say that TestIt class Has-a animal since ( Animal a = new Animal();) is declared inside a method... please confirm


2- in the below code we can not say that TestIt class Has-a Dog when line one is invoked ,,, and we can not say that TestIt class Has-a Animal when line tow is invoked, please confirm

 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you justify your answer?
 
Hama Kamal
Ranch Hand
Posts: 144
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Seetharaman Venkatasamy wrote:can you justify your answer?



well, this is what i get from our discussion
1- for the first case since the Reference variable is declared inside the method it will get vanished as the method runs and completes.
2-for the second case HAS-a only concerns the Reference variable not the Object being created.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For me, your conclusion seems to be fine. we will see what other folks will tell!

<edit>
one thing I can say, your example is example for composition(kind of HAS-A)
</edit>
 
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know about line two.
TestIt HAS-A Dog, but because Dog IS-A Animal, I think you could also say TestIt HAS-A Animal.
 
Ranch Hand
Posts: 59
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hama Kamal wrote:

Seetharaman Venkatasamy wrote:can you justify your answer?



well, this is what i get from our discussion
1- for the first case since the Reference variable is declared inside the method it will get vanished as the method runs and completes.
2-for the second case HAS-a only concerns the Reference variable not the Object being created.






When only line 1 is present in the class TestIt, we can only say that TestIt HAS-A Animal. We can't say TestIt HAS-A Dog as we can't use a Dog-specific stuffs in the class TestIt.

With only line 2, its obvious that the class TestIt HAS-A Dog.

 
reply
    Bookmark Topic Watch Topic
  • New Topic