• 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

subtype and subclass

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can anybody give me a java example of difference in subtype and subclass?
in UML distilled:
"newer lanuage.. try to emphasize the difference between interface-inheritance (subtyping) and implementation-inheritance (subclassing)".
Thanks a lot!
--Moon
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Implementing an interface is subtyping; extending a class is subclassing.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello moon...
actually ur trying to confuse two perspective that is Conceptual perspective and Implementation perspective.. as Martin Fowler visualizes every thing from in terms of these perspectivs so... actually subtypes and subclases are same... but
in Conceptual perspective
we consider SUBTYPES...
and in Implementation perspective
we take it as SUBCLASS...

i hope i hve made it clear to you..

------------------
ATHER ALI
SCJP2.0, SCWCD
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

actually subtypes and subclases are same...


No, they aren't!
Subtyping means (as stated above) interface inheritance, that is a class is a subtype of another class or interface, if it conforms to its interface. HashMap is a subtype of Map and of Object, for example.
Subclassing means implementation inheritance, that is a subclass reuses some implementation of its superclass. In java, subclassing is always also subtyping, but there are languages like C++ where you can privately inherit from a class, so that you don't inherit the public interface.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My understanding is the same as Ilja.
 
ather ali
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Ilja Preuss
.... now my concept is clear... thankx for correcting me
------------------
ATHER ALI
SCJP2.0, SCWCD
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome!
reply
    Bookmark Topic Watch Topic
  • New Topic