Java MCQS
Java MCQS
a) java.io
b) java.util
c) java.net
d) java.network
2. Which of these is a protocol for breaking and sending packets to an address across a network?
a) TCP/IP
b) DNS
c) Socket
d) Proxy Server
3. How many ports of TCP/IP are reserved for specific protocols?
a) 10
b) 1024
c) 2048
d) 512
4. How many bits are in a single IP address?
a) 8
b) 16
c) 32
d) 64
5. Which of these is a full form of DNS?
a) Data Network Service
b) Data Name Service
c) Domain Network Service
d) Domain Name Service
6. . Which of these class is used to encapsulate IP address and DNS?
a) DatagramPacket
b) URL
c) InetAddress
d) ContentHandler
7. URL stands for Uniform Resource Locator and represents a resource on the World Wide Web,
such as a Web page or FTP directory.
a. True
b. False
8 Which class is used to create servers that listen for either local client or remote client programs?
a. ServerSockets
b. httpServer
c. httpResponse
d. None of the above
9 Which constructor of DatagramSocket class is used to creates a datagram socket and binds it with
the given Port Number?
a. DatagramSocket(int port)
b. DatagramSocket(int port, InetAddress address)
c. DatagramSocket()
d. None of the above
12 Which class is used to create servers that listen for either local client or remote client programs?
a. ServerSockets
b. httpServer
c. httpResponse
d. None of the above
13 The DatagramSocket and DatagramPacket classes are not used for connection-less socket programming.
a. True
b. False
20 If one want to implement Socket at client side then which is the correct way to implement it?
(A) ServerSocket ss=new ServerSocket(port);
(B) Socket s=ss.accept();
(C) Socket s=new Socket("localhost",port);
21 URL contains…?
(A) Protocol
(B) IP Address
(C) Port Number
(D) All of these
22 InetAddress has a cache to store successful and unsuccessful host name resolutions.
(A) True
(B) False
23 DatagramSocket() throws
(A) IOException
(B) UnknownHostException
(C) ClassNotFoundException
(D) SocketException
27 Which of the following is NOT true about User Datagram Protocol in transport layer?
(A) Works well in unidirectional communication, suitable for broadcast information.
(B) It does three way handshake before sending datagrams.
(C) It provides datagrams, suitable for modeling other protocols such as in IP tunneling or Remote
Procedure Call and the Network File System.
(D) The lack of retransmission delays makes it suitable for real-time applications.
28 The transport layer protocols used for real time multimedia, file transfer, DNS and email, respectively
are:
(A) TCP, UDP, UDP and TCP
(B) UDP, TCP, TCP and UDP
(C) UDP, TCP, UDP and TCP
(D) TCP, UDP, TCP and UDP
33 In InetAddress class which method it returns the host name of the IP Address?
A) public String getHostName()
B) public String getHostAddress()
C) public static InetAddress getLocalHost()
D) None of the above
34 Which method of URL class represents a URL and has complete set of methods to manipulate
URL in Java?
A) java.net.URL
B) java.net.URLConnection
C) Both A & B
D) None of the above
46 What are the exceptions which have to be handled in a RMI client program?
a. RemoteException
b. NotBoundException
c. MalFormedURLException
d. All mentioned above
49 Which program obtains a remote reference to one or more remote objects on a server and then invokes
methods on them in an RMI application?
a. Server
b. Client
c. Both A & B
d. None of the above
50 Which objects are used by RMI for communicating with the remote object?
a. Stub
b. Skeleton
c. Both A & B
d. None of the above
53 RMI uses which protocol on top of TCP/IP (an analogy is HTTP over TCP/IP)?
a. Java Remote Method Protocol (JRMP)
b. Internet Inter-ORB Protocol (IIOP)
c. Jinni Extensible Remote Invocation (JERI)
d. All mentioned above
55 In RMI which layer defines and supports the invocation semantics of the RMI connection
and this layer maintains the session during the method call?
a. The Stub & Skeleton Layer
b. The Application Layer
c. The Remote Reference Layer
d. The Transport Layer