You are on page 1of 1

1. What is a socket in the context of Java programming?

A) A hardware component used for


data transmission B) An endpoint for communication between two machines over the
network C) A graphical user interface element D) A type of database storage in Java

2. Which package is used for implementing socket programming in Java? A) java.net B) java.io
C) java.lang D) java.util

3. Which class is used to represent a socket in Java? A) Socket B) ServerSocket C)


URLConnection D) DatagramSocket

4. How do you establish a TCP connection using sockets in Java? A) Using Socket and
ServerSocket classes B) Using DatagramSocket and DatagramPacket classes C) Using
URLConnection class D) Using Scanner and PrintWriter classes

5. Which method is used to connect a client socket to a server socket in Java? A) accept() B)
connect() C) listen() D) open()

You might also like