• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which of the above two interfaces would be invoked?

 
Hari Dhanakoti
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have specified a code here and would like to know which of the above interface will be invoked.


 
Moguluri Ravi Kiran
Ranch Hand
Posts: 63
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic