This set of Advanced Java Multiple Choice Questions & Answers (MCQs) focuses on “Client and Server”.
1. How does applet and servlet communicate?
d) HTTP Tunneling
Explanation: Applet and Servlet communicate through HTTP Tunneling.
2. In CGI, process starts with each request and will initiate OS level process.
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?
Explanation: 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
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
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?
c) TCP and UDP
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?
c) IP Address
d) TCP Address
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?
d) 10.X.X.X, 172.X.X.X, or 192.168.X.X
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
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?
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.