• 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

what exactly an interface object contains ?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what exactly an interface object contains when we declare it to achieve correct method invocation?
how it correctly works?
suppose i have two interfaces each having one method with same method name.
a class implements this interface. how using an interface object and assigning that object a class object calls the method from that interface only???
 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by RohitR Kulkarni:
what exactly an interface object contains when we declare it to achieve correct method invocation?
how it correctly works?
suppose i have two interfaces each having one method with same method name.
a class implements this interface. how using an interface object and assigning that object a class object calls the method from that interface only???



An interface is just a specification, a skeleton, there is no body, there is no implementation. You would feel its importance only at runtime.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
an interface declares a set of methods the implementing class MUST define. it simply says "any and all classes that implement me will have the following methods with the following signatures".

If you have two interfaces that both declare the same method, it's not a problem. the one method you write will satisfy that part of both interfaces. you kind of get two-for-one.
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the subject is a bit confusing one, there is no such thing as interface object there is only a reference of the interface type that holds an object of the implementing class.
reply
    Bookmark Topic Watch Topic
  • New Topic