static method in class have same signature as default method in interface

Viewed 1366

I have below scenario :

class C {
    static void m1() {}
}

interface I {
    default void m1() {}
}

//this will give compilation error : inherited method from C cannot hide public abstract method in I
class Main extends C implements I {

}

Below are my questions:

  1. I am aware that instance method will override the default methods but what if static methods in class have same signature as default method in Interface?

  2. If static method m1() in class C would be public then compilation error will be :

    static method m1() conflicts with abstract method in I.

so when the access modifier was default it was trying to hide and when it is public it is conflicting. why is this difference? what is the concept behind it?

4 Answers
Related