On page 662 of
SCJP book there is a question
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. }
And the answers are
...
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.
The correct answer given is G on the basis that compilation fails due to a missing ; on line 7 but I would have thought that this would be picked up by the compiler as a missing ; on line 8?
Equally you could say it was an error on line 3 because the assignment started on line 3 was not closed correctly.
Is there a standard way of knowing how to place errors on questions like this on the exam?