Chapter 4 Networking Basics PDF

Summary

This document appears to be a set of networking questions, possibly from a past paper. The questions are focused on the concepts of networking basics using Java. The keywords indicate that the document discusses programming aspects of networking.

Full Transcript

Chapter 4 Networking Basics Each Question carries l Marks Q1. getLocalHost() method simply returns the InetAddress object which represents A) host name B) machine name C) local host D) remote host Q2. The getByName() method retu...

Chapter 4 Networking Basics Each Question carries l Marks Q1. getLocalHost() method simply returns the InetAddress object which represents A) host name B) machine name C) local host D) remote host Q2. The getByName() method returns an with host name A) IP address B) InetAddress Object C) port number D) IPv4 Q3. getAllByName() method returns an array of that represents all of the addressesthat specific host name has A) host names B) InetAddresses C) ipaddresses D) objects Q4. InetAddress also Includes a factory method called A) getByAddress() B) getHostName() C) getAddress() D) getIPAddress() Q5. what is the output of following program import java.net.*; class Demo { public static void main(String arg[]) { InetAddress ip=InetAddress.getByName("www.google.com"); System.out.println(ip) } A) www.google.com/217.56.216.195 B) www.google.com C) 217.56.216.195 D) All of the above Q6. What is the role of getAddress() method ? A) returns Ip address of network. B) Returns a byte array that represents the object's Ip address in the network byte order. C) Returns an array of object's that represents Ip address. D) Returns the a byte array of Ip address of network host machine. Q7. Type of server in two-tier architectures which provides data to client stored on disk pages iscalled A) transaction server B) functional server C) disk server D) data server Q8. Which method does return true value if specified address is a multicast address ? A) isMulticastHostName() B) isMulticastHostAddress() C) isMulticastAddress() D) isMulticastIPAddress() Q9. InetAddress has two subclasses called as: A) IPV4Address() and IPV6Address() B) IP4VAddress() and IP6VAddress() C) Inet4Address() andInet6Address() D) InetAddress4() and InetAddress6() Q10. What is output of following code? import java.net.*; class Inet{ public static void main(String arg[]) { InetAddress ip=InetAddress.getLocalHost(); System.out.println(ip.getHostAddress(); } } A) 192.168.0.100 B) localhost/192.168.0.100 C) localhost machine D) localhost//8080: Q11. InetAddress class is used to encapsulate both numerical IP address and the A) port number B) host name C) server name D) socket name Q12. You can simply use InetAddress class when working with IP address because it can accommodate both styles. A) IP4V and IP6V B) IPV4 and IPV6 C) host name and IP D) A and B Q13. What does getHostAddress() of InetAddress class terurn? A) Returns host address with ipaddress. B) Returns a string that represents ipaddresses with hostname. C) Returns a string that represents a host address associated with the Inetaddress object. D) Returns astring that represents a host name associated with Inetaddress object. Q14. getHostName() of InetAddress class is used to A) Return a string that represents host name associated with Inetaddress object. B) Return a string that represents host address associated with Inetaddress object. C) Return an object that represents Ipaddress associated with host name. D) Return Ipaddress that is associated with InetAddress object. Q15. Which of the following statement is correct ? A) There are two kinds of sockets in java one is for server and other for clients. B) There is only one socketfor server. C) There is only one socket for client. D) There is only one socket for server as well as for client. Q16. Which of the following class is used to create server that listen for clients ? A) httpserver B) ServerSocket C) DatagramSocket D) Socket Q17. What happens if server socket is not able to listen on specified port ? A) The system exits gracefully with appropriate message B) The system will wait till port is free. C) IoExeption is thrown when opening the socket D) PortOccupiedException is thrown. Q18. Which exception will be thrown if client socket does not specify the hostname when it has created? A) IOException B) UnknownHostException C) UnknownHostNameException D) UnknownPortException Q19. Which constructor will you use to create client socket using a preexsiting InetAddress object anda port ? A) Socket (String hostname, int port ) B) Socket (Inetaddress ipAdd, int port ) C) Socket (Inetaddress ipAdd, string Hostname) D) Socket ( int port, Inetaddress ipAdd ) Q20. method returns the local part to which the invoking socket object is bound. A) int getLocalHost() B) int getLocalPort() C) int getPort() D) int GetLocalHost() Q21. Which of the following are factory methods of InetAddress class? A) static InetAddress[] getAllByName(String hostname) B) static InetAddres getLocalHost() C) stringgetHostName() D) A and B Q22. Which of the following methods belong to ServerSocket class A) accept() B) connect() C) bind() D) A and C Q23. ServerSocket class has one of the following constructor A) ServerSocket(int port) B) ServerSocket(String host, int port) C) ServerSocket(int port, InetAddress add) D) ServerSocket(InetAddress add, int port) Q24. Socket method called returns the port number that socket is bound to on local machine A) int getLocalPortt() B) int getPort() C) InetAddress getInetAddress() D) string getHostAddress() Q25. What are different factory methods of InetAddress class? A) getByName() B) GetLocalHost() C) getByAddress() D) both A & C Q26. How long is an IPv6 address? A) 32 bits B) 128 bytes C) 64 bits D) 128 bits Q27. method is needed only when you instantiate the socket using the not argument constructer. A) bind() B) connect() C) accept() D) SetHostName() Q28. InetAddress class having method which returns a string that shows the host name and IP address. A) toString() B) getHostAddress() C) getLocalHost() D) none of the above Q29. If server socket is created using serversocket () constructer then which method should we use tobind the serve socket ? A) isbind() B) bind() C) bind To() D) bind ( socketAddress host , int backlog) Q30. accept method is used for ______________ A) Incoming Client connection B) Incoming Server socket C) Accepting request from server D) Waitingsocket Q31. Class represents the socket that both the client & server use to communicate with each other A) java.net.Serversocket B) java.net.Server C) Java.net.socket D) java.net.Clientsocket Q32. Socket s1= Socket ( localhost, 1346), What does it means ? A) Client socket is waiting for connection B) Client socket is created to connect with specified host name and port number C) Client socket is name as localhost and Port number is 1346 D) server socket is connected to local host with port number 1346 Q33. What is the output of following statements Socket s1=new Socket("localhost",1234); inta=s1.getPort(); System.out.println(a); A) localhost B) localhost/1234 C) 1234 D) 1234/localhost Q34. Correct way of using ServerSocket is A) ServerSocket(int port) B) ServerSocket(int port,int maxQueue) C) ServerSocket(int port,intmaxQueue,InetAddress localAddress) D) All of the above Q35. What is the output of following statements? ServerSocket ss=new ServerSocket(1349); Sockets1=ss.accept(); System.out.println(ss.getLocalPort()); A) port number of client socket B) 1349 C) local port D) None of the above Q36. public InputStream getInputStream() is method of class A) Serversocket B) ClientSocket C) Socket D) All of the above Q37. getOutputStream() returns the output stream of the A) Socket B) ServerSocket C) ClientSocket D) None of the above Q38. Which of the following statement is correct? A) The input stream of socket is connected to the output stream of remote socket B) The output stream ofsocket is connected to the input stream of remote socket C) The output stream of socket is connected to the output stream of remote socket D) A and B Q39. method makes socket object no longer capable of connecting again to any server A) send() B) wait() C) connect() D) close() Q40. If your application has successfully bound to specified port and is ready for client requestthen A) an exception is thrown B) an IOException is thrown C) it does not throw an exception D)UnknownHostException is thrown Q41. Socket is the combination of __________and _____________ A) IP address and port number B) port number and local host C) IPAddress and machine number D) Allof the above Q42. Which steps occur when establishing a TCP connection between two computers using socket? A) The server initiates a ServerSocket object denoting port number to be connected B) The server invokesthe accept() method of ServerSocket class. This method waits until a client connects to the server on the given port C) After the server is waiting, a client instantiates a socket object with specified server name and port number D) All of the above Q43. What is the output of the following statement? ServerSocket ss=new ServerSocket(1234); Sockets1=ss.accept(); System.out.println(s1.getPort()); A) port number of client socket B) 1234 C) local port D) All of the above Q44. What is the output of following statement? ServerSocket ss=new ServerSocket(1234); Sockets1=ss.accept(); System.out.println(s1.getRemoteSocketAddress()); A) 1234 B) iPAddress of serversocket C) IPAddress of client with port number D) IPAddress of serverwith port number Q45. What is the output of following statement? Socket s1=new Socket("localhost",1234); System.out.println(s1.getRemoteSocketAddress()); A) IPAddress of client with port number B) host name, IPAddress and port number of Serversocket C) host name and IPAddress Serversocket D) IPAddress of server with port number Q46. Connection timed out exception is occurred A) if client socket is not created B) if serversocket does not accept client request C) if port number is notavailable which is specified by client socket with host name D) None of the above Q47. Which method is used to expose the details of establishing connection between server socket &client socket ? A) connect() B) receive() C) there is no such method D) None of the above Q48. You can gain access to the input and output streams associated with socket by use getInputStream() A) getOutStream() B) setOutputStream() C) getOutputStream() D) getOutputClass() Q49. Which exception will occur when port is already bound with an application and other application isrequesting for same port? A) IOException B) PortNotFoundException C) UnknownPortNameException D) ConectException Q50. When you will use this ServerSocket(int port, int que) constructor to create server socket A) to create ServerSocket with port number B) to create ServerSocket with port number & Ip address C)to create ServerSocket with port number and number of incoming client queue D) B & C Q51. Socket(InetAddress host, int port) in this constructor, what does first parameter stands for ? A) host name B) host name and IPAddress specified by InetAddress object C) IpAddress of host D) ipaddress and port number Q52. Which constructor will you use to connect to specified host and port by creating a socket on thelocal host at specified address & port A) Socket() B) Socket(String host, int port) C) Socket (Inetaddress ipAdd,int port) D) Socket ( String host,int port, Inetaddress ipAdd, int localport ) Q53. Which of the following class is used to create client socket A) httpserver B) Datagram Socket C) Socket D) ClientSocket Q54. What will be the output of following statements Socket s1=Socket("localhost",1349); System.out.println(s1.getLocalPort()); A) 1349 B) port number of local machine C) local host D) localhost/1349 Q55. Which of the following are Instance method of InetAddress Class A) byte[] getAddress() B) string getHostName() C) A and B D) static InetAddress getByName(string hostname) Q56. Which constructor of DatagramSocket class is used to create a datagram socket and binds it withthe given port number? A) DatagramSocket(int port) B) DatagramSoclet(int port InetAddress add) C) DatagramSoclet() D)None of the above Q57. Which class is used for connection-less socket programming ? A) DatagramSoclet B) DatagramServer C) A and B D) None of the above Q58. Which exception will occur if specified port number is not available for DatagramSoclet? A) UnknownException B) SocketException C) UnknownSocketException D) UnknownPortException Q59. ) Which of the following constructor is used to create datagram socket with port number and hostaddress A) DatagramSoclet(int port) B) DatagramSocket(int port InetAddress add) C) DatagramSoclet() D) A & B Q60. Which constructor will you use to send packet? A) DatagramPacket(byte[] bar, int len) B) DatagramPacket(byte[] bar, int len, int port) C) DatagramPacket(string s1, int len, InetAddress, int port) D) All of the above Q61. Java DatagramSocket and DatagramPacket classes are used for socket programming A) Connection-oriented B) Connection-less C) A & B D) Reliable Q62. Datagram Packet is a message than can be used for messages A) Connection-oriented or connection less B) send and store C) send and receive D) receive and read Q63. Which constructors are used to receive data from packet? A) DatagramPacket(byte[] bar, int len) B) DatagramPacket(byte[] bar, int off, int len) C) DatagramPacket(string s1, int len, InetAddress, int port) D) A and B Q64. getData() & getLenght() are the methods of class A) DatagramSoclet B) ServerSocket C) DatagramPacket D) ClientSocket Q65. What is the output of following code? DatagramPacket dp =new DatagramPacket(byte[] data,1024); System.out.println(dp.getLength()); A) 1024 B) data, 1024 C) 1024, data D) Null Q66. Which of the below are common network protocols? A) TCP B) UDP C) TCP and UDP D) FTP Q67. Which of these package contains classes and interfaces for networking? A) java.io B) java.util C) java.net D) java.network Q68. 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 Q69. How many ports of TCP/IP are reserved for specific protocols? A) 10 B) 1024 C) 2048 D) 512 Q70. How many bits are in a single IP address? A) 8 B) 16 C) 32 D) 64 Q71. How many bits value does IPv4 and IPv6 uses to represent the address? A) 32 and 64 B) 64 and 128 C) 32 and 128 D). 64 and 64 Q72. TCP,FTP,Telnet,SMTP,POP etc. are examples of ? A) Socket B) IP Address C) Protocol D) MAC Address Q73. is a server that is mediator between real web server and client application. A) IBMServer B) SQLServer C) ReserverSockets D) Proxy server Q74. Port number 80 is reserved for A) FTP B) Telnet C) e-mail D) HTTP Q75. method is used to know the type of content used in the URL. A) ContentType() B) Contenttype() C) GetContentType() D) getContentType() Q76. Port number 25 is reserved for A) FTP B) Telnet C) SMTP D) HTTP Q77. User Datagram Protocol is A) Support fast transfer of packets B) support connection-less transport of packets C) support unreliable transport of packets D) All of the above Q78. The Transmission Control Protocol is A) Low level routing protocol B) Middle level routing protocol C) Higher level routing protocol D) None of above Q79. Internet Protocol is A) Low level routing protocol B) Middle level routing protocol C) Higher level routing protocol D) None of above Q80. ContentHandler , MulticastSocket , URL, SocketImpl are examples of -------- A) package B) class C) Interface D) Method Q81. What does URL stands for? A) Uniform Resource Locator B) Uniform Resource Latch C) Universal Resource Locator D) UniversalResource Latch Q82. Which of these exceptions is thrown by URL classes constructors? A) URLNotFound B) URLSourceNotFound C) MalformedURLException D) URLNotFoundException Q83. Which of these methods is used to know host of an URL? A) host() B) getHost() C) GetHost() D) gethost() Q84. 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 Q85. What is the output of this program? import java.net.*; class networking { public static voidmain(String[] args) throws MalformedURLException { URL obj = new URL("https://www.sanfoundry.com/javamcq"); System.out.print(obj.getProtocol()); } } A) http B) https C) www D) com Q86. Which of these methods is used to know the full URL of an URL object? A) fullHost() B) getHost() C) ExternalForm() D) toExternalForm() Q87..com,.gov,.org are examples of-------- A) domain B) server name C) client name D) package Q88. Which of these methods is used to know when was the URL last modified? A) LastModified() B) getLastModified() C) GetLastModified() D) getlastModified()() Q89. What is the output of this program? import java.net.*; class networking { public static voidmain(String[] args) throws Exception { URL obj = new URL("https://www.sanfoundry.com/javamcq"); URLConnection obj1 = obj.openConnection(); System.out.print(obj1.getContentType()); } } A) html B) text C) html/text D) text/html Q90. ContentHandler , MulticastSocket , URL, SocketImpl are included in package A).net B).util C). io D).lang Q91. types of exceptions are occurred in networking programming A) UnknownHostException B) MalformedURLExeption C) Exception D) All of the above Q92. Datagrams are ________ of information passed between machines A) bundles B) sets C) none of A and B D) Both A and B Q93. TCP/IP style of networking provides ------------------ A) serialized stream of packet data B) predictable stream of data C) reliable stream of data D) All of theabove Q94. _______ constructor specifies only a buffer that will receive data and the size of packet. A) DatagramPacket(byte data[], int size) B) DatagramPacket(byte data[], int offset, int size) C) DatagramPacket(byte data[], int offset, int size , InetAddress ipAddress, int port) D) All of the above Q95. DatagramPacket has _____________ methods A) int getPort() B) byte[] getData() C) int getLength() D) All of the above Q96. What is the output of this program? import java.net.*; class networking { public static voidmain(String[] args) throws MalformedURLException { URL obj = new URL("http://www.sanfoundry.com/javamcq"); System.out.print(obj.getPort()); } } A) 1 B) 0 C) -1 D) garbage value Q97. Which steps occur when establishing a TCP connection between two computers using sockets? A) The server instantiates a ServerSocket object, denoting which port number communication is to occur on B) The server invokes the accept() method of the ServerSocket class. This method waits until a client connects to the server on the given port C) After the server is waiting, a client instantiates a Socket object,specifying the server name and port number to connect to D) All of the above Q98. Which of these transfer protocol must be used so that URL can be accessed by URLConnectionclass object? A) http B) https C) Any Protocol can be used D) None of the mentioned Q99. The class is used for accessing the attributes of remote resource. A) URI B) URLConnection C) URL D) URLLoader Q100. How many forms of constructors URL class have? A) 1 B) 2 C) 3 D) 4

Use Quizgecko on...
Browser
Browser