Maharashtra State Board of Technical Education
(Autonomous) (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 Dele
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 Dele
means______________________________.
2 TCP/IP reserves the___________________ports for specific protocols 3 N R 1 lower 1024 Edit Dele
Which of these package contains classes and interfaces for
3 3 N R 1 java.net Edit Dele
networking?
4 A ServerSocket can connect to_____________clients. 3 N R 1 multiple Edit Dele
5 A set of rules that governs data communication. 3 N R 1 protocol Edit Dele
6 A socket identifies________________in network. 3 N R 1 a communication end point Edit Dele
7 A socket is combination of 3 N R 1 Both A and B Edit Dele
A socket is__________________________of a two-way communication link
8 3 N R 1 one end-point Edit Dele
between two programs running on two hosts in the network.
9 Access control does not deals with 3 N R 1 Authenication Edit Dele
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 Dele
sensitive operation.
byte[] getData() method of DatagramPacket class
11 3 N R 1 Byte array of data contained in datagram Edit Dele
returns______________________
Class URL represents_______________________________________________, a
12 3 N R 1 Uniform Resource Locator Edit Dele
pointer to a "resource" on the World Wide Web
13 Communication using TCP protocol is __________and _________ 3 N R 1 connection-oriented, concurrent Edit Dele
Connection oriented communication is possible using
14 3 N R 1 Socket and ServerSocket Edit Dele
___________________classes of Java.
15 How many bits are in a single IPv4 address? 3 N R 1 32 Edit Dele
16 How many bytes are required to represent an IPv4 address? 3 N R 1 4 Edit Dele
In InetAddress class which method returns the host name of the IP
17 3 N R 1 public String getHostName() Edit Dele
Address?
18 In the format for defining the URL what is the last part? 3 N R 1 File path Edit Dele
19 In the URL, http://www.osborne.com:80/index.htm, 80 represents 3 N R 1 Port number Edit Dele
20 In UDP send() and receive() methods belong to which class? 3 N R 1 DatagramSocket Edit Dele
21 In which class the constructors are not visible 3 N R 1 Inetaddress class Edit Dele
22 Inet Address class encapsulates__________________ 3 N R 1 Both A and B Edit Dele
23 IP Stands for ________ 3 N R 1 Internet Protocol Edit Dele
24 Java.net package include following classes. 3 N R 1 URLConnection, Socket, InetAddress Edit Dele
Name the class which is used to create a port where the server will
25 3 N R 1 ServerSocket Edit Dele
listen?
26 Permission class of java.security package is____________class 3 N R 1 abstract Edit Dele
27 Permission class belongs to which package? 3 N R 1 java.security Edit Dele
28 Port Number for FTP is 3 N R 1 21 Edit Dele
29 Port number of Email is_________________. 3 N R 1 25 Edit Dele
30 Pretty Good Privacy (PGP) is used in security of 3 N R 1 Email Edit Dele
31 Reserved port no of HTTP 3 N R 1 80 Edit Dele
32 Resolver in DNS sysytem maps 3 N R 1 Domain name to ip address Edit Dele
33 Select the proper constructor of ServerSocket class 3 N R 1 All of above Edit Dele
34 Select the proper constructor of URL class 3 N R 1 All of the above Edit Dele
35 TCP is Which Type of Protocol ? 3 N R 1 Connection oriented protocol Edit Dele
36 TCP is_____________oriented protocol 3 N R 1 stream Edit Dele
37 TCP Stands for ________ 3 N R 1 Transmission Control Protocol Edit Dele
38 TCP/IP sockets are used to impelement________________connections. 3 N R 1 All of the above Edit Dele
The class which encapsulates both the numerical IP address and the
39 3 N R 1 InetAddress Edit Dele
domain name for that address.
The constructor which is used in ServerSocket may
40 3 N R 1 ServerSocket (int port). Edit Dele
be___________________.
41 The constructor which is used to create client socket is__________________. 3 N R 1 Socket(InetAddress IPAddress, int port). Edit Dele
The factory method for retrieving objects of InetAddress is
42 3 N R 1 All of the mentioned Edit Dele
___________________.
The factory method which returns an array of InetAddresses that
43 3 N R 1 getAllByName( ) Edit Dele
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 Dele
the________________________
45 The method int getPort( ) of Socket class returns____________ 3 N R 1 remote port to which this Socket object is connected. Edit Dele
The number 80 in following URL specifies?
46 3 N R 1 Port number Edit Dele
http://www.rediff.com:80/index.htm/
47 The openConnection() is the method of which Class? 3 N R 1 URLConnection Edit Dele
The openConnection() method of URL class return
48 3 N R 1 URLConnection Edit Dele
_____________Object.
49 The return type of getHostAddress() method is_____________ 3 N R 1 string Edit Dele
The server listens for a connection request from a client using the
50 3 N R 1 Socket s = ServerSocket.accept() Edit Dele
following statement:
51 The valid sequence for URL format is ___________________ 3 N R 1 protocol, Hostname, portnumber, filepath Edit Dele
The_________________method in the InetAddress class returns the IP
52 3 N R 1 getHostAddress() Edit Dele
address.
53 The____________________class is used to create TCP server. 3 N R 1 ServerSocket Edit Dele
54 To create an InputStream on a Socket s, you use_______________. 3 N R 1 InputStream in = s.getInputStream(); Edit Dele
55 To obtain an ObjectOutputStream from a socket,use__________ 3 N R 1 new ObjectOutputStream(socket.getOutputStream()) Edit Dele
56 To return an instance of InetAddress class you have to use 3 N R 1 Factory Methods of InetAddress class Edit Dele
To return the currently intalled policy object____________________method is
57 3 N R 1 public static Policy getPolicy() Edit Dele
used.
58 UDP is not_______________oriented protocol. 3 N R 1 Connection Edit Dele
59 UDP Packets are known as ___________________ 3 N R 1 Datagram Edit Dele
60 UDP Protocol uses following classes for communication 3 N R 1 DatagramPacket and DatagramSocket Edit Dele
61 UDP Stands for ________ 3 N R 1 User Datagram Protocol Edit Dele
URL class has several constructors; each can throw a
62 3 N R 1 MalformedURLException Edit Dele
_____________________.
63 What does the openConnection() method of java.net.* return? 3 N R 1 Object of URLConnection class Edit Dele
64 What does URL stands for? 3 N R 1 Uniform Resource Locator Edit Dele
65 What is return type of getAddress() method of InetAddress class? 3 N R 1 byte[] Edit Dele
66 What is Second part of URL address 3 N R 1 Hostname Edit Dele
67 What is Socket? 3 N R 1 All of these Edit Dele
68 What is the first part of URL address? 3 N R 1 Protocol Edit Dele
69 What is the optional part of URL Address 3 N R 1 Port Number Edit Dele
What is the return type of the method getAllByName( ) of InetAddress
70 3 N R 1 InetAddress[ ] Edit Dele
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 Dele
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 Dele
server
73 When a URL object is created __________ 3 N R 1 a connection is automatically established with that URL Edit Dele
Which class defines following methods. 1. int getContent Length() 2.
74 3 N R 1 URLConnection Edit Dele
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 Dele
URL?
76 Which class is used to create client in TCP/IP? 3 N R 1 Socket Edit Dele
Which class is used to designed to be a "listener" which waits for client
77 3 N R 1 ServerSocket Edit Dele
to connect before doing anything.
78 Which class is used to implement datagrams with UDP protocol. 3 N R 1 DatagramSocket Edit Dele
Which class of java.net package can be used to find the host name
79 3 N R 1 The InetAddress class Edit Dele
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 Dele
Which constructor of DatagramSocket class is used to create a
81 3 N R 1 DatagramSocket(int port) Edit Dele
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 Dele
the datagram?
Which exception indicate that the IP address of a host could not be
83 3 N R 1 UnknownHostException Edit Dele
determined
84 Which is connection less protocol 3 N R 1 UDP Edit Dele
85 Which is not a method of URL Connection? 3 N R 1 Date getLastModified( ) Edit Dele
86 Which is not valid method of URL class? 3 N R 1 getUrl() Edit Dele
87 Which is the correct syntax from given? 3 N R 1 byte[] getAddress() Edit Dele
88 Which is the reliable protocol of networking ? 3 N R 1 TCP Edit Dele
89 Which method is used to know the full URL of an URL object? 3 N R 1 toExternalForm() Edit Dele
90 Which method is used to retrieve the host name associated with URL 3 N R 1 getHost() Edit Dele
91 Which method is used to return the IPAddress of local machine 3 N R 1 static InetAddress getLocalHost( ) Edit Dele
Which method of ServerSocket will wait for a client to initiate
92 3 N R 1 accept() Edit Dele
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 Dele
94 Which of the following are Factory Methods of InetAddress class 3 N R 1 All the Above Edit Dele
95 Which of the following class defines accept() method? 3 N R 1 ServerSocket Edit Dele
96 Which of the following constructor of InetAddress is generally used? 3 N R 1 InetAddress class does not contain any visible constructor. Edit Dele
97 Which of the following is a connection oriented protocol? 3 N R 1 TCP Edit Dele
Which of the following is mediator between real web server and client
98 3 N R 1 Proxy Edit Dele
application
99 Which of the following is not a constructor of DatagramSocket 3 N R 1 DatagramSocket(InetAddress address) Edit Dele
Which of the following is not a Factory method of an InetAddress
100 3 N R 1 Sting getHostAddress() Edit Dele
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 Dele
server
102 Which of the following is true about UDP? 3 N R 1 No retransmission of lost packets. Edit Dele
103 Which of the following is true for TCP ? 3 N R 1 TCP is realiable and connection oriented Edit Dele
104 Which of the following is true for UDP ? 3 N R 1 UDP is unrealiable and connection less Edit Dele
Which of the following method is used to obtain remote port to which
105 3 N R 1 getPort() Edit Dele
Socket object is connected.
Which of the following methods of InetAddress class returs the IP
106 3 N R 1 getHostAddress() Edit Dele
Address?
107 Which of the ServerSocket method listen client request for connection? 3 N R 1 accept() Edit Dele
108 Which of these class is necessary to implement datagrams? 3 N R 1 Both of these Edit Dele
Which of these class is used to create servers that listen for either
109 3 N R 1 ServerSockets Edit Dele
local or remote client programs?
110 Which of these class is used to encapsulate IP address and DNS? 3 N R 1 InetAddress Edit Dele
which of these class must be used to send a datagram packets over a
111 3 N R 1 All of the mentioned Edit Dele
connection?
112 Which of these is a bundle of information passed between machines? 3 N R 1 Datagram Edit Dele
113 Which of these is a factory methods 3 N R 1 getLocalHost() Edit Dele
114 Which of these is a not a factory method of InetAddress class? 3 N R 1 static InetAddress getAllName(String hostName) Edit Dele
Which of these is a protocol for breaking and sending packets to an
115 3 N R 1 TCP/IP Edit Dele
address across a network?
Which of these is a return type of getAddress method of
116 3 N R 1 InetAddress Edit Dele
DatagramPacket class?
Which of these is a return type of getData() method of
117 3 N R 1 byte Edit Dele
DatagramPacket class
118 Which of these method does not belongs to DatagramPacket class 3 N R 1 getAddress() Edit Dele
which of these method of DatagramPacket is used to find the length of
119 3 N R 1 getLength() Edit Dele
byte Array
Which of these method of DatagramPacket is used to find the port
120 3 N R 1 getPort() Edit Dele
number?
Which of these method of DatagramPacket is used to obtain the byte
121 3 N R 1 getData() Edit Dele
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 Dele
Which of these methods is used to know the type of content used in
123 3 N R 1 getContentType() Edit Dele
the URL?
Which of these methods is used to know when was the URL last
124 3 N R 1 getLastModified() Edit Dele
modified?
125 Which package is used for handling security related issue? 3 N R 1 java.security Edit Dele
126 Which socket class can send packets unreliably? 3 N R 1 java.net.DatagramSocket() Edit Dele
Which type of exception is throw by InetAddress class Factory
127 3 N R 1 UnknownHostException Edit Dele
methods?
You can invoke_____________________on a Socket object, say socket, to
128 3 N R 1 socket.getInetAddress(); Edit Dele
obtain an InetAddress object.
You can obtain the server's hostname by invoking
129 3 N R 1 getCodeBase().getHost() Edit Dele
__________________on an applet.
______is networking protocol for hypermedia, collaborative &
130 3 N R 1 HTTP Edit Dele
distributed information system.
________ is a low level routing protocol that breaks data into smaller
131 3 N R 1 Internet protocol. Edit Dele
packets.
__________ class is used for accessing the attribute of a remote
132 3 N R 1 URLConnection Class Edit Dele
resource.
133 __________ is a factory method which returns an array of addresses. 3 N R 1 getAllByName. Edit Dele
__________ is used to implement reliable, bidirectional, persistent
134 3 N R 1 TCP/IP client and server socket. Edit Dele
point to point stream based connection.
__________method is used to examine the address and port
135 3 N R 1 getInetAddress() Edit Dele
information by the socket.
__________method of URL class is used to obtained file path from
136 3 N R 1 getFile() Edit Dele
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 Dele
connections.
138 ____________port number is reserved for Http protocol. 3 N R 1 80 Edit Dele
_____________ protocol supports fast point to point datagram
139 3 N R 1 UDP Edit Dele
oriented model.
______________class is used to access the attributes of a remote
140 3 N R 1 URLConnection Edit Dele
host.
________________ is abstract class for representing access to a
141 3 N R 1 Permission Edit Dele
system resource.
___________________ method of DatagramSocket class is used to
142 3 N R 1 receive(DatagramPacket packet) Edit Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
152 getByname() method returns 3 N U 2 host name Edit Dele
153 getLocalHost() method is present in which package 3 N U 2 java.net Edit Dele
154 getPort() method of socket class return 3 N A 2 Returns the port number on which the socket is connected Edit Dele
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 Dele
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 Dele
=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 Dele
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 Dele
159 Identify the valid method of URL class. 3 N U 2 All of the mentioned Edit Dele
160 Identify the valid ServerSocket constructor. 3 N U 2 public ServerSocket(int portno) Edit Dele
If port number is not specified in the URL, getPort() method returns
161 3 N U 2 -1 Edit Dele
_______
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
"+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 Dele
"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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
default value for maxQueue?
178 InetAddress is used to encapsulate 3 N U 2 both a and b Edit Dele
179 InputStream class is used in TCP Client-server program to 3 N U 2 Send/receive message from client to server Edit Dele
180 IPv6 uses ---------------------- 3 N U 2 Eight groups of four hexadecimal digits each Edit Dele
181 Java.net package consist of interface_____________ 3 N U 2 All of above Edit Dele
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 Dele
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 Dele
184 openConnection() method returns 3 N U 2 a) Returns a URLConnection object Edit Dele
185 Permission class is a part of which packets? 3 N U 2 java.security.Permission Edit Dele
186 port number of Telnet is________ 3 N U 2 23 Edit Dele
returns the socket and establish a connection between server and
187 3 N U 2 public Socket accept() Edit Dele
client.
DatagramPacket(byte data[],int size) DatagramPacket(byte
188 Select correct constructors of DatagramPacket class? 3 N U 2 Edit Dele
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 Dele
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 Dele
191 Select proper method used to create the instance InetAddress class. 3 N U 2 getLocalHost(),getByName(),getAllByName() Edit Dele
192 Select th proper interface of java.net package 3 N U 2 ContentHandlerFactory Edit Dele
Select the appropriate method for retrieving address of remote
193 3 N U 2 public Address getRemotHost( ) Edit Dele
machine
194 Select the fullform of DNS 3 N U 2 Domain Name System Edit Dele
195 Select the method of DatagramPacket used to find the port number 3 N U 2 getPort() Edit Dele
196 Select the method used to create a URL Connection 3 N U 2 openConnection Edit Dele
197 Select the method which throws UnKnownHostException 3 N U 2 All of the above Edit Dele
select the proper class for creating servers that listen for either local or
198 3 N U 2 ServerSockets Edit Dele
remote client programs
199 Select the proper constructor of ServerSocket 3 N U 2 ServerSocket(int port, int maxQueue) Edit Dele
200 Select the proper constructor of the Socket class 3 N U 2 Socket(String hostName, int port) Edit Dele
201 Select the proper constructor of URL class 3 N U 2 All of above Edit Dele
202 Select the proper InetAddress factory method. 3 N U 2 static InetAddress getLocalHost() Edit Dele
Select the proper method of URL class to create the object of
203 3 N U 2 openConnection() Edit Dele
URLConnection.
204 Select the proper method to know the type of content used in the URL. 3 N U 2 getContentType() Edit Dele
Select the proper method to retrieve the host name & IP address of static InetAddress getByName(String hostName)throws
205 3 N U 2 Edit Dele
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 Dele
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 Dele
UnknownHostException
208 select the proper method to retrive the data from DatagramPacket 3 N U 2 getData() Edit Dele
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 Dele
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 Dele
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 Dele
________exception.
212 TCP and UDPs 3 N A 2 protocol Edit Dele
213 TCP does not supports Multicasting and Broadcasting because: 3 N U 2 It is connection oriented protocol. Edit Dele
The URL connection classes are good enough for simple programs that
214 3 N U 2 HTTP Edit Dele
want to connect to__________server to fetch content.
The--------------------method in the InetAddress class returns the IP
215 3 N U 2 getHostAddress() Edit Dele
address.
The client request a connection to a server using the following
216 3 N A 2 Socket s=new Socket(ServerName,port); Edit Dele
statement.
217 The connection establishment in TCP is called 3 N U 2 three- way handshaking Edit Dele
218 The Constructor of URL can throws an Exception called 3 N U 2 MalFormedURLException Edit Dele
The following code can be used to produce a permisson to read the file perm=new
219 3 N U 2 Edit Dele
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 Dele
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 Dele
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 Dele
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 Dele
The server listens for a connection request from a client using the
224 3 N U 2 Socket s = serverSocket.accept() Edit Dele
following statement:
The Socket class has how many constructors that a client uses to
225 3 N A 2 2 Edit Dele
connect to a server:
226 The User Datagram Protocol (UDP) is 3 N U 2 All of them Edit Dele
The____________________________models an IP address,which can be used
227 3 N U 2 InetAddress class Edit Dele
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 Dele
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 Dele
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 Dele
command is used InetAddress.getAllByName("www.google.com");
To access the URLConnection Class object which of the transfer
231 3 N U 2 http Edit Dele
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 Dele
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 Dele
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 Dele
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 Dele
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: URL("http://www.msbte.com/downloads");
236 3 N A 2 Edit Dele
-1 Host: www.msbte.com File: /downloads System.out.println("Protocol: " + hp.getProtocol());
System.out.println("Port: " +
To return the currently installed policy object___________________method is
237 3 N U 2 public static Policy getPolicy() Edit Dele
used.
238 URL Connection is class used for_____________________________. 3 N U 2 Accessing the attributes of a remote resource. Edit Dele
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 Dele
or resource location
240 URLConnection object is retrived using following method? 3 N U 2 openConnection() Edit Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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& b Edit Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
What is the default length of the queue in following constructor of
254 3 N U 2 50 Edit Dele
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 ("Local hostname is: " +
255 3 N A 2 Edit Dele
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 & b Edit Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
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 Dele
"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 Dele
What is the return type of getAddress() method of DatagramPacket
265 3 N U 2 InetAddress Edit Dele
class?
266 What is the use of bind() method 3 N U 2 bind a socket to a local IP address and port Edit Dele
267 What is the use of writeUTF( ) method? 3 N U 2 This method writes a string into underlying output stream Edit Dele
What method is used to establish a port where a server waits for
268 3 N U 2 ServerSocket() Edit Dele
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 Dele
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 Dele
What the index.html specifies in following URL?
271 Http://www/rediff.com:80/index.html 3 N U 2 File name Edit Dele
272 What type of exception might be thrown by Socket class. 3 N U 2 UnknownHostException Edit Dele
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 Dele
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 Dele
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 Dele
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 Dele
________________ in use
277 When UnknownHostException is thrown, that indicates 3 N U 2 The IP address of a host could not be determined Edit Dele
Which datagram method returns the byte array of data contained in
278 3 N U 2 byte[] getData () Edit Dele
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 Dele
System.exit(1); } PrintWriter out=new
catch(UnknownHostException u) { System.err.println("I
PrintWriter(c.getOutputStream(),true); BufferedReader in=new
don't know host"); 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 Dele
System.out.println("CTE:"+ad.getHostAddress()); ad=InetAddress.getByName("localhost");
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 & B Edit Dele
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 Dele
Which constructor is used to create ServerSocket connected to port no
283 3 N U 2 ServerSocket(1254) Edit Dele
1254 and maxq length as 50.
Which constructors of DatagramPacket class are used for receiving
284 3 N U 2 All Edit Dele
purpose?
285 Which Exception is thrown by DatagramSocket class constructor 3 N U 2 SocketException Edit Dele
286
Which five parameters uniquely identify a Connection ? 3 N U 2 Local IP, Remote IP, Local MAC, Remote MAC and Protocol Edit Dele
287 Which ip address is multicast ip address 3 N U 2 235.55.45.2 Edit Dele
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 Dele
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 Dele
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 Dele
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 Dele
FilePermission() 3) DataPermission() 4) Non Of Above
292 Which is reserved port of HTTP & FTP 3 N U 2 80 & 21 Edit Dele
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 Dele
operation
Which is the class present in java.net package used to create packet
294 3 N U 2 DatagramPacket Edit Dele
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 Dele
296 Which method Returns the output stream of the URL connection ? 3 N U 2 getOutputStream() Edit Dele
297 Which methods are commonly used in ServerScocket class ? 3 N U 2 public Socket accept() Edit Dele
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 Dele
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 Dele
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 Dele
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 Dele
302 Which of these class is used to encapsulate IP address and DNS? 3 N U 2 InetAddress Edit Dele
303 Which of these methods is used to know host of an URL? 3 N U 2 getHost() Edit Dele
which of this class is not related to input and output stream in terms of
304 3 N A 2 Reader Edit Dele
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"); System.out.println("Protocol:
305 3 N A 2 HTTP Edit Dele
" + 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 Dele
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 Dele
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 Dele
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 Dele
obtain an InetAddress object.
You can obtain the server's hostname by invoking_______________on an
310 3 N U 2 getCodeBase().getHost() Edit Dele
applet.
311 _______ method is used to examine the address and port information 3 N U 2 getInetAddress(). Edit Dele
by the socket.
_________ is a protocol for breaking and sending packets to an
312 3 N U 2 TCP/IP Edit Dele
address across a network?
__________are used to implement reliable, bidirectional, persistent
313 3 N U 2 TCP/IP Edit Dele
point to point stream based connection.
314 ___________ is a bundle of information passed between machines. 3 N U 2 Datagram Edit Dele
___________ is a general-purpose class for accessing the attributes
315 3 N U 2 URLConnection Edit Dele
of a remote
316 ___________ server can process multiple request at a time 3 N U 2 a concurrent Edit Dele
___________is a factory method of InetAddress class which returns
317 3 N U 2 getAllByName() Edit Dele
an array of InetAddress.
318 _____________ class is necessory to implements Datagram 3 N U 2 both a and b Edit Dele
________________ is a mediator used in between Web Server and
319 3 N U 2 Proxy Edit Dele
Client
________________________ are the instance methods of
320 3 N U 2 All Edit Dele
InetAddress class.
…………….. method is used for testing whether the specified element is a
321 3 N A 2 isFile() Edit Dele
file or not.
322 …………….method is used to find thehost URL? 3 N U 2 getHost() Edit Dele
…………………thrown to indiacate that IP address of Host could not be
323 3 N U 2 UNknwonHostExecption Edit Dele
Determined
……………………….method of datagram packet is used to find the port
324 3 N U 2 getPort() Edit Dele
number.
A technique that creates a subletting effect; one server answers ARP
325 3 N U 2 Proxy Server Edit Dele
requests for multiple hosts?
326 Which client accesses the Web server by using a GET MESSAGE? 3 N U 2 HTTP Edit Dele
Which of these is a protocol for breaking and sending packets to
327 3 N U 2 TCIP/IP Edit Dele
an address across a network?
Copyright © 2014 - 2015. All rights reserved.