from a mock exam:
Before which of the following can the keyword "synchronized" be placed, without causing a compile error?
1. class methods
2. instance methods
3. any block of code within a method
4. variables
5. a class
I selected 1,2
But the right answer is: 1,2,3
I didnt select 3 because it would indeed give a compile error if the keyword "synchronized" is just placed before a block of code ( unless it precedes { object } )
How do we tackle such tricky questions? Any standard conventions?
I am worried about losing marks to such questions.
If 1,2,3 isthe right answer, they want me to assume the proper presence of "{ object }" after synchronized. How do i know when to assume things and when to not???
Thnx in advance,
Amol