Skip to content

Instantly share code, notes, and snippets.

@iainmcgin
Created August 26, 2011 16:31
Show Gist options
  • Save iainmcgin/1173808 to your computer and use it in GitHub Desktop.
Save iainmcgin/1173808 to your computer and use it in GitHub Desktop.
Java Puzzle
class A {
public void x(byte b) { System.out.println("byte"); }
public void x(long l) { System.out.println("long"); }
}
class B extends A {
public void x(short s) { System.out.println("short"); }
public void x(int i) { System.out.println("int"); }
}
class Main {
public static void main(String[] args) {
A a = new B();
a.x((short)5);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment