Java Quiz
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.
About this entry
You are currently reading “Java Quiz”, an entry on Lamby's blog.
- Published:
- 09.04.07 / 5pm
- Filed under:
- Computer, Planet ALUG, Planet UWCS, Planet WUGLUG
5 Comments
Jump to comment form | comments rss | trackback uri