AJP 4 chapter
AJP 4 chapter
to inspect the properties of the remote object before actually transporting it locally.
a)URL
b)URLConnection
c)URL.Connection
d)None of these
3) The _____ class is used to encapsulate both the numerical IP address and the
domain name for that address.
a)IPAddress
b)MACAddress
c) InetAddress
d)None of the above
8) To create an InetAddress object you have to use one of the available _____
a)Interfaces
b)Classes
c)Factory Methods
d)All of the above
9) Which of the following is a correct factory method to create an object in an
InetAddress?
a)getLocalHost()
b)getByName(String hostName)
c)getAllByName(String hostName)
d)All of the above
10) The _____ method returns the InetAddress object that represents the local host.
a)getByName(String hostName)
b)getLocalHost()
c)getAllByName(String hostName)
d)None of the above
11) The _______ method returns an InetAddress for a host name passed to it.
a)getByName(String hostName)
b)getLocalHost()
c)getAllByName(String hostName)
d)None of the above
12) The _______ factory method returns an array of InetAddresses that represent all
of the addresses that a particular name resolves to.
a)getByName(String hostName)b)getLocalHost()
c)getAllByName(String hostName)
d)None of the above
13) The factory method ______ which takes an IP address and returns an InetAddress
object.
a)getByName(String hostName)
b)getLocalHost()
c)getAllByName(String hostName)
d)getByAddress()
14) Which of the following Instance Method returns true if this object has the same
Internet address as other?
a)boolean isMulticastAddress()
b)boolean equals(Object other)
c)String toString()
d)byte[] getAddress()
15) Which of the following Instance Method returns a byte array that represents the
object’s Internet address in network byte order?
a)byte[] getAddress()
b)String getHostName()
c)String toString()
d)boolean isMulticastAddress()
16) Which of the following Instance Method returns a string that represents the host
address associated with the InetAddress object?
a)String toString()
b)boolean equals(Object other)
c)String getHostAddress()
d)None of the above
17) Which of the following Instance Method returns a string that represents the host
name associated with the InetAddress object?
a)String getHostAddress()
b)String getByName()
c)String getHostName()
d)String toString()
18) Which of the folowing Instance Method Returns true if this Internet address is a
multicast address. Otherwise, it returns false?
a)boolean equals(Object other)
b)boolean isMulticastAddress()
c)boolean isMultiCastAddress()
d)boolean MulticastAddress()
19) Which of the following Instance Method returns a string that lists the host name
and the IP address for convenience?
a)String getHostAddress()
b)String getByName()
c)String getHostName()
d)String toString()
20) ______ sockets are used to implement reliable, bidirectional, persistent, point-to
point, stream-based connections between hosts on the Internet.
a)TCP/IP
b)UDP
c)Proxy
d)None of the above
21) _____ can be used to connect Java’s I/O system to other programs that may reside
either on the local machine or on any other machine on the Internet.
a)Server
b)Client
c)Socket
d)All of the above
22) Which class is designed to be a “listener,” which waits for clients to connect
before doing anything?
a)Socket
b)Server
C)Both a & b
d)ServerSocket
23) Which are the two constructors used to create client sockets?
a)Socket(String hostName) ,Socket(InetAddress ipAddress, int port)
b)Socket(String hostName, int port) ,Socket(InetAddress ipAddress)
c)Socket(String hostName, int port), Socket(InetAddress ipAddress, int
port)
d)None of the above
24) By using following methods a socket can be examined at any time for the address
and port information associated with it.
a)InetAddress getInetAddress( )
b)int getPort( )
c)int getLocalPort( )
d)All of the above
25) Which of the following method returns the InetAddress associated with the
Socket object?
a)InetAddress getInetAddress( )b)int getPort( )
c)int getLocalPort( )
d)All of the above
26) Which of the following method returns the remote port to which this Socket
object is connected?
a)InetAddress getInetAddress( )
b)int getPort( )
c)int getLocalPort( )
d)All of the above
27) Which of the following method returns the local port to which this Socket object
is connected?
a)InetAddress getInetAddress( )
b)int getPort( )
c)int getLocalPort( )
d)All of the above
28) Which exception is thrown by the factory methods getLocalHost() & getByName()
when they are unable to resolve the host name?
a)UnknownHostException
b)IOException
c)Both 1 & 2
d)None of the above
31) Which method returns the OutputStream associated with the invoking socket?
a)InputStream getInputStream( )
b)OutputStream getOutputStream( )
c)Both 1 & 2
d)None of the above
35) _______ method Creates a socket connecting the local host to the named host and
port.
a)Socket(String hostName, int port)
b)Socket(InetAddress ipAddress, int port)
c)Both 1 & 2
d)None of the above
36) ______ method Creates a socket using a preexisting InetAddress object and a
port.
a)Socket(String hostName, int port)
b)Socket(InetAddress ipAddress, int port)
c)Both 1 & 2
d)None of the above
40) DatagramSocket is
a)used to send or receive the DatagramPackets.
b)serialized, predictable, reliable stream of packet data.
c)information passed between machines.
d)none of the above
45) Which method returns the destination InetAddress, typically used for sending.
a)int getPort( )
b)int getLength( )
c)InetAddress getAddress( )
d)byte[ ] getData( )
47) When the datagram is received, there is no assurance that it hasn’t been damaged
in trasmissin
a)TRUE
b)FALSE
48) Calling ServerSocket() constructor with port value 'zero' means _____________.
a)use a port number that is automatically allocated.
b)use a local port
c)use server port
d)None of above
49) Which of these package contains classes and interfaces for networking?
a)java.util.*
b)java.networking.*
c)java.net.*
d)java.awt.*
57) Name the class which is used to create a port where the server will listen?
a)DatagramPacket
b)ServerSocket
c)Socket
d)URL
62) The factory method which returns an array of InetAddresses that represent all of
the addresses that a particular host name resolves to.
a)getAllByName( )
b)getByName()
c)getLocalHost( )
d)getHostName( )
64) URL class has several constructors; each can throw a _____________________.
a)MalformedURLException
b)IOException
c)URLException
d)SocketException
69) What is the return type of the method getAllByName( ) of InetAddress class?
a)byte[]
b)String
c)void
d)InetAddress[ ]
72) Which method of ServerSocket will wait for a client to initiate communications
and then communicate with the client
a)initialize()
b)start()
c)socket()
d)accept()
75) which of these method of DatagramPacket is used to find the length of byte
Array
a)getLength()
b)getlength()
c)getTotalLength()
d)getSize()
76) Which of these method of DatagramPacket is used to find the port number?
a)getPortNumber()
b)getport()
c)getPort()
d)getportNumber()