• 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
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

java inheritance

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
every body aware object class is super class of every class in java.
means every class extends the Object class.
class A extends B{} already extends Object class in this a can have
properties of both object and b class how this is posible even though java
doesn't supprot multiple inheritance.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by subhakar edeti:
every body aware object class is super class of every class in java.
means every class extends the Object class.
class A extends B{} already extends Object class in this a can have
properties of both object and b class how this is posible even though java
doesn't supprot multiple inheritance.



Class A inherits from the Object class as a result of extending class B because class B is an Object. A does not extend both ClassB and Object. So you have a linear hierarchy like so

Object-> Class B --> Class A.
 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Speaking of multiple inheritance, if you ever feel that you need it, you can declare your class to imiplement interfaces in addition to inheriting from a single parent class.

-- Kaydell
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not inheritance, it's implementation...

btw, Java does support multiple inheritance but only of interfaces.
 
reply
    Bookmark Topic Watch Topic
  • New Topic