aspose file tools*
The moose likes Beginning Java and the fly likes what exactly an interface object contains ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what exactly an interface object contains ?" Watch "what exactly an interface object contains ?" New topic
Author

what exactly an interface object contains ?

RohitR Kulkarni
Greenhorn

Joined: Aug 30, 2008
Posts: 2
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???
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1535
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.


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11480
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

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.


SCJP, SCWCD.
|Asking Good Questions|
 
Don't get me started about those stupid light bulbs.
 
subject: what exactly an interface object contains ?