You are on page 1of 1

21. How do you retrieve the input stream associated with a socket in Java? A) socket.

getInput()
B) socket.getInputStream() C) socket.getInputReader() D) socket.getReceiverStream()

22. Which of the following methods is used to write data to a socket output stream in Java? A)
writeData() B) sendData() C) write() D) send()

23. What is the purpose of the SocketException in Java socket programming? A) To handle file
I/O errors. B) To handle errors related to networking protocols. C) To indicate an error
during socket communication. D) To represent an error with input/output streams.

24. Which method is used to set the timeout for blocking socket operations in Java? A)
setTimeout() B) setBlocking() C) setSocketTimeout() D) setBlockingTimeout()

25. In Java socket programming, which method is used to accept incoming connections on a
ServerSocket? A) accept() B) connect() C) listen() D) open()

You might also like