Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Unit 3 Cwipedia

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Maharashtra State Board of Technical Education

(A utonomous) (ISO 9001:2008) (ISO/IEC 27001:2005)

Welcome M3001 [117.239.186.68]


My Home Log Out

e-Exam Manage Questions for Advanced Java Programming (17625) for topic 3 Go Back to Subjects

Q To Fig Q Mar
Question Answer Edit Delete
No pic ure Type ks

Calling ServerSocket() constructor with port value 'zero'


1 3 N U 1 use a port number that is automatically allocated. Edit Delete
means______________________.

2 TCP/IP reserves the ____________ ports for specific protocols 3 N R 1 lower 1024 Edit Delete

Which of these package contains classes and interfaces for


3 3 N R 1 java.net Edit Delete
networking?

4 A ServerSocket can connect to ________ clients. 3 N R 1 multiple Edit Delete

5 A set of rules that governs data communication. 3 N R 1 protocol Edit Delete

6 A socket identifies __________ in network. 3 N R 1 a communication end point Edit Delete

7 A socket is combination of 3 N R 1 Both A and B Edit Delete

A socket is __________________ of a two-way communication link


8 3 N R 1 one end-point Edit Delete
between two programs running on two hosts in the network.

9 Access control does not deals with 3 N R 1 Authenication Edit Delete

A_______ is responsible for determining whether code executing in


10 the Java runtime environment has permission to perform a security- 3 N R 1 policy object Edit Delete
sensitive operation.

byte[] getData() method of DatagramPacket class


11 3 N R 1 Byte array of data contained in datagram Edit Delete
returns______________________

Class URL represents __________________________________, a


12 3 N R 1 Uniform Resource Locator Edit Delete
pointer to a "resource" on the World Wide Web

13 Communication using TCP protocol is __________and _________ 3 N R 1 connection-oriented, concurrent Edit Delete

Connection oriented communication is possible using


14 3 N R 1 Socket and ServerSocket Edit Delete
___________________classes of Java.

15 How many bits are in a single IPv4 address? 3 N R 1 32 Edit Delete

16 How many bytes are required to represent an IPv4 address? 3 N R 1 4 Edit Delete

In InetAddress class which method returns the host name of the IP


17 3 N R 1 public String getHostName() Edit Delete
Address?

18 In the format for defining the URL what is the last part? 3 N R 1 File path Edit Delete
19 In the URL, http://www.osborne.com:80/index.htm, 80 represents 3 N R 1 Port number Edit Delete

20 In UDP send() and receive() methods belong to which class? 3 N R 1 DatagramSocket Edit Delete

21 In which class the constructors are not visible 3 N R 1 Inetaddress class Edit Delete

22 Inet Address class encapsulates__________________ 3 N R 1 Both A and B Edit Delete

23 IP Stands for ________ 3 N R 1 Internet Protocol Edit Delete

24 Java.net package include following classes. 3 N R 1 URLConnection, Socket, InetAddress Edit Delete

Name the class which is used to create a port where the server will
25 3 N R 1 ServerSocket Edit Delete
listen?

26 Permission class of java.security package is _______ class 3 N R 1 abstract Edit Delete

27 Permission class belongs to which package? 3 N R 1 java.security Edit Delete

28 Port Number for FTP is 3 N R 1 21 Edit Delete

29 Port number of Email is ____________. 3 N R 1 25 Edit Delete

30 Pretty Good Privacy (PGP) is used in security of 3 N R 1 Email Edit Delete

31 Reserved port no of HTTP 3 N R 1 80 Edit Delete

32 Resolver in DNS sysytem maps 3 N R 1 Domain name to ip address Edit Delete

33 Select the proper constructor of ServerSocket class 3 N R 1 All of above Edit Delete

34 Select the proper constructor of URL class 3 N R 1 All of the above Edit Delete

35 TCP is Which Type of Protocol ? 3 N R 1 Connection oriented protocol Edit Delete

36 TCP is _________oriented protocol 3 N R 1 stream Edit Delete

37 TCP Stands for ________ 3 N R 1 Transmission Control Protocol Edit Delete

38 TCP/IP sockets are used to impelement __________ connections. 3 N R 1 All of the above Edit Delete

The class which encapsulates both the numerical IP address and the
39 3 N R 1 InetAddress Edit Delete
domain name for that address.

The constructor which is used in ServerSocket may


40 3 N R 1 ServerSocket (int port). Edit Delete
be______________.

41 The constructor which is used to create client socket is ____________. 3 N R 1 Socket(InetAddress IPAddress, int port). Edit Delete

The factory method for retrieving objects of InetAddress is


42 3 N R 1 All of the mentioned Edit Delete
___________________.

The factory method which returns an array of InetAddresses that


43 3 N R 1 getAllByName( ) Edit Delete
represent all of the addresses that a particular host name resolves to.

The java.net.InetAddress class provides methods to get


44 3 N R 1 IP of any host name Edit Delete
the________________________

45 The method int getPort( ) of Socket class returns____________ 3 N R 1 remote port to which this Socket object is connected. Edit Delete

The number 80 in following URL specifies?


46 3 N R 1 Port number Edit Delete
http://www.rediff.com:80/index.htm/

47 The openConnection() is the method of which Class? 3 N R 1 URLConnection Edit Delete

The openConnection() method of URL class return


48 3 N R 1 URLConnection Edit Delete
_____________Object.

49 The return type of getHostAddress() method is_____________ 3 N R 1 string Edit Delete

The server listens for a connection request from a client using the
50 3 N R 1 Socket s = ServerSocket.accept() Edit Delete
following statement:

51 The valid sequence for URL format is ___________________ 3 N R 1 protocol, Hostname, portnumber, filepath Edit Delete

The ____________method in the InetAddress class returns the IP


52 3 N R 1 getHostAddress() Edit Delete
address.

53 The ______________class is used to create TCP server. 3 N R 1 ServerSocket Edit Delete

54 To create an InputStream on a Socket s, you use __________. 3 N R 1 InputStream in = s.getInputStream(); Edit Delete

55 To obtain an ObjectOutputStream from a socket,use__________ 3 N R 1 new ObjectOutputStream(socket.getOutputStream()) Edit Delete

56 To return an instance of InetAddress class you have to use 3 N R 1 Factory Methods of InetAddress class Edit Delete

To return the currently intalled policy object______________method is


57 3 N R 1 public static Policy getPolicy() Edit Delete
used.

58 UDP is not __________oriented protocol. 3 N R 1 Connection Edit Delete

59 UDP Packets are known as ___________________ 3 N R 1 Datagram Edit Delete

60 UDP Protocol uses following classes for communication 3 N R 1 DatagramPacket and DatagramSocket Edit Delete

61 UDP Stands for ________ 3 N R 1 User Datagram Protocol Edit Delete

URL class has several constructors; each can throw a


62 3 N R 1 MalformedURLException Edit Delete
_____________________.

63 What does the openConnection() method of java.net.* return? 3 N R 1 Object of URLConnection class Edit Delete

64 What does URL stands for? 3 N R 1 Uniform Resource Locator Edit Delete

65 What is return type of getAddress() method of InetAddress class? 3 N R 1 byte[] Edit Delete

