Unit 5 - Practice Quiz

CSE310 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 In Java I/O, what is a "stream"?

Describing the basics of input and output in Java Easy
A. A keyword for creating loops
B. A sequence of data flowing from a source to a destination
C. A data structure similar to an Array or List
D. A special type of variable used only for I/O

2 Which class is commonly used to read input from the console (System.in) in Java?

Read and write data from various sources Easy
A. ConsoleReader
B. Scanner
C. SystemReader
D. FileWriter

3 To write raw binary data to a file, which of the following streams should be used?

Using streams to read and write files Easy
A. PrintWriter
B. FileWriter
C. BufferedWriter
D. FileOutputStream

4 Which class is designed for reading character files?

Using streams to read and write files Easy
A. FileInputStream
B. ObjectInputStream
C. DataInputStream
D. FileReader

5 What is the primary purpose of serialization in Java?

Writing and read objects using serialization Easy
A. To organize methods within a class
B. To handle runtime exceptions
C. To convert a Java object's state into a byte stream
D. To compile a Java .java file into a .class file

6 To make a class's objects eligible for serialization, which interface must the class implement?

Writing and read objects using serialization Easy
A. Serializable
B. Cloneable
C. Comparable
D. Runnable

7 What is the main benefit of using Generics in Java?

Generics : Creating a custom generic class Easy
A. They increase the execution speed of the program.
B. They allow a class to inherit from multiple other classes.
C. They provide compile-time type safety and prevent ClassCastException.
D. They automatically manage memory allocation.

8 Which syntax is correct for declaring a generic class named Container?

Generics : Creating a custom generic class Easy
A. class Container<T> { }
B. class Container { <T> }
C. generic class Container { }
D. class <T> Container { }

9 What is the purpose of the diamond operator (<>) in Java?

Using the type inference diamond to create an object Easy
A. It defines a new data structure.
B. It is used for mathematical comparisons.
C. It is used to mark the beginning and end of a method.
D. It simplifies the instantiation of generic classes by letting the compiler infer the type.

10 In Java generics, what does the wildcard character ? represent in a declaration like List<?>?

Using bounded types and Wild Cards. Easy
A. An unknown type
B. The Object type
C. An error that needs to be fixed
D. A null value

11 What does the generic syntax <T extends Number> mean?

Using bounded types and Wild Cards. Easy
A. This is an invalid Java syntax.
B. It is a lower-bounded wildcard, meaning T can be Number or any of its superclasses.
C. It is an upper-bounded wildcard, meaning T can be Number or any of its subclasses.
D. T can be any type except Number.

12 Which of the following is a valid state in the Java thread lifecycle?

Multithreading (Threads) : Thread lifecycle. Easy
A. EXECUTING
B. STARTED
C. FINISHED
D. RUNNABLE

13 What method call transitions a thread from the NEW state to the RUNNABLE state?

Multithreading (Threads) : Thread lifecycle. Easy
A. init()
B. execute()
C. start()
D. run()

14 One way to create a thread in Java is by creating a class that extends which built-in class?

Thread class. Easy
A. Runnable
B. Process
C. Executor
D. Thread

15 If you create a thread by implementing the Runnable interface, which method from the interface must you override?

Runnable interface Easy
A. run()
B. execute()
C. stop()
D. start()

16 Why is implementing the Runnable interface often preferred over extending the Thread class?

Runnable interface Easy
A. Because Java does not support multiple inheritance of classes, implementing an interface allows more flexibility.
B. Because the Thread class is marked as deprecated.
C. Because Runnable threads run faster than Thread subclasses.
D. Because Runnable is an older, more stable API.

17 In Java, what is the value of Thread.NORM_PRIORITY?

Thread priorities Easy
A. 5
B. 1
C. 10
D. 0

18 Which Java keyword is used to ensure that a method or block of code can only be accessed by one thread at a time?

Synchronization Easy
A. volatile
B. synchronized
C. static
D. transient

19 Synchronization in Java is used to prevent which common multithreading problem?

Synchronization Easy
A. Thread starvation
B. Deadlock
C. Memory leaks
D. Race conditions

20 Which method causes the current thread to pause execution and release the object's lock until another thread calls notify() or notifyAll()?

inter-thread communication Easy
A. wait()
B. join()
C. sleep()
D. yield()

21 What is the primary advantage of wrapping a FileInputStream with a BufferedInputStream?

Using streams to read and write files Medium
A. It provides methods for reading primitive data types like int and double directly.
B. It automatically handles character encoding conversions from bytes to characters.
C. It reduces the number of physical read operations on the underlying file system by reading data in larger chunks into a buffer.
D. It encrypts the data being read from the file for security purposes.

22 Consider the following class. If an object of Employee is serialized and then deserialized, what will be the value of the tempPassword field in the new object?
java
class Employee implements java.io.Serializable {
public String name;
public transient String tempPassword;
private static final long serialVersionUID = 1L;

public Employee(String name, String password) {
this.name = name;
this.tempPassword = password;
}
}

Writing and read objects using serialization Medium
A. null.
B. An empty string "".
C. It will throw a NotSerializableException during deserialization.
D. The original password string.

23 Given the method signature public void processElements(List<? extends Number> list), which of the following method calls is invalid?

Generics : Using bounded types and Wild Cards. Medium
A. processElements(new ArrayList<Integer>());
B. processElements(new ArrayList<Double>());
C. processElements(new ArrayList<Number>());
D. processElements(new ArrayList<Object>());

24 Examine this code. What is a potential issue when multiple threads call the increment() method concurrently on the same Counter instance?
java
class Counter {
private int count = 0;

public void increment() {
count++;
}

public int getCount() {
return count;
}
}

Synchronization Medium
A. The count variable will not be visible to other threads due to instruction reordering.
B. The program will enter a deadlock.
C. A NullPointerException will be thrown if two threads call it at the same time.
D. A race condition may occur, leading to an incorrect final count value due to lost updates.

25 What is the primary advantage of implementing the Runnable interface over extending the Thread class to create a thread in Java?

Runnable interface Medium
A. It allows the task-defining class to extend another class, as Java does not support multiple inheritance of classes.
B. Implementing Runnable provides access to more thread control methods like suspend() and resume().
C. Threads created from a Runnable always have a higher default priority than those created by extending Thread.
D. Runnable instances can be started using the run() method directly to create a new thread.

26 In Java's inter-thread communication mechanism, why must wait() and notify() be called from within a synchronized block or method?

inter-thread communication Medium
A. To prevent a StackOverflowError from recursive calls.
B. To ensure the methods are executed with the highest possible priority.
C. This is a convention only and is not strictly enforced by the JVM.
D. To ensure that the thread calling these methods holds the monitor (lock) of the object, which is required to prevent race conditions and IllegalMonitorStateException.

27 What is the output of the following Java code snippet?
java
class Box<T> {
private T item;
public void set(T item) { this.item = item; }
public T get() { return item; }
}

public class Main {
public static void main(String[] args) {
Box<Integer> integerBox = new Box<>();
integerBox.set(10);
Box<String> stringBox = new Box<>();
stringBox.set("Hello");
System.out.printf("%s : %d", stringBox.get(), integerBox.get());
}
}

Generics : Creating a custom generic class Medium
A. Hello : 10
B. null : null
C. A ClassCastException is thrown at runtime.
D. The code fails to compile because Box cannot be instantiated with different types.

28 A thread is currently in the RUNNABLE state. What could cause it to transition to the BLOCKED state?

Thread lifecycle. Medium
A. The thread's run() method completes its execution.
B. The thread calls the wait() method on an object.
C. The thread calls Thread.sleep(500).
D. The thread attempts to enter a synchronized block that is currently locked by another thread.

29 Which code snippet correctly demonstrates the modern, preferred way to ensure a FileWriter is closed automatically, even if an exception occurs?

Using streams to read and write files Medium
A. java
try (FileWriter fw = new FileWriter("out.txt")) {
fw.write("data");
} catch (IOException e) {
e.printStackTrace();
}
B. java
FileWriter fw = new FileWriter("out.txt");
fw.write("data");
fw.close();
C. java
FileWriter fw = new FileWriter("out.txt");
try {
fw.write("data");
} catch (IOException e) {
fw.close();
}
D. java
FileWriter fw = new FileWriter("out.txt");
try {
fw.write("data");
} finally {
fw.close();
}

30 What is the fundamental difference between invoking t.start() versus t.run() on a Thread object t?

Thread class. Medium
A. t.start() creates a new thread of execution and calls the run() method within it, while t.run() executes the run() method on the current calling thread.
B. t.start() must be called on a Thread subclass, whereas t.run() is called when using the Runnable interface.
C. t.run() is used to initialize the thread, and t.start() actually executes it.
D. There is no difference; start() simply calls run() internally.

31 A class implements Serializable but does not declare a private static final long serialVersionUID. What is a potential risk of this omission?

Writing and read objects using serialization Medium
A. The serialized object will consume more disk space because the version ID must be stored as a string.
B. Deserialization of an object may fail with an InvalidClassException if the class is modified after the object was serialized.
C. The serialization process will be significantly slower due to runtime calculations.
D. The class cannot be serialized and will throw a NotSerializableException at runtime.

32 You have a method with the signature void addNumbers(List<? super Integer> list). Which of the following lines of code would cause a compilation error if placed inside this method?

Generics : Using bounded types and Wild Cards. Medium
A. Integer myInt = list.get(0);
B. list.add(100);
C. list.add(null);
D. Object obj = list.get(0);

33 When is it more appropriate to use a synchronized block on a private lock object (private final Object lock = new Object();) instead of synchronizing the entire method or using this?

Synchronization Medium
A. When you only need to protect a small, critical section within a larger method to improve concurrency.
B. Only when synchronizing access to static fields.
C. When the method you are synchronizing is recursive.
D. It is never appropriate; synchronized methods are always safer and clearer.

34 What is the most accurate description of how thread priorities, set via Thread.setPriority(), work in Java?

Thread priorities Medium
A. Priorities are an absolute contract with the OS, ensuring a strict execution order.
B. A thread with priority Thread.MAX_PRIORITY is guaranteed to execute to completion before any thread with Thread.MIN_PRIORITY begins.
C. Setting a priority also allocates a proportional amount of CPU memory to the thread.
D. Thread priorities are merely hints to the thread scheduler, and the actual scheduling behavior is platform-dependent and not guaranteed.

35 What happens if a thread calls notify() on an object's monitor, but no other threads are in a wait() state on that same monitor?

inter-thread communication Medium
A. An IllegalMonitorStateException is thrown because there is no thread to notify.
B. The notify() signal is simply discarded and has no effect.
C. The thread that called notify() enters a WAITING state until another thread calls wait().
D. The program will enter a deadlock state.

36 Which of the following snippets correctly creates and starts a new thread using a lambda expression to define the Runnable task?

Runnable interface Medium
A. java
Runnable r = () -> System.out.println("Running");
r.start();
B. java
new Runnable(() -> System.out.println("Running")).start();
C. java
new Thread(() -> System.out.println("Running")).run();
D. java
Thread t = new Thread(() -> System.out.println("Running"));
t.start();

37 Under which scenario would you choose to use a class from the Reader/Writer hierarchy over one from the InputStream/OutputStream hierarchy?

Describing the basics of input and output in Java Medium
A. When you need the absolute fastest I/O performance for raw data transfer.
B. When you need to read and write primitive Java data types like int and boolean in a platform-independent way.
C. When processing a binary image file like a JPEG.
D. When processing a text file where correct handling of character encodings (like UTF-8 or ISO-8859-1) is important.

38 Which of the following lines of code is a direct example of using the type inference diamond operator introduced in Java 7?

Using the type inference diamond to create an object Medium
A. Map<String, Integer> map = new HashMap<>();
B. Map map = new HashMap();
C. Map<String, Integer> map = new HashMap<String, Integer>();
D. var map = new HashMap<String, Integer>();

39 Given the following generic class, which option correctly instantiates it to create a pair of a String and an Integer?
java
class Pair<K, V> {
private K key;
private V value;

public Pair(K key, V value) {
this.key = key;
this.value = value;
}
// ... getters
}

Generics : Creating a custom generic class Medium
A. Pair<K, V> p = new Pair<String, Integer>("Age", 25);
B. Pair p = new Pair<String, 25>();
C. Pair<String, Integer> p = new Pair<>("Age", 25);
D. Pair<String, Integer> p = new Pair<>("Age", "25");

40 What is the primary purpose of calling the flush() method on a BufferedWriter or FileOutputStream?

Read and write data from various sources Medium
A. To clear the internal buffer, discarding any data that has not yet been written.
B. To close the stream and release all associated system resources.
C. To force any data currently held in the stream's internal buffer to be written to the underlying output destination.
D. To reset the stream's position back to the beginning.

41 Consider the following code snippet designed to read a text file encoded in UTF-8. Which statement best analyzes its performance and correctness implications?

java
void readFile(String path) throws IOException {
FileInputStream fis = new FileInputStream(path);
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
// Line A
int data;
while ((data = isr.read()) != -1) {
System.out.print((char) data);
}
isr.close();
}

Using streams to read and write files Hard
A. The code is functionally correct but highly inefficient because it reads one byte at a time. Wrapping the FileInputStream in a BufferedInputStream would be the most effective optimization.
B. The code is functionally correct but highly inefficient because it reads one character at a time. Wrapping the InputStreamReader in a BufferedReader would be the most effective optimization.
C. The code is functionally correct but highly inefficient because InputStreamReader.read() makes a separate system call for each character read from the file.
D. The code is potentially incorrect. If a multi-byte UTF-8 character is split across the internal buffer of FileInputStream, InputStreamReader might fail to decode it correctly.

42 Examine the following class structure. A Manager object is serialized and then deserialized. What will be the value of companyName and accessLevel in the deserialized object?

java
class Employee {
String name = "Default";
public Employee() {
System.out.println("Employee Constructor");
}
}

class Manager extends Employee implements Serializable {
private static final long serialVersionUID = 1L;
static String companyName = "ABC Corp";
transient int accessLevel = 10;

public Manager() {
System.out.println("Manager Constructor");
this.name = "Manager";
this.accessLevel = 20;
}
}

// Main execution logic:
// Manager m = new Manager();
// companyName is changed to "XYZ Corp"
// m is serialized.
// companyName is changed to "FINAL Corp"
// m is deserialized into m2.

Writing and read objects using serialization Hard
A. companyName will be "FINAL Corp" and accessLevel will be 20.
B. companyName will be "ABC Corp" and accessLevel will be 10.
C. companyName will be "XYZ Corp" and accessLevel will be 20.
D. companyName will be "FINAL Corp" and accessLevel will be 0.

43 Given the following method signature, which of the provided code snippets will compile successfully inside the process method?

java
public <T> void process(List<? super T> list1, List<? extends T> list2) {
// Method body
}

Using bounded types and Wild Cards. Hard
A. T item = list2.get(0); list1.add(item);
B. Object item = list1.get(0); list2.add(item);
C. T item = list1.get(0); list2.add(item);
D. Object item = list2.get(0); list1.add(item);

44 Analyze the following DoubleCheckedLocking singleton implementation. Under which condition could this implementation fail, and why?

java
public class Singleton {
private static Singleton instance;

private Singleton() {}

public static Singleton getInstance() {
if (instance == null) { // Check 1
synchronized (Singleton.class) {
if (instance == null) { // Check 2
instance = new Singleton(); // Assignment
}
}
}
return instance;
}
}

Synchronization Hard
A. This implementation is thread-safe and will not fail under any circumstances due to the double-checked lock.
B. This implementation can fail on multi-core processors with pre-Java 5 memory models because of instruction reordering, allowing a thread to see a non-null but incompletely constructed instance.
C. This implementation can fail because the instance variable is not marked final, allowing its reference to be changed after initialization.
D. This implementation can fail if two threads pass 'Check 1' simultaneously, as they will both enter the synchronized block and create two different instances.

45 Consider a producer-consumer implementation using wait() and notifyAll(). What is the primary purpose of checking the condition (e.g., while (queue.isEmpty())) in a while loop instead of an if statement before calling wait()?

inter-thread communication Hard
A. To prevent a deadlock that can occur if notifyAll() is called before wait().
B. To ensure that only one consumer thread proceeds at a time after being notified.
C. To handle spurious wakeups, where a thread can wake from wait() without having been notified.
D. To re-acquire the monitor lock that was released when wait() was called.

46 A thread t is in the TIMED_WAITING state because it has called someLock.tryLock(10, TimeUnit.SECONDS). Which of the following events will NOT cause the thread t to transition out of the TIMED_WAITING state?

Thread lifecycle. Hard
A. Another thread invokes t.suspend().
B. Another thread invokes t.interrupt().
C. The specified timeout of 10 seconds elapses.
D. The lock someLock becomes available for thread t to acquire.

47 Analyze the following generic class. Why does the line marked // COMPILATION ERROR fail to compile?

java
class Node<T> {
private T data;
private static int count;

public Node(T data) {
this.data = data;
}

public static void updateCount() {
// count++; // This is fine
}

public boolean isInstance(Object obj) {
// return obj instanceof T; // COMPILATION ERROR
return false;
}
}

Generics : Creating a custom generic class Hard
A. Because the isInstance method should be declared as static.
B. Because obj must be cast to T before the instanceof check.
C. Because instanceof can only be used with non-generic, reifiable types.
D. Because T is a private type parameter and cannot be accessed inside a public method.

48 On a single-core CPU running a modern preemptive multitasking OS like Linux or Windows, you create three CPU-bound threads t_min, t_norm, and t_max and set their priorities to Thread.MIN_PRIORITY, Thread.NORM_PRIORITY, and Thread.MAX_PRIORITY respectively. All three threads are started simultaneously. Which statement most accurately describes the expected execution behavior?

Thread priorities Hard
A. The behavior is undefined and completely random, as Java thread priorities have no mapping to native OS thread priorities.
B. t_max will run to completion first, followed by t_norm, and then t_min, in a strict sequence.
C. The Java thread priorities will be ignored by the underlying OS, and all threads will be treated equally, receiving roughly the same amount of CPU time.
D. The OS scheduler will likely give more time slices to t_max than t_norm, and more to t_norm than t_min, but all three will appear to run concurrently.

49 Consider the following two ways to create and start a thread. What is a key design advantage of Approach B (implementing Runnable) over Approach A (extending Thread)?

java
// Approach A
class MyThread extends Thread {
public void run() { / task / }
}
Thread t1 = new MyThread();

// Approach B
class MyTask implements Runnable {
public void run() { / task / }
}
Thread t2 = new Thread(new MyTask());

Runnable interface Hard
A. Approach B consumes less memory because a Runnable object is lighter than a Thread object.
B. Approach B allows the task logic (MyTask) to be executed by different thread management services, like an ExecutorService.
C. Approach B allows for setting a higher thread priority than Approach A.
D. Approach B allows the task to have a return value, whereas Approach A does not.

50 A class Data implements Externalizable. During deserialization via ObjectInputStream.readObject(), what is the exact sequence of events that occurs to create and initialize the new Data object?

Writing and read objects using serialization Hard
A. The JVM calls the no-arg constructor of the Data class to create an instance, and then calls the readExternal() method on this newly created instance.
B. The JVM allocates memory for a Data object, then calls the readExternal() method on the blank object, which is responsible for populating all its fields.
C. The JVM uses reflection to create an instance of Data without calling any constructor, and then calls readExternal().
D. The JVM reads the superclass data first (if any), then allocates memory for the Data object, and finally calls readExternal().

51 What is the primary difference in locking behavior between a java.util.concurrent.locks.ReentrantLock created with new ReentrantLock(true) and a standard synchronized block?

Synchronization Hard
A. The ReentrantLock(true) allows interruption while waiting for the lock (lockInterruptibly), while a thread waiting on a synchronized block cannot be interrupted.
B. The ReentrantLock(true) is significantly faster under high contention than a synchronized block.
C. The ReentrantLock(true) is reentrant, while a synchronized block is not.
D. The ReentrantLock(true) provides a fairness policy, attempting to grant access to the longest-waiting thread, whereas synchronized blocks make no such guarantee.

52 A task requires five worker threads to perform a computation and then a single master thread to aggregate the results. All five workers must complete their work before the master can begin aggregation. Which concurrency utility is most suitable for this specific coordination problem?

inter-thread communication Hard
A. A Semaphore initialized with 5 permits.
B. A CyclicBarrier initialized with a count of 6.
C. A CountDownLatch initialized with a count of 5.
D. Five Future objects obtained from an ExecutorService.

53 Consider the following method signatures. Which statement correctly identifies a valid and an invalid use case?

java
// Method 1
<T> void copy(List<T> dest, List<T> src);

// Method 2
<T> void copy(List<? super T> dest, List<? extends T> src);

Using bounded types and Wild Cards. Hard
A. Method 2 can copy a List<String> into a List<Object>, but Method 1 can also do this if T is inferred as Object.
B. Both methods are functionally identical; Method 2 is just more verbose.
C. Method 2 can copy a List<Integer> into a List<Number>, but Method 1 cannot.
D. Method 1 can copy a List<Number> into a List<Integer>, but Method 2 cannot.

54 A thread is executing a long-running computation. Another thread calls the stop() method on this thread object. Which of the following is the most severe and direct consequence of using Thread.stop()?

Multithreading (Threads) : Thread class. Hard
A. The thread will ignore the stop() call if it is in the middle of a synchronized block.
B. It is unreliable and may not actually stop the thread, leading to resource leaks.
C. It can leave shared objects in a corrupted, inconsistent state because locks held by the stopped thread are suddenly released.
D. It throws a ThreadDeath error, which can be caught, allowing the thread to perform cleanup before terminating.

55 You need to perform a transactional file write operation: write data to a temporary file, and only if the entire write is successful, replace the original file with the temporary one. Which java.nio.file.Files method and StandardCopyOption is best suited for this task?

Using streams to read and write files Hard
A. Files.move(tempPath, originalPath, StandardCopyOption.REPLACE_EXISTING)
B. Files.write(originalPath, bytes, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.SYNC)
C. Files.copy(tempPath, originalPath, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE)
D. Files.move(tempPath, originalPath, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE)

56 What is the state of a thread t immediately after new Thread(runnable) is executed but before t.start() is called, and what is the state of the thread that called t.start() immediately after the call returns?

Thread lifecycle. Hard
A. Thread t is in STARTING (a conceptual, not actual, state); the calling thread's state is RUNNABLE.
B. Thread t is in NEW state; the calling thread's state is RUNNABLE.
C. Thread t is in NEW state; the calling thread's state is WAITING.
D. Thread t is in RUNNABLE state; the calling thread's state is BLOCKED.

57 Consider a deadlock scenario involving two threads, T1 and T2, and two locks, L1 and T2. T1 acquires L1 then tries to acquire L2. T2 acquires L2 then tries to acquire L1. According to the Coffman conditions for deadlock, which specific condition is most directly broken by establishing a global, fixed order for acquiring locks (e.g., always acquire L1 before L2)?

Synchronization Hard
A. Mutual Exclusion
B. Hold and Wait
C. No Preemption
D. Circular Wait

58 Given the following generic class and its usage, what can be inferred about the diamond operator (<>) and anonymous inner classes?

java
import java.util.Comparator;

class Pair<T> {
T first, second;
Pair(T f, T s) { this.first = f; this.second = s; }
}

// Usage:
Pair<String> p = new Pair<>("a", "b") {
// anonymous inner class body
};

Using the type inference diamond to create an object Hard
A. This code compiles successfully in Java 8 and later, as the diamond operator can infer the type for anonymous inner classes.
B. This code fails to compile in all Java versions because the diamond operator cannot be used with anonymous inner classes.
C. This code fails to compile because anonymous inner classes cannot extend generic classes.
D. This code compiles only in Java 9 and later, which enhanced type inference for anonymous inner classes.

59 What happens if you attempt to serialize an object of a class that implements Serializable, but one of its instance fields is an object of a class that does not implement Serializable?

Writing and read objects using serialization Hard
A. The field is silently skipped during serialization, similar to a transient field, and will be null upon deserialization.
B. A ClassNotFoundException is thrown at compile time.
C. A SecurityException is thrown at runtime, as this is considered an insecure operation.
D. A java.io.NotSerializableException is thrown at runtime when the serialization is attempted.

60 A java.util.concurrent.Exchanger is used by two threads, T1 and T2. T1 calls exchanger.exchange(data1). T2 is delayed and has not yet called exchange(). What is the state of T1?

inter-thread communication Hard
A. RUNNABLE, as the exchange method is non-blocking.
B. TERMINATED, as the operation fails without a partner thread.
C. BLOCKED, because it is waiting for a lock held by another thread.
D. WAITING or TIMED_WAITING, as it is parked by the Exchanger until the other thread arrives.