Multi-Threading and Concurrency


Question-1. Have a look at the following snippet :


Choose the correct option.

A. Prints A B C and then terminates

B. Prints A B and then terminates

C. Prints A B C

D. Prints A B

E. Either A or D

F. At runtime, it throws an IllegalMonitorStateException


Question-2. Have a look at the following code snippet :


What will be the output after running this code?

A. Runner faster

B. Compilation Error

C. Runner rapid

D. Runner quicker

E. Runner faster quicker

F. None


Question-3. Which two statements are true? (Choose two)

A. It is possible for more than two threads to deadlock at once.

B. The JVM implementation guarantees that multiple threads cannot enter into a deadlocked state.

C. Deadlocked threads release once their sleep() method's sleep duration has expired.

D. Deadlocking can occur only when the wait(), notify(), and notifyAll() methods are used incorrectly.

E. It is possible for a single-threaded application to deadlock if synchronized blocks are used incorrectly.

F. If a piece of code is capable of deadlocking, you cannot eliminate the possibility of deadlocking by inserting invocations of Thread.yield().


Click here for answers

No comments:

Post a Comment