Hi
In this following program,
Given:
1. public class TestObj {
2. public static void main(
String[] args) {
3. Object o = new Object() {
4. public boolean equals(Object obj) {
5. return true;
6. }
7. }
8. System.out.println(o.equals("Fred"));
9. }
10. }
What is the result?
A. An exception occurs at runtime.
B. true
C. fred
D. Compilation fails because of an error on line 3.
E. Compilation fails because of an error on line 4.
F. Compilation fails because of an error on line 8.
G. Compilation fails because of an error on a line other than 3, 4, or 8
I thought Answer is F(because before line 8 there sholud be statement seperator ';').But in the book it shows the correct answer is G.
Can anybody clarify this answer?It will be very helpful for me.Thanks.