Created
August 26, 2011 16:31
-
-
Save iainmcgin/1173808 to your computer and use it in GitHub Desktop.
Java Puzzle
This file contains hidden or 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
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