Advanced 250+ TOP MCQs on Client and Server and Answers

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

1. How does applet and servlet communicate?
a) HTTP
b) HTTPS
c) FTP
d) HTTP Tunneling

Answer: d
Clarification: 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

Answer: a
Clarification: 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

Answer: b
Clarification: ServerSocket is a java.net 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

Answer: c
Clarification: 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

Answer: a
Clarification: 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

Answer: c
Clarification: 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

Answer: a
Clarification: 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

Answer: d
Clarification: 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

Answer: b
Clarification: 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()

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

Leave a Reply

Your email address will not be published. Required fields are marked *