This set of Advanced Java Multiple Choice Questions & Answers (MCQs) focuses on “Client and Server”.
1. How does applet and servlet communicate?
a) HTTP
b) HTTPS
c) FTP
d) HTTP Tunneling
View Answer
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
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
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
View Answer
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
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
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
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
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
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
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.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Practice Programming MCQs
- Check Java Books
- Practice BCA MCQs
- Apply for Computer Science Internship
- Check Programming Books