Advanced Java Questions & Answers – Client and Server

This set of Advanced Java Multiple Choice Questions & Answers (MCQs) focuses on “Client and Server”.

1. How does applet and servlet communicate?
c) FTP
d) HTTP Tunneling
View Answer

Answer: d
Explanation: Applet and Servlet communicate through HTTP Tunneling.

2. In CGI, process starts with each request and will initiate OS level process.
a) True
b) False
View Answer

Answer: a
Explanation: A new process is started with each client request and that corresponds to initiate a heavy OS level process for each client request.

3. Which class provides system independent server side implementation?
a) Socket
b) ServerSocket
c) Server
d) ServerReader
View Answer

Answer: b
Explanation: ServerSocket is a class which provides system independent implementation of server side socket connection.

4. What happens if ServerSocket is not able to listen on the specified port?
a) The system exits gracefully with appropriate message
b) The system will wait till port is free
c) IOException is thrown when opening the socket
d) PortOccupiedException is thrown
View Answer

Answer: c
Explanation: public ServerSocket() creates an unbound server socket. It throws IOException if specified port is busy when opening the socket.

5. What does bind() method of ServerSocket offer?
a) binds the serversocket to a specific address (IP Address and port)
b) binds the server and client browser
c) binds the server socket to the JVM
d) binds the port to the JVM
View Answer

Answer: a
Explanation: bind() binds the server socket to a specific address (IP Address and port). If address is null, the system will pick an ephemeral port and valid local address to bind socket.

6. Which of the below are common network protocols?
a) TCP
b) UDP
c) TCP and UDP
d) CNP
View Answer

Answer: c
Explanation: Transmission Control Protocol(TCP) and User Datagram Protocol(UDP) are the two common network protocol. TCP/IP allows reliable communication between two applications. UDP is connection less protocol.

7. Which class represents an Internet Protocol address?
a) InetAddress
b) Address
c) IP Address
d) TCP Address
View Answer

Answer: a
Explanation: InetAddress represents an Internet Protocol address. It provides static methods like getByAddress(), getByName() and other instance methods like getHostName(), getHostAddress(), getLocalHost().

8. What does local IP address start with?
a) 10.X.X.X
b) 172.X.X.X
c) 192.168.X.X
d) 10.X.X.X, 172.X.X.X, or 192.168.X.X
View Answer

Answer: d
Explanation: Local IP addresses look like 10.X.X.X, 172.X.X.X, or 192.168.X.X.

9. What happens if IP Address of host cannot be determined?
a) The system exit with no message
b) UnknownHostException is thrown
c) IOException is thrown
d) Temporary IP Address is assigned
View Answer

Answer: b
Explanation: UnknownHostException is thrown when IP Address of host cannot be determined. It is an extension of IOException.

10. What is the java method for ping?
a) hostReachable()
b) ping()
c) isReachable()
d) portBusy()
View Answer

Answer: c
Explanation: inet.isReachable(5000) is a way to ping a server in java.

Sanfoundry Global Education & Learning Series – Java Programming Language.

To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.