Java 8 quiz on multiple inheritance with default Interface method
Beginning JDK 8, we can have a default method implementation in an interface.
So, what happens when a class inherits a method with same signature from a superclass and an interface ?
Answer
If a class inherits a method (abstract or concrete) from its
superclass and a method with the same signature from one of its super-interfaces, then the class inherits the method of the superclass and the methods in the super-interfaces are ignored.
This rule treats a default method in an interface as a fallback if the same method is not available in the class through the class hierarchy.
Correct answer is “Hello”.
Note: This program will only work on JDK 8 and above.
© 2016, https:. All rights reserved. On republishing this post, you must provide link to original post
in an interface how could u write a concrete method…??
Java 8 supports adding default method in an Interface.
You may want to refer this article :
http://www.topjavatutorial.com/java-8/new-features-in-java-8-interfaces/