• 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

Enthuware: relationship is-like-a

 
Ranch Hand
Posts: 44
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I came across an Enthuware question asking which of the 4 statements are valid and the following statement turned out to be valid.

"Every thread in java is-like-a Runnable"

I have only heard of IS-A and HAS-A relationships in OO. Is there such a thing as an is-like-a relationship or is it a typo from Enthuware ?
 
Greenhorn
Posts: 24
Android Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a relationship such as is-like-a yes. It has a subtle difference with is-a.

Is-a
An is-a relationship denotes a relationship where a class inherits from another class (subclassing). So when: class A extends class B, B is-a A.

Is-like-a
An is-like-a relationship denotes a relationship where a class implements an interface. So when: class MyClass implements MyInterface, MyClass is-like-a MyInterface.

Most of the time they're both just called is-a relationships though.
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jack Tol wrote:There is a relationship such as is-like-a yes. It has a subtle difference with is-a.

An is-a relationship denotes a relationship where a class inherits from another class (subclassing). So when: class A extends class B, B is-a A.
An is-like-a relationship denotes a relationship where a class implements an interface. So when: class MyClass implements MyInterface, MyClass is-like-a MyInterface.

Most of the time they're both just called is-a relationships though.



Never heard of this distinction. In my experience with Java, the IS-A relationship encompasses this description that you provide for interfaces. Why should there be a distinction in the first place? I just fail to see the reason in terms of java polymorphism and functinoality, in fact I dare say there are no differences, so why should they have different names?

EDIT: I'm just awake here, ofcourse what you're saying is, depending on the description you can basically "be told" if it is an interface or a class that the class-in-question is "related" to. Which I can see might serve a purpose in terms planning/discussing/explaining a software architecture, albeit I still never heard of it and strongly doubt it will be on the test.

// Andreas
 
Enthuware Software Support
Posts: 4821
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right. The fine distinction between is-a and is-like-a is not important for the exam. This has been updated and appropriate explanation has been added to the question.

thank you!
Paul.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic