Adv Java | Unit 2 Networking | Multiple Choice Questions With Answer

 









 

SUBJECT CODE: 602 SUBJECT NAME: ADVANCED JAVA

 

Unit 2 : Networking

   


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

A) Java.io

B) Java.util

C) Java.net

D) Java.network

Answer:C

 

 

 

 

 

 

 

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

Answer:A

 

 

 

 

 

 

 

3. Which class is used to create servers that listen for either local client orremote

client program?

A) ServerSockets

B) httpserver

C) httpResponse

D) none

Answer:A

 

 

 

 

 

 

 

4. Which methods are commonly used in server socket class?

A) public outputstream getOutputstream()

B) public socket accept()

C) public synchronized void close()

D) none

Answer:B

 

 

 

 

 

 

 

5. Which method of URL class represent a URL and it has complete set ofmethods

to manipulate URL in java?

A) Java.net.URL

B) Java.net.URLConnection

C) both A and B

D) none

Answer:A

 

 

 

 

 

 

 

 

6. Which package provides core functionality?

A) javanet

B) java.rmi

C) java.lang

D) java.math

Answer:C

 

 

 

 

 

 

 

    

7. The URLConnection class can be used to read and write data to specified

resource referred by the URL.

A) true

B) false

Answer:A

 

 

 

 

 

 

 

 

 

8. Datagram is basically an information but there is no guarantee ofits

content,arrival or arrival time.

A) true

B) false

Answer:A

 

 

 

 

 

 

 

 

9. What does the javA)net.InetAddress class represent?

A) Socket

B) IP address

C) Protocol

D) MAC address

Answer:B

 

 

 

 

 

 

 

 

10. The flush() method of printStream class flushes any uncleared buffersin

memory?

A) true

B) false

Answer:A

 

 

 

 

 

 

    

 

 

11) TCP,FTP,Telnet,SMTP are example of?

A) Socket

B) IP address

C) Protocol

D) MAC address

Answer:C

 

 

 

 

 

 

 

 

 

 

12) In Inetaddress class which method returns the host name of IP address?

A) public String getHostName()

B) public String getHostAddress()

C) public String InetAddress getLocalHost()

D) none

Answer:A

 

 

 

 

 

 

 

13) Show some networking terminology given below?

A) All

B) IP address

C) Protocol

D) MAC address

Answer:A

 

 

 

 

 

 

 

 

 

14) URL is an acronym for?

A) Uniform Resource Locator

B) Unified resource location

C) Uniform restore Locator

D) unified restore locator

Answer:A

 

 

 

 

 

 

 

 

 

15) Which classes are used for connection less socket programming?

A) Datagram Socket

B) Datagram packet

C) Both a and b

D) none

Answer:C

 

 

 

 

 

 

 

 

 

16) how many ports TCP/IP are reserved for specific protocol?

A) 10

B) 1024

C) 2048

D) 512

Answer:B

 

 

 

 

 

 

 

17) how many bits are in a single IP address?

A) 8

B) 16

C) 32

D) 64

Answer:C

    

 

 

 

 

 

 

 

18) Which of these class is used to encapsulate IP address and DNS?

A) Datagram packet

B) URL

C) InetAddress

D) ContentHandler

Answer:C

 

 

 

 

 

 

 

19) Which of these is return type of getAddress method of DatagramPacket class?

A) findAddress()

B) getAddress()

C) Address()

D) Whois()

Answer:B

 

 

 

 

 

 

 

 

 

20) Which of these method of DatagramPacket is used to find port number?

A) port()

B) getPort()

C) findPort()

D) receivedPort()

Answer:A

 

 

 

 

 

 

 

21) Which of these class is necessary to implement datagrams?

    

A) DatagramPacket

B) DatagramSocket

C) All of the mentioned

D) None of the mentioned

Answer: C

 

 

 

 

 

 

 

22) Which of these method of DatagramPacket is used to find the port number?

A) port()

B) getPort()

C) findPort()

D) recievePort()

Answer: A

 

 

 

 

 

 

23) Which of these method of DatagramPacket is used to obtain the byte array of

data contained in a datagram?

A) getData()

B) getBytes()

C) getArray()

D) recieveBytes()

Answer: A

 

 

 

 

 

