public class Overload { public static void main(String args[]) { int result = foo(new B(), new B()); System.out.println(result); } public static int foo(A a, B b) { return 1; } public static int foo(B b, A a) throws Exception { return 2; } static class A { } static class B extends A { } }
Without using a compiler (using the JLS and JLS report is allowed), answer the following:
- Does this code compile?
- If yes - what is the result from running the program?
- If no - why not? List all errors.
Answers on a postcard.