You are on page 1of 1

21. Which of the following is true about TCP sockets in Java?

A) They are connectionless and


unreliable. B) They use the DatagramSocket class for communication. C) They provide
reliable, connection-oriented communication. D) They are suitable for broadcasting
messages.

22. Which method is used to close a server socket in Java? A) close() B) disconnect() C)
shutdown() D) end()

23. What is the role of the ServerSocket class in Java socket programming? A) To create a client-
side socket. B) To represent a server-side socket that listens for incoming connections. C) To
perform low-level I/O operations. D) To handle datagram-based communication.

24. Which exception is thrown when there is an error during socket communication in Java? A)
IOException B) SocketException C) NetworkException D) ProtocolException

25. How do you retrieve the output stream associated with a socket in Java? A)
socket.getOutput() B) socket.getOutputStream() C) socket.getOutputWriter() D)
socket.getSenderStream()

26.

You might also like