24) Which of these method of DatagramPacket is used to find the length of byte

array?

A) getnumber()

B) length()

C) Length()

D) getLength()

Answer: D

Explanation: getLength returns the length of the valid data contained in the byte

array that would be returned from the getData () methoD) This typically is not equal

to length of whole byte array.

 

 

25) Which of these class must be used to send a datatgram packets over a

connection?

    

A) InetAdress

B) DatagramPacket

C) DatagramSocket

D) All of the mentioned

Answer: D

Explanation: By using 5 classes we can send and receive data between client and

server, these are InetAddress, Socket, ServerSocket, DatagramSocket, and

DatagramPacket.

 

 

 

26) Which of these method is used to start a server thread?

A) run()

B) start()

C) runThread()

D) startThread()

Answer: A

Explanation: run() method is caleed when the server thread is starteD)

 

 

 

 

 

27) Which of these method is called when http daemon is acting like a normal web

server?

A) Handle()

B) HandleGet()

C) handleGet()

D) Handleget()

Answer: C

 

 

 

 

 

 

28) Which of these methods of httpd class is used to read data from the stream?

A) getDta()

B) GetResponse()

C) getStream()

D) getRawRequest()

Answer: D

Explanation: The getRawRequest() method reads data from a stream until it gets two

consecutive newline characters.

 

 

 

 

 

    

29) Which of these method of httpd class is used to get report on each hit to HTTP

server?

A) log()

B) logEntry()

C) logHttpd()

D) logResponse()

Answer: B

 

 

 

 

 

 

30) Which of these method is used to find a URL from the cache of httpd?

A) findfromCache()

B) findFromCache()

C) serveFromCache()

D) getFromCache()

Answer: C

Explanation: serveFromCatche() is a boolean method that attempts to find a

particular URL in the cache. If it is successful then the content of that cache entry are

written to the client, otherwise it returns false.

 

 

31) Which of these variables stores the number of hits that are successfully served

out of cache?

A) hits

B) hitstocache

C) hits_to_cache

D) hits.to.cache

Answer: D

 

 

 

 

 

 

 

 

32) Which of these class is used for operating on request from the client to the

server?

A) http

B) httpDecoder

C) httpConnection

D) httpd

    

Answer: D

 

 

 

 

 

 

33) Which of these method of httpd class is used to write UrlCacheEntry object into

local disk?

A) writeDiskCache()

B) writetoDisk()

C) writeCache()

D) writeDiskEntry()

Answer: A

Explanation: The writeDiskCache() method takes an UrlCacheEntry object and

writes it persistently into the local disk. It constructs directory names out of URL,

making sure to replace the slash(/) characters with system dependent seperatorChar.

34) Which of these is an instance variable of class httpd?

A) port

B) cache

C) log

D) All of the mentioned

Answer: D

Explanation: There are 5 instance variables : port, docRoot, log, cache and stopFlag.

All of them are private.

 

 

 

 

 

 

35) Which of these is an instance variable of httpd that is a Hashtable?

A) port

B) cache

C) log

D) stopFlag

Answer: C

Explanation: Cache is the Hashtable where all of the files are cached in RAM and is

initialized when the object is created.

 

 

 

 

36) What does URL stands for?

A) Uniform Resource Locator

B) Uniform Resource Latch

C) Universal Resource Locator

D) Universal Resource Latch

Answer: A

Explanation: URL is Uniform Resource Locator.

 

 

 

 

 

 

37) Which of these exception is thrown by URL class’s constructors?

A) URLNotFound

B) URLSourceNotFound

C) MalformedURLException

D) URLNotFoundException

Answer: C

 

 

 

 

 

 

 

38) Which of these methods is used to know host of an URL?

A) host()

B) getHost()

C) GetHost()

D) gethost()

Answer: B

 

 

 

 

 

 

 

39) Which of these methods is used to know the full URL of an URL object?

A) fullHost()

B) getHost()

C) ExternalForm()

D) toExternalForm()

Answer: D

 

 

 

 

 

 

 

 

40) Which of these class is used to access actual bits or content information of a

URL?

A) URL

B) URLDecoder

C) URLConnection

D) All of the mentioned

Answer: D

 




Post a Comment

0 Comments