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 ?

Java8 quiz Multiple Inheritance


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

You may also like...

2 Responses

  1. Shaswat Patitpawnam says:

    in an interface how could u write a concrete method…??

Leave a Reply.. code can be added in <code> </code> tags

%d bloggers like this: