0% found this document useful (0 votes)
6 views7 pages

Unit 2 WT

The document consists of multiple sets of matching questions related to Java programming concepts, including SWING components, I/O streams, generic collections, concurrency, and networking. Each set provides a list of terms or components alongside their functionalities or descriptions, with the correct matches indicated. The answers for each set are provided in a consistent format, highlighting the relationships between the terms and their respective functionalities.

Uploaded by

Anbarasa Pandian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views7 pages

Unit 2 WT

The document consists of multiple sets of matching questions related to Java programming concepts, including SWING components, I/O streams, generic collections, concurrency, and networking. Each set provides a list of terms or components alongside their functionalities or descriptions, with the correct matches indicated. The answers for each set are provided in a consistent format, highlighting the relationships between the terms and their respective functionalities.

Uploaded by

Anbarasa Pandian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Set 1: SWING Components

Match the following SWING components with their descriptions:

SWING Component Description


1. JButton A. Displays a list of items that can be selected
2. JList B. Represents a button that can trigger an action
3. JTextField C. Allows users to select a file from the file system
4. JFileChooser D. Accepts user input as text

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

Set 2: I/O Streams and Object Serialization

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

Set 3: Generic Collections

Match the following generic collections in Java with their descriptions:

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

Set 5: Java Networking

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

Set 6: SWING Layout Managers

Match the following SWING layout managers with their descriptions:

Layout Manager Description


1. BorderLayout A. Arranges components in a grid-like layout
2. FlowLayout B. Places components in the center of the container
3. GridLayout C. Positions components in a single row or column
4. GridBagLayout D. Divides the container into five regions: North, South, East, West, and
Layout Manager Description
Center

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

Set 7: Object Serialization

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

Set 8: Generic Collections

Match the following generic collections in Java with their descriptions:

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

Set 10: Java Networking

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

Set 11: SWING Components

Match the following SWING components with their functionalities:

SWING Component Functionality


1. JCheckBox A. Allows users to select a file from the file system
2. JFileChooser B. Displays a list of items that can be selected
3. JRadioButton C. Allows users to choose multiple options from a list
4. JComboBox D. Allows users to choose a single option from a drop-down menu

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

Set 12: I/O Streams


Match the following terms related to I/O Streams in Java with their functionalities:

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

Set 13: Generic Collections

Match the following generic collections in Java with their descriptions:

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

Set 15: SWING Components

Match the following SWING components with their functionalities:

SWING Component Functionality


1. JPasswordField A. Allows users to enter text in a single line
2. JTextArea B. Displays a list of selectable items
3. JComboBox C. Allows users to enter passwords securely
4. JList D. Allows users to enter and edit multiline text

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

Set 17: Generic Collections

Match the following generic collections in Java with their descriptions:

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

Set 19: SWING Layout Managers

Match the following SWING layout managers with their descriptions:

Layout Manager Description


1. CardLayout A. Arranges components in a grid-like layout
2. BoxLayout B. Positions components in a single row or column
3. GroupLayout C. Allows only one component to be visible at a time
4. GridBagLayout D. Lays out components in a sequence like rows of a table

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

Set 20: I/O Streams

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

Set 21: Generic Collections

Match the following generic collections in Java with their descriptions:

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

You might also like