66 What is Second part of URL address 3 N R 1 Hostname Edit Delete

67 What is Socket? 3 N R 1 All of these Edit Delete

68 What is the first part of URL address? 3 N R 1 Protocol Edit Delete

69 What is the optional part of URL Address 3 N R 1 Port Number Edit Delete

What is the return type of the method getAllByName( ) of InetAddress


70 3 N R 1 InetAddress[ ] Edit Delete
class?

What will be displayed in the output? import java.net.*; class


myAddress { public static void main (String args[]) { try { InetAddress
71 address = InetAddress.getLocalHost(); System.out.println(address); } 3 N R 1 The internet address of the host Edit Delete
catch (UnknownHostException e) { System.out.println("Could not find
this computer's address."); } } }

It implicitly establishes a connection between the client &


72 When a socket object is created __________ 3 N R 1 Edit Delete
server

73 When a URL object is created __________ 3 N R 1 a connection is automatically established with that URL Edit Delete

Which class defines following methods. 1. int getContent Length() 2.


74 3 N R 1 URLConnection Edit Delete
long getDate() 3. long getExpiration()

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


75 3 N R 1 URLConnection Edit Delete
URL?

76 Which class is used to create client in TCP/IP? 3 N R 1 Socket Edit Delete

Which class is used to designed to be a "listener" which waits for client


77 3 N R 1 ServerSocket Edit Delete
to connect before doing anything.

78 Which class is used to implement datagrams with UDP protocol. 3 N R 1 DatagramSocket Edit Delete

Which class of java.net package can be used to find the host name
79 3 N R 1 The InetAddress class Edit Delete
and IP address of the client.

80 Which classes are used for connection-oriented socket programming 3 N R 1 Both A and B Edit Delete

Which constructor of DatagramSocket class is used to create a


81 3 N R 1 DatagramSocket(int port) Edit Delete
datagram socket and bind it with the given port number?

Which datagram method returns the byte array of data contained in


82 3 N R 1 byte[] getData() Edit Delete
the datagram?

Which exception indicate that the IP address of a host could not be


83 3 N R 1 UnknownHostException Edit Delete
determined

84 Which is connection less protocol 3 N R 1 UDP Edit Delete

85 Which is not a method of URL Connection? 3 N R 1 Date getLastModified( ) Edit Delete

86 Which is not valid method of URL class? 3 N R 1 getUrl() Edit Delete

87 Which is the correct syntax from given? 3 N R 1 byte[] getAddress() Edit Delete

88 Which is the reliable protocol of networking ? 3 N R 1 TCP Edit Delete

89 Which method is used to know the full URL of an URL object? 3 N R 1 toExternalForm() Edit Delete

90 Which method is used to retrieve the host name associated with URL 3 N R 1 getHost() Edit Delete

91 Which method is used to return the IPAddress of local machine 3 N R 1 static InetAddress getLocalHost( ) Edit Delete

Which method of ServerSocket will wait for a client to initiate


92 3 N R 1 accept() Edit Delete
communications and then communicate with the client

93 Which method of URL class is used to create object of URLConnection? 3 N R 1 openConnection Edit Delete

94 Which of the following are Factory Methods of InetAddress class 3 N R 1 All the Above Edit Delete

95 Which of the following class defines accept() method? 3 N R 1 ServerSocket Edit Delete

96 Which of the following constructor of InetAddress is generally used? 3 N R 1 InetAddress class does not contain any visible constructor. Edit Delete
97 Which of the following is a connection oriented protocol? 3 N R 1 TCP Edit Delete

Which of the following is mediator between real web server and client
98 3 N R 1 Proxy Edit Delete
application

99 Which of the following is not a constructor of DatagramSocket 3 N R 1 DatagramSocket(InetAddress address) Edit Delete

Which of the following is not a Factory method of an InetAddress


100 3 N R 1 Sting getHostAddress() Edit Delete
Class?

Socket is not used to create connection between client and


101 Which of the following is not true about TCP Socket? 3 N R 1 Edit Delete
server

102 Which of the following is true about UDP? 3 N R 1 No retransmission of lost packets. Edit Delete

103 Which of the following is true for TCP ? 3 N R 1 TCP is realiable and connection oriented Edit Delete

104 Which of the following is true for UDP ? 3 N R 1 UDP is unrealiable and connection less Edit Delete

Which of the following method is used to obtain remote port to which


105 3 N R 1 getPort() Edit Delete
Socket object is connected.

Which of the following methods of InetAddress class returs the IP


106 3 N R 1 getHostAddress() Edit Delete
Address?

107 Which of the ServerSocket method listen client request for connection? 3 N R 1 accept() Edit Delete

108 Which of these class is necessary to implement datagrams? 3 N R 1 Both of these Edit Delete

Which of these class is used to create servers that listen for either
109 3 N R 1 ServerSockets Edit Delete
local or remote client programs?

110 Which of these class is used to encapsulate IP address and DNS? 3 N R 1 InetAddress Edit Delete

which of these class must be used to send a datagram packets over a


111 3 N R 1 All of the mentioned Edit Delete
connection?

112 Which of these is a bundle of information passed between machines? 3 N R 1 Datagram Edit Delete

113 Which of these is a factory methods 3 N R 1 getLocalHost() Edit Delete

114 Which of these is a not a factory method of InetAddress class? 3 N R 1 static InetAddress getAllName(String hostName) Edit Delete

Which of these is a protocol for breaking and sending packets to an


115 3 N R 1 TCP/IP Edit Delete
address across a network?

Which of these is a return type of getAddress method of


116 3 N R 1 InetAddress Edit Delete
DatagramPacket class?

Which of these is a return type of getData() method of


117 3 N R 1 byte Edit Delete
DatagramPacket class

118 Which of these method does not belongs to DatagramPacket class 3 N R 1 getAddress() Edit Delete

which of these method of DatagramPacket is used to find the length of


119 3 N R 1 getLength() Edit Delete
byte Array

Which of these method of DatagramPacket is used to find the port


120 3 N R 1 getPort() Edit Delete
number?
Which of these method of DatagramPacket is used to obtain the byte
121 3 N R 1 getData() Edit Delete
array of data contained in a datagram?

122 Which of these methods is used to know the full URL of an URL object? 3 N R 1 toExternalForm() Edit Delete

Which of these methods is used to know the type of content used in


123 3 N R 1 getContentType() Edit Delete
the URL?

Which of these methods is used to know when was the URL last
124 3 N R 1 getLastModified() Edit Delete
modified?

125 Which package is used for handling security related issue? 3 N R 1 java.security Edit Delete

126 Which socket class can send packets unreliably? 3 N R 1 java.net.DatagramSocket() Edit Delete

Which type of exception is throw by InetAddress class Factory


127 3 N R 1 UnknownHostException Edit Delete
methods?

You can invoke ______________ on a Socket object, say socket, to


128 3 N R 1 socket.getInetAddress(); Edit Delete
obtain an InetAddress object.

You can obtain the server's hostname by invoking


129 3 N R 1 getCodeBase().getHost() Edit Delete
__________________on an applet.

______is networking protocol for hypermedia, collaborative &


130 3 N R 1 HTTP Edit Delete
distributed information system.

________ is a low level routing protocol that breaks data into smaller
131 3 N R 1 Internet protocol. Edit Delete
packets.

__________ class is used for accessing the attribute of a remote


132 3 N R 1 URLConnection Class Edit Delete
resource.

133 __________ is a factory method which returns an array of addresses. 3 N R 1 getAllByName. Edit Delete

__________ is used to implement reliable, bidirectional, persistent


134 3 N R 1 TCP/IP client and server socket. Edit Delete
point to point stream based connection.

__________method is used to examine the address and port


135 3 N R 1 getInetAddress() Edit Delete
information by the socket.

__________method of URL class is used to obtained file path from


136 3 N R 1 getFile() Edit Delete
given URL.

____________ acts as a mediator between a client program and an


137 external servers to filter request , improve performance & share 3 N R 1 Proxy server Edit Delete
connections.

138 ____________port number is reserved for Http protocol. 3 N R 1 80 Edit Delete

_____________ protocol supports fast point to point datagram


139 3 N R 1 UDP Edit Delete
oriented model.

______________class is used to access the attributes of a remote


140 3 N R 1 URLConnection Edit Delete
host.

________________ is abstract class for representing access to a


141 3 N R 1 Permission Edit Delete
system resource.
___________________ method of DatagramSocket class is used to
142 3 N R 1 receive(DatagramPacket packet) Edit Delete
receive DatagramPacket.

A ___________is responsible for determining whether code executing


143 in the java runtime environment has permission to perform a security- 3 N U 2 Policy Object Edit Delete
sensitive operation.

Arrange the following code segment in proper order that represent


TCP server a) creating serverSocket object. server=new
ServerSocket(4000, 2); System.out.println("Socket open"); b) //receive
inputs from client receive=new
144 DataInputStream(client.getInputStream()); String data=null; 3 N U 2 a,c,b Edit Delete
while(true) { data=receive.readUTF(); System.out.println(data); } c)
//accept() method listens for a connection to be made to this socket
and accepts it. client=server.accept(); System.out.println("Client
connected");

Choose the class name to be used instead of A_Class to get correct


output. import java.net.*; class Sample { public static void
main(String[] args)throws UnknownHostException { try { A_Class
145 3 N A 2 InetAdress Edit Delete
address=A_Class.getByName("google.com");
System.out.println(address); }catch(UnknownHostException e) {
System.out.println("Caught : "+e); } } }

Choose the correct output import java.net.*; class myURL2 { public


static void main(String args[]) throws MalformedURLException { URL
u=new URL("http://www.msbte.com");
a) Protocol=http Host Name=www.msbte.com Port Number=-1
146 System.out.println("Protocol="+u.getProtocol()); 3 N A 2 Edit Delete
File Name=
System.out.println("Host Name="+u.getHost());
System.out.println("Port Number="+u.getPort());
System.out.println("File Name="+u.getFile()); } }

Choose the correct output import java.net.*; class networking { public


static void main(String args[])throws UnknownHostException {
147 InetAddress obj1 =InetAddress.getByName("msbte.com"); 3 N A 2 true Edit Delete
InetAddress obj2 =InetAddress.getByName("msbte.com"); boolean x =
obj1.equals(obj2); System.out.print(x); } }

Consider the following programe what will happen after execution.


import java.net.*; class sample { public static void main(String[] args)
148 throws Exception { URL obj = new URL("http://www.msbte.com"); 3 N A 2 84 Edit Delete
URLConnection obj1 = obj.openConnection(); int len =
obj1.getContentLength(); System.out.print(len); } }

Find Error in following program. import java.awt.*; class URLDemo {


public static void main(String args[]) throws urlexception { URL hp =
new URL("http://www.Abc.com/downloads");
149 3 N A 2 both a and b Edit Delete
System.out.println("Protocol: " + hp.getProtocol());
System.out.println("Port: " + hp.getPort()); System.out.println("Host: "
+ hp.getHost()); } }

For the following client side code of TCP implementation of sockets,


import java.io.IOException; import java.net.*; public class Server
what should be the server side code in order to establish connection
{ public static void main(String[] args) throws IOException {
between both the machines? import java.io.IOException; import
150 java.net.*; public class Client { public static void main(String[] args) 3 N A 2 ServerSocket ss=new ServerSocket(2000); Socket Edit Delete
throws UnknownHostException, IOException { Socket sock=new sock=ss.accept(); System.out.println("Connection
Socket("127.0.0.1",2000); } } Established"); } }

151 From given list which address is called as loopback address ? 3 N U 2 127.0.0.0 Edit Delete

152 getByname() method returns 3 N U 2 host name Edit Delete

153 getLocalHost() method is present in which package 3 N U 2 java.net Edit Delete

154 getPort() method of socket class return 3 N A 2 Returns the port number on which the socket is connected Edit Delete

Give line numbers containing errors in following program: import


java.Net.*; import java.io.*; import java.util.*; public class
HeaderViewer {public static void main(String args[]) {try {URL u = new
URL("http://www.rediffmail.com/index.html"); URLconnection uc =
u.openconnection( ); System.out.println("Content-type: "
+uc.getContentType( )); System.out.println("Content-encoding: "+
155 3 N A 2 Line No.: 1,7,8,10,12,14,16 Edit Delete
uC.getContentEncoding( )); System.out.println("Date: " + new
Date(uc.getDate( ))); System.out.println("Last modified: "+ new
Date(uC.getLastModified( ))); System.out.println("Expiration date: "+
new Date(uc.getExpiration( ))); System.out.println("Content-length: "
+uC.getContentLength( )); } catch (MalformedURLException ex)
{System.out.println("I can't understand this URL..."); } } }

Given Statement may throws which exception? InetAddress address


156 3 N U 2 UnknownHostException Edit Delete
=InetAddress.getByName("www.xyz.com");

Given the following lines from a Java program segment: byte[] dataOut
= new byte [512]; String userInput = "Java Programming"; dataOut =
userInput.getBytes(); Which of the following lines of code could be DatagramPacket packet = new DatagramPacket(dataOut,
157 3 N A 2 Edit Delete
used to create a new UDP datagram packet to send the data that was userInput.length, InetAddress, 9876)
provided by the user to a host identified by the InetAddress object
IPAddress?

158 Http is which type of Protocol 3 N U 2 Stateless Edit Delete

159 Identify the valid method of URL class. 3 N U 2 All of the mentioned Edit Delete

160 Identify the valid ServerSocket constructor. 3 N U 2 public ServerSocket(int portno) Edit Delete

If port number is not specified in the URL, getPort() method returns


161 3 N U 2 -1 Edit Delete
_______

If we create the datagram packet wit following constructor:


162 DatagramPacket(byte data[],int offset, int size, InetAddress ipaddress, 3 N U 2 size of the packet Edit Delete
int port) What "size" parameter specifies?

If you use either Telnet or FTP, which is the highest layer you are using
163 3 N U 2 Application Edit Delete
to transmit data?

import java.net.*; public class URLDemo{ public static void main(String


args[])throws MalformedURLException{ URL hp = new
URL("http://www.javajazzup.com"); System.out.println("Protocal:" +
Protocal:http Port:-1 Host:www.javajazzup.com File:
164 hp.getProtocol()); System.out.println("Port:" + hp.getPort()); 3 N U 2 Edit Delete
Ext:http://www.javajazzup.com
System.out.println("Host:" + hp.getHost()); System.out.println("File:" +
hp.getFile()); System.out.println("Ext:" + hp.toExternalForm()); } }
What will be the output of above code?

import java.io.*; import java.net.*; class exp7_1{ public static void


main(String args[]) throws MalformedURLException{ URL a=new
165 3 N A 2 -1 Edit Delete
URL("http://www.msbte.com:/index.html"); System.out.println("port
:"+a.getPort()); } }

import java.io.*; import java.net.*; class PwdClient { public static void


main(String args []) { try { Socket so =new Socket("localhost",3642);
DataInputStream d =new DataInputStream(System.in);
System.out.println("Enter a Password"); String passwd =d.readLine();
166 PrintStream p = new PrintStream(so.getOutputStream()); 3 N U 2 client side Edit Delete
p.println(passwd); DataInputStream d1 =new
DataInputStream(so.getInputStream()); String r =d1.readLine();
System.out.println(r); so.close(); } catch( Exception e) {
System.out.println("Msg from client: "+e); } } }

import java.net.*; class networking { public static void main(String[]


args) throws MalformedURLException { URL obj = new
167 3 N U 2 http://www.sanfoundry.com/javamcq Edit Delete
URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.toExternalForm()); } }

import java.net.*; class networking { public static void main(String[]


args) throws Exception { URL obj = new
168 URL("http://www.sanfoundry.com/javamcq"); URLConnection obj1 = 3 N U 2 text/html Edit Delete
obj.openConnection(); System.out.print(obj1.getContentType()); } }
Note: Host URL is written in html and simple text.

import java.net.*; class networking1 { public static void main(String[]


args) throws UnknownHostException { InetAddress obj1 =
169 InetAddress.getByName("www.google.com"); InetAddress obj2 = 3 N A 2 true Edit Delete
InetAddress.getByName("www.google.com"); boolean x =
obj1.equals(obj2); System.out.print(x); } }

import java.net.*; class myAddress { public static void main (String


args[]) { try { InetAddress address = InetAddress.getLocalHost();
170 3 N U 2 The internet address of the host Edit Delete
System.out.println(address); } catch (UnknownHostException e) {
System.out.println("Could not find this computer's address."); } } }

In following java program fill statement showing *****. Select any one
option from given options. import java.net.*; public class InetDemo {
public static void main(String[] args) { try { InetAddress
171 ip=InetAddress.**************** System.out.println("Host Name: 3 N A 2 getByName("www.msbte.com"); Edit Delete
"+ip.getHostName()); System.out.println("IP Address:
"+ip.getHostAddress()); } catch(Exception e) { System.out.println(e); }
}}

In how many ways we can create URL A)URL url = new


172 URL("http://hostname:80/index.html"); B)URL url = new URL("http", 3 N U 2 A & B both Edit Delete
"hostname", 80, "index.html");

In InetAddress class which method it returns the host name of the IP


173 3 N U 2 public static InetAddress getLocalHost() Edit Delete
Address?
In order to receive message from client which thing is missing in given
server side program in TCP connectivity: import java.net.*; import
java.io.*; class server { public static void main(String args[]) throws
174 Exception { ServerSocket s1 = new ServerSocket(2); InputStream i = 3 N A 2 OutputStream class Edit Delete
s.getInputStream(); DataInputStream di = new DataInputStream(i);
DataInputStream d = new DataInputStream(System.in); String str =
di.readUTF(); System.out.println(str); } }

In the following code, what type of protocol is Socket object "skt"


uses? import java.io.*; import java.net.*; public class NetClient { public
175 3 N U 2 TCP Edit Delete
static void main(String args[]) throws Exception { Socket skt = new
Socket("host",88); } }

In the following program choose the correct strings from given options
to pass in URL constructor to get an output without any exception.
import java.net.*; class URLDemo { public static void main(String
args[]) throws MalformedURLException { URL hp = new
URL("__________"); System.out.println("Protocol: " +
176 hp.getProtocol()); System.out.println("Port: " + hp.getPort()); 3 N A 2 All Edit Delete
System.out.println("Host: " + hp.getHost()); System.out.println("File: "
+ hp.getFile()); } } A. http://www.msbte.com/mainsite/index.php B.
http://www.msbte.com:80/mainsite/index.php C. www.msbte.com/ D.
www.msbte.com/mainsite/index.php

In this construtor ServerSocket(int port, int maxQueue) what is the


177 3 N U 2 50 Edit Delete
default value for maxQueue?

178 InetAddress is used to encapsulate 3 N U 2 both a and b Edit Delete

179 InputStream class is used in TCP Client-server program to 3 N U 2 Send/receive message from client to server Edit Delete

180 IPv6 uses ---------------------- 3 N U 2 Eight groups of four hexadecimal digits each Edit Delete

181 Java.net package consist of interface_____________ 3 N U 2 All of above Edit Delete

Match the following a) Datagram Socket i) UDP connection b) URL ii)


provides necessary framework of debugging java programs c) java.net
182 iii) makes it possible to communicate over a network with java 3 N A 2 a-i, b-iv, c-iii, d-ii Edit Delete
programs d) sun.tools.debug iv) is a java object that represent WWW
address

183 Name the components of the URL in order of their appearance 3 N U 2 Protocol,Hostname,Port Number, File Name Edit Delete

184 openConnection() method returns 3 N U 2 a) Returns a URLConnection object Edit Delete

185 Permission class is a part of which packets? 3 N U 2 java.security.Permission Edit Delete

186 port number of Telnet is________ 3 N U 2 23 Edit Delete

returns the socket and establish a connection between server and


187 3 N U 2 public Socket accept() Edit Delete
client.

DatagramPacket(byte data[],int size) DatagramPacket(byte


188 Select correct constructors of DatagramPacket class? 3 N U 2 Edit Delete
data[],int offset ,int size)

select correct the code for the display given output


Figure:-

import java.io.*; import java.net.*; public class URLConnection {


public static void main(String[] args) { try{ URL url=new
189 3 Y1 A 2 Edit Delete
URL("http://www.javatpoint.com/java-tutorial");
URLConnection huc=(URLConnection)url.o

190 Select pacakge used for handling security related issues in a program 3 N U 2 java.security Edit Delete

191 Select proper method used to create the instance InetAddress class. 3 N U 2 getLocalHost(),getByName(),getAllByName() Edit Delete

192 Select th proper interface of java.net package 3 N U 2 ContentHandlerFactory Edit Delete

Select the appropriate method for retrieving address of remote


193 3 N U 2 public Address getRemotHost( ) Edit Delete
machine

194 Select the fullform of DNS 3 N U 2 Domain Name System Edit Delete

195 Select the method of DatagramPacket used to find the port number 3 N U 2 getPort() Edit Delete

196 Select the method used to create a URL Connection 3 N U 2 openConnection Edit Delete

197 Select the method which throws UnKnownHostException 3 N U 2 All of the above Edit Delete

select the proper class for creating servers that listen for either local or
198 3 N U 2 ServerSockets Edit Delete
remote client programs

199 Select the proper constructor of ServerSocket 3 N U 2 ServerSocket(int port, int maxQueue) Edit Delete

200 Select the proper constructor of the Socket class 3 N U 2 Socket(String hostName, int port) Edit Delete

201 Select the proper constructor of URL class 3 N U 2 All of above Edit Delete

202 Select the proper InetAddress factory method. 3 N U 2 static InetAddress getLocalHost() Edit Delete

Select the proper method of URL class to create the object of


203 3 N U 2 openConnection() Edit Delete
URLConnection.

204 Select the proper method to know the type of content used in the URL. 3 N U 2 getContentType() Edit Delete

Select the proper method to retrieve the host name & IP address of static InetAddress getByName(String hostName)throws
205 3 N U 2 Edit Delete
remote machine having domain name as "www.msbte.com" UnknownHostException

Select the proper method to retrieve the host name and IP Address of static InetAddress getLocalHost( )throws
206 3 N U 2 Edit Delete
local machine UnknownHostException

static InetAddress.getLocalHost( )throws


207 Select the proper method to retrieve the host name of local machine 3 N U 2 Edit Delete
UnknownHostException

208 select the proper method to retrive the data from DatagramPacket 3 N U 2 getData() Edit Delete

Select the proper output for following code import java.net.*; class
DemoURL { public static void main(String args[])throws
209 3 N A 2 Port: -1 File: /downloads/index.php Edit Delete
MalformedURLException { URL hp=new
URL("http://www.msbte.com/downloads/index.php");
System.out.println("Port: "+hp.getPort()); System.out.println("File:
"+hp.getFile()); } }

ServerSocket has a method called __________, which is a blocking call


210 3 N U 2 accept() Edit Delete
that will wait for a client to initiate communications,

Socket connection = server.accept( ); In the above statement, server


211 is an object of ___________class and accept() method throws 3 N U 2 ServerSocket, IOException Edit Delete
________exception.

212 TCP and UDPs 3 N A 2 protocol Edit Delete

213 TCP does not supports Multicasting and Broadcasting because: 3 N U 2 It is connection oriented protocol. Edit Delete

The URL connection classes are good enough for simple programs that
214 3 N U 2 HTTP Edit Delete
want to connect to ______ server to fetch content.

The -------------- method in the InetAddress class returns the IP


215 3 N U 2 getHostAddress() Edit Delete
address.

The client request a connection to a server using the following


216 3 N A 2 Socket s=new Socket(ServerName,port); Edit Delete
statement.

217 The connection establishment in TCP is called 3 N U 2 three- way handshaking Edit Delete

218 The Constructor of URL can throws an Exception called 3 N U 2 MalFormedURLException Edit Delete

The following code can be used to produce a permisson to read the file perm=new
219 3 N U 2 Edit Delete
named "abc " in the /tmp directory java.io.FilePermission("/tmp/abc","read");

The following program is written for ____________________ import


java.net.*; import java.io.*; public class MyServer { public static void
main(String[] args) { ServerSocket s; Socket c; try { InetAddress
i=InetAddress.getByName("COMP30"); System.out.println(i); s=new
ServerSocket(8088); System.out.println("Server Started..");
c=s.accept(); // PrintStream ps=new
PrintStream(c.getOutputStream()); BufferedReader br=new
BufferedReader(new InputStreamReader(System.in)); //
220 3 N A 2 TCPIP server Edit Delete
BufferedReader br1 = new BufferedReader(new
InputStreamReader(c.getInputStream())); String l=""; boolean
flag=true; DataInputStream dis=new
DataInputStream(c.getInputStream()); DataOutputStream dos=new
DataOutputStream(c.getOutputStream()); while(flag) {
dos.writeUTF("Server-> "+br.readLine()); System.out.println("Client->
"+dis.readUTF()); } c.close(); } catch (Exception e) {
e.printStackTrace(); } } }

The following program will display _____________________ import


java.net.*; public class MyNetwork { public static void main(String
221 args[]) throws UnknownHostException { InetAddress ip [] = 3 N A 2 All IP addresses of www.google.com Edit Delete
InetAddress.getAllByName("www.google.com"); for(int
i=0;i<ip.length;i++) { System.out.println(ip[i].getHostAddress()); } } }
The following Server program _____________________ import
java.net.*; import java.io.*; public class Server { public static void
main(String args[]) throws IOException { ServerSocket ss = new waits for client request at 2000 port number and sends welcome
222 3 N A 2 Edit Delete
ServerSocket(2000); while(true) { Socket cs = ss.accept(); PrintWriter message to all clients
pw = new PrintWriter(cs.getOutputStream()); pw.println("welcome");
pw.close(); } } }

223 The purpose of URL is 3 N U 2 a and b Edit Delete

The server listens for a connection request from a client using the
224 3 N U 2 Socket s = serverSocket.accept() Edit Delete
following statement:

The Socket class has how many constructors that a client uses to
225 3 N A 2 2 Edit Delete
connect to a server:

226 The User Datagram Protocol (UDP) is 3 N U 2 All of them Edit Delete

The ____________________models an IP address,which can be used


227 3 N U 2 InetAddress class Edit Delete
to find the host name IP address of the client

The _____________________________ which contains a set of pre-


228 3 N U 2 java.net package Edit Delete
written networking routines

This program is written for ___________ side import java.net.*; import


java.io.*; public class MyClient { public static void main(String[] args) {
Socket c1; try { InetAddress i=InetAddress.getByName("COMP30");
System.out.println(i); c1=new Socket("localhost",8088);
System.out.println("Client Started.."); // PrintStream ps=new
PrintStream(c.getOutputStream()); BufferedReader br=new
BufferedReader(new InputStreamReader(System.in)); //
229 BufferedReader br1 = new BufferedReader(new 3 N U 2 client Edit Delete
InputStreamReader(c.getInputStream())); String l=""; boolean
flag=true; DataInputStream dis=new
DataInputStream(c1.getInputStream()); DataOutputStream dos=new
DataOutputStream(c1.getOutputStream()); while(flag) {
dos.writeUTF("Server-> "+br.readLine()); System.out.println("Client->
"+dis.readUTF()); } c1.close(); } catch (Exception e) {
e.printStackTrace(); } } }

To Get All addresses by name of a URL - "www.google.com" following InetAddress[] addresses =


230 3 N U 2 Edit Delete
command is used InetAddress.getAllByName(&quot;www.google.com&quot;);

To access the URLConnection Class object which of the transfer


231 3 N U 2 http Edit Delete
protocol is used?

To connect to a serevr running on the same machine with client, which


232 3 N U 2 All of the above Edit Delete
of the following can be used for hostname?

To create Socket "S" by IP address "127.0.0.1" and port number


"12345" Identify the command A) Socket s = new Socket("127.0.0.1",
233 3 N U 2 A Edit Delete
12345); B) ServerSocket s = new Socket("127.0.0.1", 12345); C)
Socket s = new Socket("localhost", 12345);

To create a server socket on the specified port with a maximum queue


234 3 N U 2 b and c Edit Delete
length of maxlength which of the following constructor use?
235 to create an InputStream on a socket s, you use ________ 3 N U 2 InputStream in = s.getInputStream(); Edit Delete

import java.net.*; class urld { public static void main(String


args[]) throws MalformedURLException { URL hp = new
to get the following output select the proper code Protocol: http Port:
236 3 N A 2 URL(&quot;http://www.msbte.com/downloads&quot;); Edit Delete
-1 Host: www.msbte.com File: /downloads
System.out.println(&quot;Protocol: &quot; + hp.getProtocol());
System.out.println(&quot;Port: &quot; +

To return the currently installed policy object ____________ method is


237 3 N U 2 public static Policy getPolicy() Edit Delete
used.

238 URL Connection is class used for_____________________. 3 N U 2 Accessing the attributes of a remote resource. Edit Delete

1. Network Protocol 2.Host name or address 3.port number 4.File


239 URL string encompasses four parts in sequence 3 N U 2 Edit Delete
or resource location

240 URLConnection object is retrived using following method? 3 N U 2 openConnection() Edit Delete

What correction should be done in the program to get correct output?


import java.net.*; import java.io.*; public class URLTest { public static
void main(String args[]) throws MalformedURLException { URL url =
241 new URL("http://www.msbte.com/download"); 3 N A 2 Use of created object not correct Edit Delete
System.out.println("Protocol:"+ url1.getProtocol());
System.out.println("Port:"+ url1.getPort()); System.out.println("Host:"+
url1.getHost()); System.out.println("File:"+ url1.getFile()); } }

What correction should be done in the program to get correct output?


import java.net.*; import java.io.*; public class URLTest { public static
void main(String args[]) throws MalformedURLException { URL url =
242 new URL("http://www.msbte.com/download"); 3 N A 2 Use of created object not correct Edit Delete
System.out.println("Protocol:"+ url1.getProtocol());
System.out.println("Port:"+ url1.getPort()); System.out.println("Host:"+
url1.getHost()); System.out.println("File:"+ url1.getFile()); } }

What correction should be done in the program to get corrected output


import java.net.*; import java.io.*; class UrlDemo1 { public static void
main(String a[]) throws Exception { URL ur= new
URL("http://www.msbte.com/mainsite/"); URLConnection
con=ur.openConnection(); System.out.println("Date : "+new
243 3 N A 2 Missing package statement Edit Delete
Date(con.getDate())); System.out.println("Content type :
"+con.getContentType()); System.out.println("Expires : "
+con.getExpiration()); System.out.println("Last Modified : "+new
Date(con.getLastModified())); int len=con.getContentLength();
System.out.println("content length : "+len); } }

What correction should be done in the program to get the correct


output import java.net.*; import java.io.*; class url8_5 { public static
void main(String args[])throws MalformedURLException,IOException {
244 URL u1=new URL("http://localhost:8080/index.htm"); URLConnection 3 N A 2 } Edit Delete
u2=u1.openConnection(); String ct=u2.getContentType();
System.out.println("Content type;"+ct); InputStream
ip=u2.getInputStream(); int c; while((c=ip.read())!=-1) {
System.out.print((char)c); } }
245 What is the proper constructor of serversocket 3 N U 2 All The Above Edit Delete

Attempts to create a server socket bound to the specified port.


what is use of this method? public ServerSocket(int port) throws
246 3 N U 2 An exception occurs if the port is already bound by another Edit Delete
IOException
application.

What is 1432 in following program. import java.net.*; import java.io.*;


public class SimpleClient { public static void main(String args[]) { try {
Socket s1=new Socket("127.0.0.1",1432); InputStream
247 3 N A 2 port number Edit Delete
is=s1.getInputStream(); BufferedReader br=new BufferedReader(new
InputStreamReader(is)); System.out.println(br.readLine()); br.close();
s1.close(); } catch(Exception e) {} } }

What is correct code for the given problem statement: Develop a


248 program to send a message through client to server and server will 3 N A 2 both a&amp; b Edit Delete
send message to client that hello message.

import java.net.*; class InetAddressTest { public static void


main(String args[]) throws UnknownHostException {
249 What is correct code to get ip address of host machine ? 3 N A 2 Edit Delete
InetAddress Address = InetAddress.getLocalHost();
System.out.println(Address); } }

What is missing in the following program code? import java.io.*; class


Sender { public static void main(String args[]) throws Exception {
DatagramSocket ds = new DatagramSocket(2000); String msg="hello";
250 byte b[]=msg.getBytes(); InetAddress 3 N U 2 All of the mentioned Edit Delete
ip=InetAddress.getByName("CLIENT-PC"); int port=3000;
DatagramPacket dp=new DatagramPacket(b,b.length,ip,port);
System.out.println("message sent..."); } }

What is out put of following Program import java.net.*; class


networking { public static void main(String[] args) throws Exception {
251 URL obj = new URL("http://www.sanfoundry.com/javamcq"); 3 N U 2 text/html Edit Delete
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType()); } }

What is output of following program import java.net.*; public class


InetAddressExample { public static void main(String arg[]) { try {
InetAddress ad=InetAddress.getByName("LocalHost");
252 System.out.println("CTE:"+ad); 3 N A 2 Gives default IP address and host name as LocalHost Edit Delete
System.out.println("CTE:"+ad.getHostAddress());
System.out.println("CTE:"+ad.getHostName()); }
catch(UnknownHostException e) {} } }

253 What is proper method to retrieve the host name of local machine 3 N U 2 static InetAddressgetLocalHost( )throws UnknownHostException Edit Delete

What is the default length of the queue in following constructor of


254 3 N U 2 50 Edit Delete
Serversocket? ServerSocket(int portno)

What is the error in given code? import java.net.*; public class


Hostname{ public static void main(String args[]){ try{ InetAddress
local= InetAddress.getLocalHost(); System.out.println ("Local System.out.println (&quot;Local hostname is: &quot; +
255 3 N A 2 Edit Delete
hostname is: " + local.getLocalHostName()); } catch local.getLocalHostName()); is wrong
(UnknownHostException e){ System.err.println ("Can't detect localhost
: " + e); } } }
256 what is the function of method int getPort()? 3 N U 2 Both a &amp; b Edit Delete

What is the meaning of following code segment? BufferedReader


new inFromServer object containing data from inputstream
257 inFromServer = new BufferedReader(new 3 N A 2 Edit Delete
object of clientSocket
InputStreamReader(clientSocket.getInputStream()));

What is the missing statement in the output of the following code:


import java.net.*; import java.io.*; import java.util.Date; class UCDemo
{ public static void main(String args[]) throws Exception { int c; URL hp
= new URL("http://www.internic.net"); URLConnection hpCon =
hp.openConnection(); long d = hpCon.getDate(); if(d==0)
System.out.println("No date information."); else
System.out.println("Date: " + new Date(d));
System.out.println("Content-Type: " + hpCon.getContentType()); d =
258 hpCon.getExpiration(); if(d==0) System.out.println("No expiration 3 N A 2 Content-Type: text/html Edit Delete
information."); else System.out.println("Expires: " + new Date(d)); d =
hpCon.getLastModified(); if(d==0) System.out.println("No last-modified
information."); else System.out.println("Last-Modified: " + new
Date(d)); int len = hpCon.getContentLength(); if(len == -1)
System.out.println("Content length unavailable."); else
System.out.println("Content-Length: " + len); }} Output: Date: Sat Apr
27 12:17:32 CDT 2002 No expiration information. Last-Modified: Tue
Mar 19 17:52:42 CST 2002 Content-Length: 5299

What is the ouput of following code? import java.net.InetAddress;


import java.net.UnknownHostException; class Inetadddemo { public
259 static void main(String args[])throws UnknownHostException { 3 N A 2 local m/c Address Edit Delete
InetAddress address=InetAddress.getLocalHost();
System.out.println(address); } }

what is the out of following code if Host URL was last modified on july
18 tuesday 2013 . mport java.net.*; class networking { public static
260 void main(String[] args) throws Exception { URL obj = new 3 N A 2 Tue Jun 18 2013 Edit Delete
URL("http://www.sanfoundry.com/javamcq"); URLConnection obj1 =
obj.openConnection(); System.out.print(obj1.getLastModified); } }

What is the output of this program?


Figure:-

261 3 Y1 A 2 cisco.com Edit Delete

What is the output of this program? import java.net.*; class


networking { public static void main(String[] args) throws
262 UnknownHostException { InetAddress obj1 = 3 N A 2 msbte.com Edit Delete
InetAddress.getByName("msbte.com");
System.out.print(obj1.getHostName()); } }

What is the output of this program? import java. Net.*; class


networking { public static void main ( String [] args ) throws
263 MalformedURLException { URL obj = new URL ( 3 N A 2 http Edit Delete
"http://www.sanforundry.com/javamcq"); System.out.print(
obj.getProtocol()); } }

264 What is the purpose of InetAddress class? 3 N U 2 To retrieve IP address of the specified host machine. Edit Delete

What is the return type of getAddress() method of DatagramPacket


265 3 N U 2 InetAddress Edit Delete
class?

266 What is the use of bind() method 3 N U 2 bind a socket to a local IP address and port Edit Delete

267 What is the use of writeUTF( ) method? 3 N U 2 This method writes a string into underlying output stream Edit Delete

What method is used to establish a port where a server waits for


268 3 N U 2 ServerSocket() Edit Delete
requests?

What statement is needed to get the output as shown in fig. in bellow


program import java.net.*; import java.io.*; import java.awt.event.*;
import javax.swing.*; import java.awt.*; class urlconn extends JFrame
implements ActionListener {JTextField f=new JTextField(); JTextArea
a=new JTextArea(); String s=""; public urlconn() {
getContentPane().add(f,BorderLayout.NORTH);
getContentPane().add(a,BorderLayout.CENTER);
f.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400,400);
} public void actionPerformed(ActionEvent e) { if(e.getSource()==f) {
try { URL u=new URL(f.getText()); URLConnection
con=u.openConnection(); BufferedReader br=new BufferedReader(new
InputStreamReader(con.getInputStream())); int
len=con.getContentLength(); if(len!=0) { while((s=br.readLine())!=null)
a.append("\n"+s); br.close(); } else a.append("\n"+"content
269 3 Y1 A 2 c=new urlconn(); in main method Edit Delete
unavailable"); }catch(Exception ae){} } } public static void main(String
ar[])throws Exception { urlconn c; c.setVisible(true); } }
Figure:-

270 What the method getDate() of URLConnection class returns? 3 N U 2 returns time and date of response in terms of millisecond Edit Delete

What the index.html specifies in following URL?


271 Http://www/rediff.com:80/index.html 3 N U 2 File name Edit Delete

272 What type of exception might be thrown by Socket class. 3 N U 2 UnknownHostException Edit Delete

What will be displayed in the output import java.net.*; class


InetAddressTest { public static void main(String args[]) throws
273 UnknownHostException { InetAddress SW[] = 3 N U 2 The array of internet address Edit Delete
InetAddress.getAllByName("www.nba.com"); for (int i=0; i<SW.length;
i++) System.out.println(SW[i]); } }

What will be displayed in the output? import java.net.*;


classmyAddress { public static void main (String args[]) { try {
274 InetAddress address = InetAddress.getLocalHost(); 3 N U 2 The internet address of the host Edit Delete
System.out.println(address); } catch (UnknownHostException e) {
System.out.println("Could not find this computer's address."); } } }

When client and server is communicating using TCP protocol then


275 3 N U 2 connection-oriented, concurrent Edit Delete
communication is ____________

when creating a client on a server port that is alerady in use client can connect to the server regardless of whehter the port is
276 3 N U 2 Edit Delete
________________ in use

277 When UnknownHostException is thrown, that indicates 3 N U 2 The IP address of a host could not be determined Edit Delete

Which datagram method returns the byte array of data contained in


278 3 N U 2 byte[] getData () Edit Delete
the datagram?

Which is correct client code for following server code? import


java.net.*; import java.io.*; class tcpip_server { public static void
main(String args[]) throws IOException { ServerSocket n1=null; try {
import java.net.*; import java.io.*; class tcpip_client { public
n1=new ServerSocket(98); } catch(IOException e) {
static void main(String args[]) throws IOException { Socket
System.err.println("Port 98 could not be found"); System.exit(1); }
s=null; BufferedReader b=null; try { s=new
Socket c=null; try { c=n1.accept(); System.out.println("Connection from
Socket(InetAddress.getLocalHost(),98); b=new
"+c); } catch(IOException e) { System.out.println("Accept failed");
279 3 N A 2 BufferedReader(new InputStreamReader(s.getInputStream())); } Edit Delete
System.exit(1); } PrintWriter out=new
catch(UnknownHostException u) { System.err.println(&quot;I
PrintWriter(c.getOutputStream(),true); BufferedReader in=new
don't know host&quot;); System.exit(0); } String inp;
BufferedReader(new InputStreamReader(c.getInputStream())); String
while((inp=b.readLine())!=null) { System.out.println(inp); }
n; BufferedReader sin=new BufferedReader(new
b.close(); s.close(); } }
InputStreamReader(System.in)); System.out.println("Ready to type
now"); while((n=sin.readLine())!=null) { out.println(n); } out.close();
c.close(); n1.close(); } }

Which Statement is missing in following code import java.net.*; public


class InetAddressExample { public static void main(String arg[]) { try {
System.out.println("CTE:"+ad); InetAddress
280 3 N A 2 Edit Delete
System.out.println("CTE:"+ad.getHostAddress()); ad=InetAddress.getByName(&quot;localhost&quot;);
System.out.println("CTE:"+ad.getHostName()); }
catch(UnknownHostException e) {} } }

Which class can be used to create a server socket. This object is used
281 3 N U 2 Both A &amp; B Edit Delete
to establish communication with the clients ?

282 Which code segment listens for a socket connection? 3 N U 2 Socket socket = HttpURLConnection.open(8080); Edit Delete

Which constructor is used to create ServerSocket connected to port no


283 3 N U 2 ServerSocket(1254) Edit Delete
1254 and maxq length as 50.

Which constructors of DatagramPacket class are used for receiving


284 3 N U 2 All Edit Delete
purpose?

285 Which Exception is thrown by DatagramSocket class constructor 3 N U 2 SocketException Edit Delete

286
Which five parameters uniquely identify a Connection ? 3 N U 2 Local IP, Remote IP, Local MAC, Remote MAC and Protocol Edit Delete

287 Which ip address is multicast ip address 3 N U 2 235.55.45.2 Edit Delete

Which is correct sequence of steps for establishing TCP Connection


between client and server ? A)client instantiates a Socket object with
server name and port. B) the server give call to accpet mehod form
288 3 N U 2 a,c,b,d Edit Delete
ServerSockect class C)server opens a ServerSocket object with port
number D)an accept method on server side returns reference to new
Socket which connected to client

289 Which is Factoty method? 3 N U 2 All of above Edit Delete

which is not the constructor of URL? 1) public URL()throws


MalformedURLException 2) public URL(String Protocol,String Host,int
290 Port,String File) throws MalformedURLException 3) public URL(String 3 N U 2 1 Edit Delete
URL) throws MalformedURLException. 4) public URL(URL Context,String
Url)throws MalformedURLException

which is not the method of security class? 1) SocketPermission() 2)


291 3 N U 2 3 Edit Delete
FilePermission() 3) DataPermission() 4) Non Of Above

292 Which is reserved port of HTTP & FTP 3 N U 2 80 &amp; 21 Edit Delete

Which is responsible for determining whether code executing in Java


293 runtime environment has permission to perform a security_sensitive 3 N U 2 security class Edit Delete
operation

Which is the class present in java.net package used to create packet


294 3 N U 2 DatagramPacket Edit Delete
from byte array and destination address?

295 Which method is used to obtain the Portno of client in Client Program 3 N U 2 getLocalPort() Edit Delete

296 Which method Returns the output stream of the URL connection ? 3 N U 2 getOutputStream() Edit Delete

297 Which methods are commonly used in ServerScocket class ? 3 N U 2 public Socket accept() Edit Delete

Which minimum package statements are missing? class InetDemo {


public static void main(String args[]) { try { Socket s=new
Socket("127.0.0.1",1234); InputStream ip=s.getInputStream();
298 3 N U 2 import java.net.*; import java.util.*; import java.io.*; Edit Delete
OutputStream op=s.getOutputStream(); Date d=new Date(); String
datemsg=String.valueOf(d); op.write(datemsg.getBytes()); op.close();
} catch(Exception e) { System.out.println(e); } } }

static InetAddress getAllLocalHost() throws


299 Which of the following is not a factory method of InetAddress class 3 N U 2 Edit Delete
UnknownHostException

Which of the following statement is missing in following code: import


java.io.*; import java.net.*; public class demo { public static void
main(String args[]) throws Exception { ServerSocket ss = new
ServerSocket(8); DataInputStream in = new
300 3 N U 2 Socket so = ss.accept(); Edit Delete
DataInputStream(so.getInputStream()); String pass1 = in.readLine();
if(pass1.equals("hi")) { System.out.print("\nPassword Is Correct");
PrintStream p1 = new PrintStream(so.getOutputStream());
p1.println("Welcome"); } else { System.out.print("\nWrong Password
Entered"); } } }

301 Which of these are correct constructor/s of URL class? 3 N U 2 All of above Edit Delete

302 Which of these class is used to encapsulate IP address and DNS? 3 N U 2 InetAddress Edit Delete

303 Which of these methods is used to know host of an URL? 3 N U 2 getHost() Edit Delete

which of this class is not related to input and output stream in terms of
304 3 N A 2 Reader Edit Delete
functioning?

Which protocol will be used/printed in the following example import


java.net.*; public class URLDemo { public static void main(String
args[]) throws MalformedURLException { URL hp = new
URL("http://www.msbte.com/downloads");
305 3 N A 2 HTTP Edit Delete
System.out.println("Protocol: " + hp.getProtocol());
System.out.println("Port: " + hp.getPort()); System.out.println("Host: "
+ hp.getHost()); System.out.println("File: " + hp.getFile());
System.out.println("Ext:" + hp.toExternalForm()); } }

Which Statement gives an error import java.net.*; import java.io.*;


public class URLTest { public static void main(String args[]) throws
MalformedURLException { URL url1 = new URL(); URLConnection hp =
306 openConnection("http://www.msbte.com/download"); 3 N A 2 C.Both A and B Edit Delete
System.out.println("Protocol:"+ url1.getProtocol());
System.out.println("Port:"+ url1.getPort()); System.out.println("Host:"+
url1.getHost()); System.out.println("File:"+ url1.getFile()); } }

Which statement is missing from the code import java.net.*; import


java. io.*; class Demo { public static void main(String args[]) { URL
307 3 N A 2 getProtocol() Edit Delete
url=new URL(“http://www.yahho.com/context/current/news.html”);
System.out.println(“{Protocol :”+url. ); } }

Write a syntax to prepare DatagramPacket Object as sendPacket by


using other parameter as following. InetAddress IPAddress =
DatagramPacket sendPacket=DatagramPacket(sendData,
308 InetAddress.getByName("127.0.0.1"); byte[] sendData = new 3 N A 2 Edit Delete
sendData.length, IPAddress, port);
byte[1024]; int port=9876; String sentence = inFromUser.readLine();
sendData = sentence.getBytes();

You can invoke ______________ on a Socket object, say socket, to


309 3 N A 2 socket.getInetAddress(); Edit Delete
obtain an InetAddress object.

You can obtain the server's hostname by invoking _________ on an


310 3 N U 2 getCodeBase().getHost() Edit Delete
applet.

311 _______ method is used to examine the address and port information 3 N U 2 getInetAddress(). Edit Delete
by the socket.

_________ is a protocol for breaking and sending packets to an


312 3 N U 2 TCP/IP Edit Delete
address across a network?
__________are used to implement reliable, bidirectional, persistent
313 3 N U 2 TCP/IP Edit Delete
point to point stream based connection.

314 ___________ is a bundle of information passed between machines. 3 N U 2 Datagram Edit Delete

___________ is a general-purpose class for accessing the attributes


315 3 N U 2 URLConnection Edit Delete
of a remote

316 ___________ server can process multiple request at a time 3 N U 2 a concurrent Edit Delete

___________is a factory method of InetAddress class which returns


317 3 N U 2 getAllByName() Edit Delete
an array of InetAddress.

318 _____________ class is necessory to implements Datagram 3 N U 2 both a and b Edit Delete

________________ is a mediator used in between Web Server and


319 3 N U 2 Proxy Edit Delete
Client

________________________ are the instance methods of


320 3 N U 2 All Edit Delete
InetAddress class.

…………….. method is used for testing whether the specified element is a


321 3 N A 2 isFile() Edit Delete
file or not.

322 …………….method is used to find thehost URL? 3 N U 2 getHost() Edit Delete

…………………thrown to indiacate that IP address of Host could not be


323 3 N U 2 UNknwonHostExecption Edit Delete
Determined

……………………….method of datagram packet is used to find the port


324 3 N U 2 getPort() Edit Delete
number.

A technique that creates a subletting effect; one server answers ARP


325 3 N U 2 Proxy Server Edit Delete
requests for multiple hosts?

326 Which client accesses the Web server by using a GET MESSAGE? 3 N U 2 HTTP Edit Delete

Which of these is a protocol for breaking and sending packets to


327 3 N U 2 TCIP/IP Edit Delete
an address across a network?

C opyright © 2014 - 2015. All rights reserved.

You might also like