File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Which of the above two interfaces would be invoked? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Which of the above two interfaces would be invoked?" Watch "Which of the above two interfaces would be invoked?" New topic
Author

Which of the above two interfaces would be invoked?

Hari Dhanakoti
Ranch Hand

Joined: Jan 07, 2008
Posts: 74
Hi,
I have specified a code here and would like to know which of the above interface will be invoked.



Regards,
Hari
Moguluri Ravi Kiran
Ranch Hand

Joined: Apr 16, 2010
Posts: 62

I think all the interfaces Interface1,Interface2 & Interface3 are having the method getInfo() & thats why you are asking the overridden method from which interface is being executed here..

All the Methods from the three interfaces bocmes only one method since, the signatures of the methods are same.
so you have only one method inherited from all the interfaces into your class.

just use decompiler "javap classname"

you will see there is only one method in the class that implemented three interfaces..

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

As Moguluri said, you've not shown us the code of Interface2 and Interface3. So the best guess is there is a getInfo() method in them too with maybe different exceptions in throws clause. But in any case, methods in interface don't have a body, so they are not called. There is only one getInfo() method which has a body, and that is in the OverRideOnMultiInterfaces class, so that will be called.


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
jQuery in Action, 2nd edition
 
subject: Which of the above two interfaces would be invoked?
 
Similar Threads
Polymorphic Reference & Interfaces
Declare and use interface
Is this a Bug in Java
jsp vs rmi
Please HELP...Devaka Exam Test 2 Number 69. I totally don't understand it.