This code is from some book. I don�t remember the author. interface MyInterface { void method1(); void method2(); abstract class Abstract implements MyInterface { public void method2() { System.out.println("In method2"); } } } I know that a class defined inside an interface is implicitly static. What could be the reason this code not giving error as we cannot combine static as well as abstract. Thanks
Dilip, It's not possible to combine final and abstract modifiers. I don't think there is a problem in clubbing static and abstract in the class within the interface (top level static is not allowed). Try this: ... static abstract class Abstract(){ ... It still works.
static abstract class Abstract(){ The above code works perfectly. I think the cause of confusion was because an abstract method cannot be staic but an abstact inner class can. The following will not compile abstract class Myclass { public static abstract void show(); } MyClass.java:3: Abstract methods can't be static: void show() public static abstract void show(); ^ 1 error