Multiple Choice Questions - Java Multithreading

Multiple Choice Questions - Java Multithreading


1. Multithreading makes it possible to obtain vastly greater performance than was ever before possible by taking advantage of . . . . . . . . . . .

A) multiple GPUs
B) multiple RAMs
C) multiprocessor machine
D) java cards

2. The . . . . . . . . . . method of the thread is called before the . . . . . . . . . method and carries out any initialisation.

A) suspend, resume
B) start, run
C) start, stop
D) resume, suspend

3. The . . . . . . . . . . . . keyword tells Java to make the block of code in the method thread safe. This means that only one thread will be allowed inside this method at once, and other threads will have to wait until the currently running thread is finished with it before they can begin running it.

A) pre-emptive
B) alternative
C) safest
D) synchronized

4. If a variable is marked as . . . . . . . . , every time the variable is used it must be read from the main memory. Similarly every time a variable is written, the value must be stored in main memory.

A) volatile
B) shared
C) static
D) local

5. In pre-emptive scheduling a thread can be in one of the three states:

A) Start, Ready, Resume
B) Running, Ready, Blocked
C) Running, Ready, Resume
D) Running, unBlocked, Blocked

6. Race condition occurs due to the race between multiple threads, if a thread which is supposed to execute first lost the race and executed second, behavior of the code changes, which surface as a non-deterministic bugs.

A) True
B) False

7. You can share data between the threads by using shared object, or concurrent data-structure like . . . . . . .

A) StaticQueue
B) Non-BlockingQueue
C) BlockingQueue
D) AmberQueue

8. A livelock is similar to a deadlock, except that the states of the thread or processes involved in the . . . . . . . . . constantly change with regard to one another, without any one progressing further.

A) livelock
B) deadlock

9. . . . . . . . is a technique which concurrent programmers employ to make a thread wait on certain condition. Unlike traditional methods like wait(), sleep() etc. which all involve relinquishing CPU control, this method does not relinquish CPU, instead it just runs empty loop, in order to preserve CPU caches.

A) Thread dump
B) Reentrant Lock
C) Hash Map
D) Busy spin

10. . . . . . . . . is the process of storing and restoring of CPU state so that Thread execution can be resumed from the same point at a later point of time.

A) Thread Join
B) Context Switching
C) Parallel Switching
D) Thread Switching

Answers