You are on page 1of 1

1. Which class is used to represent a datagram socket in Java?

A) Socket B) DatagramSocket C)
ServerSocket D) URLConnection

2. Which method is used to bind a server socket to a specific port in Java? A) bind() B)
connect() C) listen() D) open()

3. Which type of communication does TCP provide in Java socket programming? A)


Connectionless and unreliable B) Connection-oriented and reliable C) Connectionless and
reliable D) Connection-oriented and unreliable

4. How do you retrieve the port number of a socket in Java? A) socket.getPort() B)


socket.getLocalPort() C) socket.getRemotePort() D) socket.getSocketPort()

5. Which method is used to accept incoming connections on a server socket in Java? A)


accept() B) connect() C) listen() D) open()

You might also like