whether this will throw 'InterruptedException' or 'IllegalStateException'
Given the code,
The options given are :
Object obj = new Object();
The answer is B.
A. This code may throw an InterruptedException.
B. This code may throw an IllegalStateException.
C. This code may throw a TimeoutException after ten minutes.
D. This code will not compile unless "obj.wait()" is replaced with "((Thread) obj).wait()".
E. Reversing the order of obj.wait() and obj.notify() may cause this method to complete normally.
F. A call to notify() or notifyAll() from another thread may cause this method to complete normally.
I compiled the code and got InterruptedException. Since the obj.wait() is not given in the try catch block, the InterruptedException is thrown(I believe). But how come the correct answer is given as B, i.e., IllegalStateException. Can anyone clear my doubt?