Skip to content

Instantly share code, notes, and snippets.

@shelajev
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shelajev/9955062 to your computer and use it in GitHub Desktop.
Save shelajev/9955062 to your computer and use it in GitHub Desktop.
Java 8, default methods
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