100% found this document useful (1 vote)
1K views

Java MCQS

This document contains 56 multiple choice questions about networking and Java networking concepts like sockets, TCP/IP, UDP, RMI, and related classes. The questions cover topics such as network layers and protocols, socket programming in Java using classes like ServerSocket, Socket, DatagramSocket, InetAddress, and URL, as well as concepts related to remote method invocation (RMI) in Java like stubs, skeletons, and the RMI registry.

Uploaded by

szar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views

Java MCQS

This document contains 56 multiple choice questions about networking and Java networking concepts like sockets, TCP/IP, UDP, RMI, and related classes. The questions cover topics such as network layers and protocols, socket programming in Java using classes like ServerSocket, Socket, DatagramSocket, InetAddress, and URL, as well as concepts related to remote method invocation (RMI) in Java like stubs, skeletons, and the RMI registry.

Uploaded by

szar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1. Which of these package contains classes and interfaces for networking?

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

10 Which methods are commonly used in ServerSocket class?- P


a. public OutputStream getOutputStream()
b. public Socket accept()
c. public synchronized void close()
d. None of the above

11 Which classes are used for connection-less socket programming?


a. DatagramSocket
b. DatagramPacket
c. Both A & B
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

14 Which method of URL class returns the object of URLConnection class?


(a) getLocalHost()
(b) openConnection()
(c) getByName(String host)
(d) getHostAddress()

15 A Socket Consists Of?


(a) Port+IP address
(b) Only IP address
(c) only Port address
(d) None of these

16 Which method is establish a connection between server and client?


(a) accept()
(b) open()
(c) getLocalHost()
(d) openConnection()

17 Which Protocol is generally used for multicast? TCP or UDP?


(a) TCP
(b) UDP
(c) A & B both
(d) None of these

18 How to get list of IP address that are assigned to a network interface?


(A) getInetAddresses()
(B) getInterfaceAddresses()
(C) A & B both
(D) None of these
19 Which is not true for socket.
(A) Socket connection means the two machines have information about each other’s network location
and port.
(B) Socket supports only TCP protocol due to its reliability feature.
(C) To connect to other machine we need a socket connection.
(D) Socket programming is used for communication between the applications running on different JRE.

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);

(D) Socket s=ss.accept(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

24 UnknownHostException is immediate child class of_______?


(A) java.lang.Exception
(B) java.lang.IOException
(C) java.lang.Throwable
(D) java.lang.Object

25 Port numbers range from _____ to ______.


(A) 0 to 65535
(B) 1 to 65536
(C) -65535 to 65536
(D) 0 to 1024

26 _________ Protocol is more efficient in terms of both latency and bandwidth.


(A) TCP
(B) UDP
(C) SMTP
(D) FTP

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

29 Show some networking terminologies given below?


A) IP Address
B) Protocol
C) MAC Address
D) All mentioned above

30 TCP,FTP,Telnet,SMTP,POP etc. are examples of ?


A) Socket
B) IP Address
C) Protocol
D) MAC Address
31 Which class can be used to create a server socket. This object is used to establish communication
with the clients?
A) ServerSocket
B) Socket
C) Both A & B
D) None of the above
32 The java.net.InetAddress class represents an?
A) Socket
B) IP Address
C) Protocol
D) MAC Address

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

35 Which package provides core functionality?


A) java.net
B) java.rmi
C) java.lang
D) java.math

36 The client in socket programming must know which information’s?


A) IPaddress of Server
B) Port number
C) Both A & B
D) None of the above
37 One of the following the java.net Net Address class represents.
A. Socket
B. Protocol
C. IP Address
D. MAC Address
E. All of these

38 TCP groups a number of bytes together______in a packets.


A. user datagram
B. datagram
C. segment
D. packet
E. None of these
39 _______is the Machine that places the request to access the data
A. Client Machine
B. Server Machine
C. Request Machine
D. None of these
40 ______is the default port of SMTP.
A. 25
B. 70
C. 80
D. 85
E. None of these

41 one of the following applications of the Client and Server Model


A. Email
B. Network Printing
C. World Wide Web
D. All of these

42 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
43 Java supports RMI, RMI Stands for?
a. Random Method Invocation
b. Remote Memory Interface
c. Remote Method Invocation
d. Random Method Invocation
44 An RMI Server is responsible for _______
a. Creating an instance of the remote object
b. Exporting the remote object
c. Binding the instance of the remote object to the RMI registry
d. All mentioned above

45 In RMI, the objects are passed by _____.


a. Value
b. Reference
c. Value and Reference
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

47 RMI is a server-side component; It is not required to be deployed on the server.


a. True
b. False

48 Which package is used for Remote Method Invocation (RMI)?


a. java.lang.rmi
b. java.lang.reflect
c. java.applet
d. java.rmi

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

51 RMI Architecture consists of how many layers?


a. 5
b. 3
c. 4
d. 2

52 1099 is the default port used by RMI Registry.


a. True
b. False

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

54 What is the built on top of the socket programming?


a. EJB
b. RMI
c. Both A & B
d. None of the 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

56 RMI allows an object to invoke methods on an object running in another JVM


a. True
b. False

You might also like