UPDATED the code
As for your question, its possible that main thread executes before any other thread that you start...
THe answer is exam lab is that
there would be no output .
As when thread b starts ,it acquires lock on a.then,when it goes to it's
doTask2 method,it joins and waits till thread main completes.
Thread main too needs lock on a to call line2.
The case when main thread runs before b thread is not taken into account
So, answer in Exam Lab is wrong