Question: Beginning with Java 10. What exception is thrown by the sleep method? a. InterruptedException c. ThreadPausedException b. NoSuchThreadException d. ThreadException 11. Which of the following

Beginning with Java

10. What exception is thrown by the sleep method?

a.

InterruptedException

c.

ThreadPausedException

b.

NoSuchThreadException

d.

ThreadException

11. Which of the following shows the proper position of the synchronized keyword in a class declaration?

a.

public int synchronized calculate(int x)

b.

public synchronized int calculate(int x)

c.

public int calculate(synchronized int x)

d.

public int calculate(int x) synchronized

12. Which of the following situations would indicate that a method does not need to be synchronized?

a.

The method doesnt accept parameters.

b.

The method doesnt have a return value.

c.

The method contains only a single Java statement.

d.

The method will never be called by more than one thread.

13. Which of the following statements is true when a method specifies the synchronized keyword?

a.

The entire object will be locked whenever any thread executes the method, so even unsynchronized methods are unavailable until the synchronized method finishes.

b.

All other threads in the application will be suspended until the synchronized method completes.

c.

Only one thread at a time will be allowed to execute the method. Any other threads that attempt to execute the method will be forced to wait until the method finishes for the current thread.

d.

Multiple threads can execute the method simultaneously. The task scheduler will automatically switch the execution among the various threads.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!