Last active
August 29, 2015 13:58
-
-
Save shelajev/9955062 to your computer and use it in GitHub Desktop.
Java 8, default methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.shelajev.throwaway.defmeth; | |
public class Main { | |
public static void main(String[] args) { | |
// what does this program produce? | |
B b = new B(); | |
b.m1(); | |
b.callM1(); | |
b.callSuperM1(); | |
} | |
} | |
interface I1 { | |
default void m1() { | |
System.out.println("I1"); | |
} | |
} | |
interface I2 extends I1 { | |
default void m1() { | |
System.out.println("I2"); | |
} | |
} | |
class A implements I1 { | |
public void callM1() { | |
m1(); | |
} | |
} | |
class B extends A implements I2 { | |
public void callSuperM1() { | |
super.m1(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment