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 data structure similar to an Array or List
B. A keyword for creating loops
C. A special type of variable used only for I/O
D. A sequence of data flowing from a source to a destination

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. FileWriter
C. SystemReader
D. Scanner

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. FileWriter
B. PrintWriter
C. FileOutputStream
D. BufferedWriter

4 Which class is designed for reading character files?

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

5 What is the primary purpose of serialization in Java?

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

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

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

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 provide compile-time type safety and prevent ClassCastException.
C. They automatically manage memory allocation.
D. They allow a class to inherit from multiple other classes.

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

Generics : Creating a custom generic class Easy
A. class Container { <T> }
B. generic class Container { }
C. class Container<T> { }
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 simplifies the instantiation of generic classes by letting the compiler infer the type.
B. It is used for mathematical comparisons.
C. It defines a new data structure.
D. It is used to mark the beginning and end of a method.

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. A null value
C. An error that needs to be fixed
D. The Object type

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

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

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

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

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

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

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

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

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. stop()
C. execute()
D. start()

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

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

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

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

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. Race conditions
B. Thread starvation
C. Memory leaks
D. Deadlock

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. yield()
C. join()
D. sleep()

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

Using streams to read and write files Medium
A. It automatically handles character encoding conversions from bytes to characters.
B. It provides methods for reading primitive data types like int and double directly.
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. It will throw a NotSerializableException during deserialization.
B. The original password string.
C. An empty string "".
D. null.

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<Object>());
D. processElements(new ArrayList<Number>());

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

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. Threads created from a Runnable always have a higher default priority than those created by extending Thread.
B. Implementing Runnable provides access to more thread control methods like suspend() and resume().
C. It allows the task-defining class to extend another class, as Java does not support multiple inheritance of classes.
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 ensure that the thread calling these methods holds the monitor (lock) of the object, which is required to prevent race conditions and IllegalMonitorStateException.
B. To ensure the methods are executed with the highest possible priority.
C. To prevent a StackOverflowError from recursive calls.
D. This is a convention only and is not strictly enforced by the JVM.

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. A ClassCastException is thrown at runtime.
C. null : null
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 attempts to enter a synchronized block that is currently locked by another thread.
D. The thread calls Thread.sleep(500).

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
FileWriter fw = new FileWriter("out.txt");
try {
fw.write("data");
} finally {
fw.close();
}
B. java
FileWriter fw = new FileWriter("out.txt");
try {
fw.write("data");
} catch (IOException e) {
fw.close();
}
C. java
try (FileWriter fw = new FileWriter("out.txt")) {
fw.write("data");
} catch (IOException e) {
e.printStackTrace();
}
D. java
FileWriter fw = new FileWriter("out.txt");
fw.write("data");
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. There is no difference; start() simply calls run() internally.
C. t.run() is used to initialize the thread, and t.start() actually executes it.
D. t.start() must be called on a Thread subclass, whereas t.run() is called when using the Runnable interface.

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. Deserialization of an object may fail with an InvalidClassException if the class is modified after the object was serialized.
B. The class cannot be serialized and will throw a NotSerializableException at runtime.
C. The serialization process will be significantly slower due to runtime calculations.
D. The serialized object will consume more disk space because the version ID must be stored as a string.

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. Object obj = list.get(0);
D. list.add(null);

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. Only when synchronizing access to static fields.
B. It is never appropriate; synchronized methods are always safer and clearer.
C. When the method you are synchronizing is recursive.
D. When you only need to protect a small, critical section within a larger method to improve concurrency.

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

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

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. The notify() signal is simply discarded and has no effect.
B. The thread that called notify() enters a WAITING state until another thread calls wait().
C. An IllegalMonitorStateException is thrown because there is no thread to notify.
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
new Thread(() -> System.out.println("Running")).run();
B. java
new Runnable(() -> System.out.println("Running")).start();
C. java
Runnable r = () -> System.out.println("Running");
r.start();
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 to read and write primitive Java data types like int and boolean in a platform-independent way.
B. When processing a text file where correct handling of character encodings (like UTF-8 or ISO-8859-1) is important.
C. When you need the absolute fastest I/O performance for raw data transfer.
D. When processing a binary image file like a JPEG.

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. var map = new HashMap<String, Integer>();
D. Map<String, Integer> 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 p = new Pair<String, 25>();
B. Pair<String, Integer> p = new Pair<>("Age", 25);
C. Pair<K, V> p = new Pair<String, Integer>("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 close the stream and release all associated system resources.
B. To clear the internal buffer, discarding any data that has not yet been written.
C. To reset the stream's position back to the beginning.
D. To force any data currently held in the stream's internal buffer to be written to the underlying output destination.

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 potentially incorrect. If a multi-byte UTF-8 character is split across the internal buffer of FileInputStream, InputStreamReader might fail to decode it correctly.
B. The code is functionally correct but highly inefficient because InputStreamReader.read() makes a separate system call for each character read from the file.
C. 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.
D. 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.

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 0.
B. companyName will be "FINAL Corp" and accessLevel will be 20.
C. companyName will be "ABC Corp" and accessLevel will be 10.
D. companyName will be "XYZ Corp" and accessLevel will be 20.

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 = list1.get(0); list2.add(item);
B. T item = list2.get(0); list1.add(item);
C. Object item = list2.get(0); list1.add(item);
D. Object item = list1.get(0); list2.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 if two threads pass 'Check 1' simultaneously, as they will both enter the synchronized block and create two different instances.
D. This implementation can fail because the instance variable is not marked final, allowing its reference to be changed after initialization.

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 handle spurious wakeups, where a thread can wake from wait() without having been notified.
C. To ensure that only one consumer thread proceeds at a time after being 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. The lock someLock becomes available for thread t to acquire.
C. The specified timeout of 10 seconds elapses.
D. Another thread invokes t.interrupt().

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 T is a private type parameter and cannot be accessed inside a public method.
C. Because obj must be cast to T before the instanceof check.
D. Because instanceof can only be used with non-generic, reifiable types.

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. 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.
C. t_max will run to completion first, followed by t_norm, and then t_min, in a strict sequence.
D. 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.

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 for setting a higher thread priority than Approach A.
C. Approach B allows the task to have a return value, whereas Approach A does not.
D. Approach B allows the task logic (MyTask) to be executed by different thread management services, like an ExecutorService.

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 CyclicBarrier initialized with a count of 6.
B. A CountDownLatch initialized with a count of 5.
C. Five Future objects obtained from an ExecutorService.
D. A Semaphore initialized with 5 permits.

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 1 can copy a List<Number> into a List<Integer>, but Method 2 cannot.
B. Method 2 can copy a List<Integer> into a List<Number>, but Method 1 cannot.
C. Both methods are functionally identical; Method 2 is just more verbose.
D. Method 2 can copy a List<String> into a List<Object>, but Method 1 can also do this if T is inferred as Object.

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 can leave shared objects in a corrupted, inconsistent state because locks held by the stopped thread are suddenly released.
C. It throws a ThreadDeath error, which can be caught, allowing the thread to perform cleanup before terminating.
D. It is unreliable and may not actually stop the thread, leading to resource leaks.

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.copy(tempPath, originalPath, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE)
B. Files.move(tempPath, originalPath, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE)
C. Files.write(originalPath, bytes, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.SYNC)
D. Files.move(tempPath, originalPath, StandardCopyOption.REPLACE_EXISTING)

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 RUNNABLE state; the calling thread's state is BLOCKED.
B. Thread t is in STARTING (a conceptual, not actual, 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 NEW state; the calling thread's state is RUNNABLE.

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. Circular Wait
B. Mutual Exclusion
C. Hold and Wait
D. No Preemption

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 fails to compile because anonymous inner classes cannot extend generic classes.
B. This code compiles only in Java 9 and later, which enhanced type inference for anonymous inner classes.
C. This code compiles successfully in Java 8 and later, as the diamond operator can infer the type for anonymous inner classes.
D. This code fails to compile in all Java versions because the diamond operator cannot be used with 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 java.io.NotSerializableException is thrown at runtime when the serialization is attempted.
D. A SecurityException is thrown at runtime, as this is considered an insecure operation.

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. TERMINATED, as the operation fails without a partner thread.
B. BLOCKED, because it is waiting for a lock held by another thread.
C. WAITING or TIMED_WAITING, as it is parked by the Exchanger until the other thread arrives.
D. RUNNABLE, as the exchange method is non-blocking.