Unit 2 WT
Unit 2 WT
a. 1 - B, 2 - A, 3 - D, 4 - C
b. 1 - C, 2 - D, 3 - A, 4 - B
c. 1 - D, 2 - C, 3 - B, 4 - A
d. 1 - A, 2 - B, 3 - C, 4 - D
Answer: a. 1 - B, 2 - A, 3 - D, 4 - C
Match the following terms related to I/O Streams and Object Serialization with their
functionalities:
Term Functionality
1. ObjectOutputStream A. Writes primitive data types and objects to an output stream
2. FileInputStream B. Reads objects previously written to an output stream
3. ObjectInputStream C. Reads bytes from a file
4. DataOutputStream D. Writes objects to a file
a. 1 - A, 2 - B, 3 - C, 4 - D
b. 1 - D, 2 - A, 3 - B, 4 - C
c. 1 - B, 2 - D, 3 - C, 4 - A
d. 1 - C, 2 - B, 3 - D, 4 - A
Answer: a. 1 - A, 2 - B, 3 - C, 4 - D
Collection Description
1. ArrayList<E> A. Implements a dynamic array
2. HashMap<K, V> B. Stores elements as key-value pairs
3. LinkedList<E> C. Implements a doubly linked list
4. HashSet<E> D. Resizes itself dynamically as elements are added
a. 1 - A, 2 - B, 3 - C, 4 - D
b. 1 - D, 2 - A, 3 - B, 4 - C
c. 1 - C, 2 - B, 3 - D, 4 - A
d. 1 - A, 2 - D, 3 - C, 4 - B
Answer: a. 1 - A, 2 - B, 3 - C, 4 - D
Set 4: Concurrency
Match the following terms related to concurrency in Java with their functionalities:
Term Functionality
1. Thread A. Allows multiple threads to access shared resources safely
2. Runnable B. Represents a single thread of execution
3. synchronized C. Interface used to define tasks that can be executed concurrently
4. Lock D. Keyword used to control access to critical sections of code
a. 1 - B, 2 - A, 3 - D, 4 - C
b. 1 - C, 2 - D, 3 - B, 4 - A
c. 1 - B, 2 - A, 3 - C, 4 - D
d. 1 - D, 2 - B, 3 - A, 4 - C
Answer: a. 1 - B, 2 - A, 3 - D, 4 - C
Match the following terms related to Java networking with their functionalities:
Term Functionality
1. Socket A. Represents the endpoint of communication between two programs
2. ServerSocket B. Implements client-side of a TCP connection
3. InetAddress C. Waits for client requests on a specified port
4. HttpURLConnection D. Represents an IP address
a. 1 - A, 2 - B, 3 - C, 4 - D
b. 1 - C, 2 - D, 3 - B, 4 - A
c. 1 - A, 2 - C, 3 - D, 4 - B
d. 1 - D, 2 - B, 3 - A, 4 - C
Answer: a. 1 - A, 2 - B, 3 - C, 4 - D
a. 1 - D, 2 - A, 3 - B, 4 - C
b. 1 - B, 2 - C, 3 - A, 4 - D
c. 1 - C, 2 - B, 3 - D, 4 - A
d. 1 - A, 2 - D, 3 - C, 4 - B
Answer: a. 1 - D, 2 - A, 3 - B, 4 - C
Match the following terms related to Object Serialization in Java with their functionalities:
Term Functionality
1. ObjectOutputStream A. Reads objects previously written to an output stream
2. ObjectInputStream B. Writes objects to a file
3. Serialization C. Converts serialized data back into an object
4. Deserialization D. Saves the state of an object to a byte stream
a. 1 - B, 2 - A, 3 - C, 4 - D
b. 1 - D, 2 - B, 3 - A, 4 - C
c. 1 - C, 2 - D, 3 - B, 4 - A
d. 1 - A, 2 - C, 3 - D, 4 - B
Answer: a. 1 - B, 2 - A, 3 - C, 4 - D
Collection Description
1. TreeMap<K, V> A. Implements a resizable array
2. PriorityQueue<E> B. Stores elements as key-value pairs in ascending order
3. ArrayList<E> C. Stores elements in natural order
4. HashSet<E> D. Stores elements with unique keys
a. 1 - B, 2 - D, 3 - C, 4 - A
b. 1 - C, 2 - A, 3 - D, 4 - B
c. 1 - D, 2 - B, 3 - A, 4 - C
d. 1 - A, 2 - C, 3 - B, 4 - D
Answer: a. 1 - B, 2 - D, 3 - C, 4 - A
Set 9: Concurrency
Match the following terms related to concurrency in Java with their functionalities:
Term Functionality
1. synchronized A. Allows multiple threads to access shared resources safely
2. Executor B. Controls the order of execution of threads
3. volatile C. Synchronizes threads by acquiring a lock
4. ReentrantLock D. Ensures visibility of changes to variables across threads
a. 1 - C, 2 - A, 3 - B, 4 - D
b. 1 - A, 2 - B, 3 - C, 4 - D
c. 1 - D, 2 - C, 3 - B, 4 - A
d. 1 - B, 2 - D, 3 - A, 4 - C
Answer: a. 1 - C, 2 - A, 3 - B, 4 - D
Match the following terms related to Java networking with their functionalities:
Term Functionality
1. Socket A. Implements client-side of a TCP connection
2. ServerSocket B. Represents an endpoint of communication between two programs
3. DatagramSocket C. Receives incoming client requests
4. InetAddress D. Represents an IP address
a. 1 - A, 2 - B, 3 - C, 4 - D
b. 1 - C, 2 - A, 3 - B, 4 - D
c. 1 - D, 2 - B, 3 - A, 4 - C
d. 1 - B, 2 - C, 3 - D, 4 - A
Answer: a. 1 - A, 2 - B, 3 - C, 4 - D
a. 1 - B, 2 - A, 3 - D, 4 - C
b. 1 - C, 2 - D, 3 - A, 4 - B
c. 1 - D, 2 - C, 3 - B, 4 - A
d. 1 - A, 2 - B, 3 - C, 4 - D
Answer: a. 1 - B, 2 - A, 3 - D, 4 - C
Term Functionality
1. FileInputStream A. Writes primitive data types and objects to an output stream
2. DataOutputStream B. Reads bytes from a file
3. FileOutputStream C. Writes objects to a file
4. BufferedInputStream D. Reads primitive data types and objects from an input stream
a. 1 - B, 2 - A, 3 - C, 4 - D
b. 1 - C, 2 - D, 3 - A, 4 - B
c. 1 - D, 2 - B, 3 - A, 4 - C
d. 1 - A, 2 - C, 3 - D, 4 - B
Answer: a. 1 - B, 2 - A, 3 - C, 4 - D
Collection Description
1. LinkedHashMap<K, V> A. Implements a resizable array
2. TreeSet<E> B. Stores elements in natural order
3. LinkedList<E> C. Stores elements with unique keys in ascending order
4. ConcurrentHashMap<K, V> D. Maintains the insertion order of elements
a. 1 - D, 2 - B, 3 - A, 4 - C
b. 1 - A, 2 - C, 3 - D, 4 - B
c. 1 - B, 2 - D, 3 - C, 4 - A
d. 1 - C, 2 - A, 3 - B, 4 - D
Answer: a. 1 - D, 2 - B, 3 - A, 4 - C
a. 1 - C, 2 - D, 3 - A, 4 - B
b. 1 - A, 2 - B, 3 - C, 4 - D
c. 1 - D, 2 - A, 3 - B, 4 - C
d. 1 - B, 2 - C, 3 - D, 4 - A
Answer: a. 1 - C, 2 - D, 3 - A, 4 - B
Set 16: I/O Streams
Match the following terms related to I/O Streams in Java with their functionalities:
Term Functionality
1. FileWriter A. Reads primitive data types and objects from an input stream
2. ByteArrayOutputStream B. Writes characters to a file
3. DataInputStream C. Reads bytes from a byte array
4. CharArrayWriter D. Writes bytes to an output stream
a. 1 - B, 2 - A, 3 - C, 4 - D
b. 1 - C, 2 - D, 3 - A, 4 - B
c. 1 - D, 2 - B, 3 - C, 4 - A
d. 1 - A, 2 - C, 3 - D, 4 - B
Answer: a. 1 - B, 2 - A, 3 - C, 4 - D
Collection Description
1. TreeSet<E> A. Implements a resizable array
2. LinkedHashMap<K, V> B. Stores elements with unique keys in insertion order
C. Implements a doubly linked list that supports deque
3. ArrayDeque<E>
operations
4. ConcurrentHashMap<K, V> D. Stores elements in natural order and allows null elements
a. 1 - D, 2 - B, 3 - C, 4 - A
b. 1 - A, 2 - C, 3 - D, 4 - B
c. 1 - B, 2 - D, 3 - A, 4 - C
d. 1 - C, 2 - A, 3 - B, 4 - D
Answer: a. 1 - D, 2 - B, 3 - C, 4 - A
a. 1 - C, 2 - B, 3 - D, 4 - A
b. 1 - D, 2 - A, 3 - B, 4 - C
c. 1 - A, 2 - D, 3 - B, 4 - C
d. 1 - B, 2 - C, 3 - A, 4 - D
Answer: b. 1 - D, 2 - A, 3 - B, 4 - C
Match the following terms related to I/O Streams in Java with their functionalities:
Term Functionality
1. ByteArrayOutputStream A. Reads primitive data types and objects from an input stream
2. FileReader B. Writes characters to a file
3. DataOutputStream C. Reads bytes from a byte array
4. ByteArrayInputStream D. Writes bytes to an output stream
a. 1 - D, 2 - B, 3 - C, 4 - A
b. 1 - A, 2 - C, 3 - D, 4 - B
c. 1 - B, 2 - A, 3 - C, 4 - D
d. 1 - C, 2 - D, 3 - A, 4 - B
Answer: a. 1 - D, 2 - B, 3 - C, 4 - A
Collection Description
1. TreeSet<E> A. Implements a resizable array
2. ConcurrentHashMap<K, V> B. Stores elements in natural order and allows null elements
3. LinkedList<E> C. Stores elements with unique keys in insertion order
4. HashSet<E> D. Implements a hash table for storing key-value pairs
a. 1 - D, 2 - B, 3 - C, 4 - A
b. 1 - A, 2 - C, 3 - D, 4 - B
c. 1 - B, 2 - D, 3 - A, 4 - C
d. 1 - C, 2 - A, 3 - B, 4 - D
Answer: c. 1 - B, 2 - D, 3 - A, 4 - C