Monday, May 27, 2019

Chapter 3(MCQ:51-100)

DatagramPacket
DatagramPacket uses different constructors depending on whether thepacket will be used to send data or to receive data. This is a little unusual.
Normally, constructors are overloaded to let us provide different kinds of
information when we create an object, not to create objects of the same class
that will be used in different contexts. In this case, all constructors take as
arguments a byte array that holds the datagram's data and the number of
bytes in that array to use for the datagram's data. When we want to receive a
datagram, these are the only arguments we provide; in addition, the array
should be empty. When the socket receives a datagram from the network, it
stores the datagram's data in the DatagramPacket object's buffer array, up to
the length we specified.

51 The valid sequence for URL format is ___________________ = protocol, Hostname, portnumber, filepath

52The ____________method in the InetAddress class returns the IP
address.
= getHostAddress()

53 The ______________class is used to create TCP server. = ServerSocket

54 To create an InputStream on a Socket s, you use __________. = InputStream in = s.getInputStream();

55 To obtain an ObjectOutputStream from a socket,use__________ = new ObjectOutputStream(socket.getOutputStream())

56 To return an instance of InetAddress class you have to use = Factory Methods of InetAddress class

57To return the currently intalled policy object______________method is
used.

= public static Policy getPolicy()

58 UDP is not __________oriented protocol. = Connection

59 UDP Packets are known as ___________________ = Datagram

60 UDP Protocol uses following classes for communication = DatagramPacket and DatagramSocket

61 UDP Stands for ________ = User Datagram Protocol

62URL class has several constructors; each can throw _____________________.
= MalformedURLException

63 What does the openConnection() method of java.net.* return? = Object of URLConnection class

64 What does URL stands for? = Uniform Resource Locator

65 What is return type of getAddress() method of InetAddress class? = byte[]

66 What is Second part of URL address = Hostname

67 What is Socket? = All of these

68 What is the first part of URL address? = Protocol

69 What is the optional part of URL Address = Port Number

70What is the return type of the method getAllByName( ) of InetAddressclass?
= InetAddress[ ]


71 What will be displayed in the output? import java.net.*; class
myAddress { public static void main (String args[]) { try { InetAddress
address = InetAddress.getLocalHost(); System.out.println(address); }
catch (UnknownHostException e) { System.out.println("Could not find
= The internet address of the host
this computer's address."); } } }

72 When a socket object is created __________ =
It implicitly establishes a connection between the client &
server

73 When a URL object is created __________ = a connection is automatically established with that URL

74Which class defines following methods. 1. int getContent Length() 2.
long getDate() 3. long getExpiration()
= URLConnection

75Which class is used to access actual bits or content information of a
URL?
= URLConnection

76 Which class is used to create client in TCP/IP? = Socket
77Which class is used to designed to be a "listener" which waits for client
to connect before doing anything.
= ServerSocket

78 Which class is used to implement datagrams with UDP protocol. = DatagramSocket

79Which class of java.net package can be used to find the host name
and IP address of the client.
= The InetAddress class

80 Which classes are used for connection-oriented socket programming = Both A andB

81Which constructor of DatagramSocket class is used to create a
datagram socket and bind it with the given port number?
= DatagramSocket(int port)

82Which datagram method returns the byte array of data contained in
the datagram?= byte[] getData()

83Which exception indicate that the IP address of a host could not be
determined= UnknownHostException

84 Which is connection less protocol = UDP

85 Which is not a method of URL Connection? = Date getLastModified( )

86 Which is not valid method of URL class? = getUrl()

87 Which is the correct syntax from given? = byte[] getAd
dress()
88 Which is the reliable protocol of networking ? = TCP

89 Which method is used to know the full URL of an URL object? = toExternalForm()

90 Which method is used to retrieve the host name associated with URL = getHost()

91 Which method is used to return the IPAddress of local machine = static InetAddress getLocalHost( )

92Which method of ServerSocket will wait for a client to initiate
communications and then communicate with the client= accept()

93 Which method of URL class is used to create object of URLConnection? = openConnection

94 Which of the following are Factory Methods of InetAddress class = All the Above

95 Which of the following class defines accept() method? = ServerSocket

96 Which of the following constructor of InetAddress is generally used? = InetAddress class does not contain any visible constructor.

97 Which of the following is a connection oriented protocol? = TCP

98Which of the following is mediator between real web server and client
application = Proxy

99 Which of the following is not a constructor of DatagramSocket = DatagramSocket(InetAddress address)

100Which of the following is not a Factory method of an InetAddress
Class?= Sting getHostAddress()


No comments:

Post a Comment

java program (Tree)