Which lines do not compile?
a. Line 1
b. Line 2
c. Line 3
d. Line 4
The answer given is 1 and 3. 3 is obvious - there is no semicolon. But the reason given for line 1 is that "Synchronized is wrong here". What does that mean? Why exactly is synchronized wrong in this statement?
The synchronized block cannot be placed outside a method. Furthermore you need to synchronize over an object. System.out.println() does not return an object.