• 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

interface

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi I am ajay,

Does a Interface inherit Object Class ?

I am asking becouse I saw somewhere "all classes and interface inherit Object class".

Please answer!!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An interface inherits the methods of any other interfaces it explicitly extends.

But all objects extend (directly or indirectly) the Object class, so you can call Objects's methods on all objects.
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quote
-------------------------------------------------
Does a Interface inherit Object Class ?
-------------------------------------------------

Inheritance can be implemented either in two way one is by extending some class or interfaces and second method is implementing interfaces.

Also an interface can extends other interfaces only. It can't extends or implements any class. SO Interface doesn't inherit Object class. Although all
classes are subclass of Object class,we can say that they(classes) inherit Object class.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Inheritance can be implemented either in two way one is by extending some class or interfaces and second method is implementing interfaces.


Implementing an interface is not the same as inheritance, and the word "inheritance" should not be used for it.
 
Prabhat Gupta
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Ulf,
As per me,IS-A relationship show inheritance and IS-A can be implemented either by extending class/Interface or implementing Interface.

please correct me if i m wrong.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know who defines what constitutes an "IS-A relationship", but when talking about Java, implementing an interface is unrelated to inheritance. People will not understand what you're talking about.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic