MSBTE AJP - ALL - MCQs Scheme I
MSBTE AJP - ALL - MCQs Scheme I
1 AWT stands for? All window Toolkit Abstract window Toolkit All writing Tools All windows Tools B
Labels, Push buttons, Check boxes, Text components, Threads, Strings, Labels, Strings, JSP, Netbeans, Push buttons, Servelts,
2 Which are various AWT controls from following? A
Choice, Lists Servelts, Vectors Sockets Notepad, JSP
3 Which of the following is the passive control? TextField Label Button Checkbox B
4 By calling _____________ method we add control in the window. Add() add() Insert() insert() B
8 Which of the following is not the constrcutor of label? Label() Label(String s) Label(int alignemnt) Label(String s, int alignment) C
13 AWT stands for? All window Toolkit Abstract window Toolkit All writing Tools All windows Tools B
14 Which method can be used to output a string in an applet display() print() drawString() transient() C
15 To disabled Label from applet which method is used? setEnabled(true) setEnabled(false) setDisabled(true) setDisabled(false) B
18 Which of the following is not the constrcutor of Button? Button() Button(String s) Button(int aalign) none of these C
19 ____is the return type of getLabel() method of Button class String void Icon int A
20 return type of setLabel() is_______ String void Icon int B
21 To fetch caption of a button ____ method is used GetLabel() setLabel() getLabel() SetLabel() C
26 For creating a Button having label which constructor is used? Button(String str) Button(Icon i) Button(String str,Icon i) Button() A
30 A __________ control is used to turn an option on or off. Button Label Checkbox List C
34 How many checkboxes we can check at a time one two Many None of these C
boolean setState(Boolean
36 CheckBox state can be changed by which method? void getSelected(Boolean state) boolean getSelected(Boolean state) void setState(Boolean state) C
state)
37 You can determine the checkbox name by which method? void getLabel() String getLabel() void getText() String getText() B
39 Which control is used to select only one option at a time in AWT? Checkbox CheckboxGroup RadioButton None of these B
43 ___________ control is used for single-line entry. Text TextField TextArea TextGroup B
Which control allows user to enter string and edit the text using
44 textfield textarea both a and b none of these C
the arrow key, cut and paste keys.
48 Modification of text can be controlled by _____ method. setEditable(true) setEditable(false) seteditable(true) seteditable(false) B
56 Which of the following is not a TextArea constructor? TextArea(int row,int col) TextArea(String text) TextArea(String text,int column) TextArea() C
To construct a TextArea with text, rows and columns and scrollbar TextArea(String text, int rows,int TextArea(String text, int columns,int
57 both none of these A
which constructor is used? columns, int scrollbar) rows, int scrollbar)
59 ___________ method is used to add a string at specified index. append() insert() add() replace() B
Only one item can be selected from Multiple item can be selected from
60 Following is true about list class both a and b none of these B
the list the list
63 Which of the following is not a List constructor? List() List(boolean mode) List(int rows) List(int rows, boolean mode) B
64 Which method is used to add new items in list void add(String item) Void Add(string item) both none A
67 Which method determine the number of items from the list int GetitemCount() int getitemCount() int GetItemCount() int getItemCount() D
68 To set the currently selected item which method is used int select(int index) void select(int index) both None B
70 Which methods determines the number of items from the list. GetItemCount() getitemCount() getItemcount() getItemCount() D
75 ___is the return type of getSelectedItem of choice class String int void object A
76 ___ is the return type of getSelectedIndex() of choice control int void string boolean A
78 AWT Viewer tool is available in which of the folder of JDK bin Lib Source class A
79 ____________ method is used to get current value of scrollbar. GetValue() getValue() get() Get() B
80 __________ method is used to set new value to scrollbar SetValue() setValue() set() Set() B
Controls or components allow users Controls or components do not Controls or components allow users Controls or components allow
87 What are controls or components? application to interact with A
to interact with application allow users to interact with users to interact with users
user
91 Which class is on the top of AWT event hierarchy? java.util.eventObject java.awt.event java.event none of these B
92 which method is used to check the status of the checkbox getState() GETSTATE() both a and b none of these A
93 To specify a font to be bold and Italic, use the font style value Font.PLAIN Font.BOLD+ITALIC Font.BOLD.ITALIC Font.BOLD+Font.ITALIC D
100 ____ is the default layout manager for Panel or Applet Flow Layout Grid Layout Border Layout Card Layout A
101 Which method is used to set layout of the container setLayout() SetLayout() setlayout() none of these A
102 The general form to set a specific type of layout manager is void setlayout(layout manager ob) void SetLayout(layout manager ob) void setLayout(LayoutManager ob) none of these C
105 Default gap between the components is_______- 1 pixel 5 pixel 10 pixel 20 pixel B
106 Default Layout for Frame FlowLayout BorderLayout GridLayout Card Layout B
108 Default layout manager for window is CardLayout FlowLayout BorderLayout GridLayout C
112 _____ arrange components in rows and columns CardLayout Grid Layout FlowLayout BorderLayout B
115 In cardLayout we are going to add component for every card to window Panel Frame container B
117 Which methodd returns the face name of the invoking font? String getName() String SetName() String getFontName() String setFontName() C
118 ___is the return type of isBold() method of FONT class void boolean String TRUE B
119 is a return type of isBold () of Font class void boolean string TRUE B
121 Which abstract class is a super class of menu related classes? menu menuclass Menu component none of these C
122 ____ method is used to add the menubar on frame window setMenuBar() addMenuBar() addMenu none of these A
123 Which of the following may a menu contain MaenuBar Menu both a and b none of these A
124 setEnabled(false); method used in menu item for _____ used to invisible menu item used to visible menu item used to select menu item none of these D
The concept of menu bar can be implemented by using three java
125 MenuBar Menu MenuItem all D
class:-
128 Which of these is super class of all adapeter class? Applet component Event Event InputEvent A
130 Types of dialog Boxes? Nodal & Nodeless Model & Modeless Modal & Nodal Both a & b B
135 When dialog box is closed which method is called? exit() close() closed() dispose() D
{
public static void main(String args[]) throws
UnknownHostException
22 { 0 1 true false C
InetAddress obj1=InetAddress.getByName("google.com");
InetAddress obj2=InetAddress.getByName("google.com");
Boolean x=obj1.equals(obj2);
System.out.println(x);
}
}
import java.io.*;
import java.net.*;
import java.util.Date;
public class udemo
{
public static void main(String args[]) throws
MalformedURLException, IOException
{
URLConnecti URLConnecti URLConnecti URLConnecti
int c;
on u1 = on u1 = on u = on =
25 long d; B
openConnecti u.openConnec u.openConnec u.openConnec
URL u = new URL("http://www.msbte.com");
on(); tion(); tion(); tion();
String s = u1.getContentType();
System.out.println("Content type:"+s);
d= u1.getDate();
System.out.println("Date:"+new Date(d));
InputStream ip = u1.getInputStream();
while((c = ip.read())!=-1)
System.out.print((char)c);
}
}
import java.net.*;
class networking
{
public static void main(String[] args) throws
33 MalformedURLException http https www com A
{
URL obj = new
URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getProtocol());
}
}
What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws
34 MalformedURLException 0 1 -1 garbage value C
{
URL obj = new
URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getPort());
}
}
What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws http://www.sa
sanfoundry.co www.sanfoun
35 MalformedURLException sanfoundry nfoundry.com/ C
m dry.com
{ javamcq
URL obj = new
URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getHost());
}
}
What is the output of this program? * importjava.net.*; *
classnetworking { * publicstaticvoidmain(String[] args)
throwsException { * URL obj = new
36 html text html/text text/html D
URL("http://www.sanfoundry.com/java mcq"); *
URLConnection obj1 = obj.openConnection(); *
System.out.print(obj1.getContentType() ); * } * }
37 How many bits are in a single IP address? 8 16 32 64 C
What is the output of this program import
java.io.*;
Class networking
Public static void main(String args[]) throws
UnknownHostException
38 { a a.com www.a.com None of these B
InetAddress obj1=InetAddress.getByName(“a.com”);
System.out.println(obj1.getHostName());
}
}
import java.io.*;
import java.net.*;
public class udemo
{
public static void main(String args[]) throws
MalformedURLException, IOException
{
int c;
long d; import import import import
53 B
URL u = new URL("http://www.msbte.com"); Java.awt.*; java.util.Date; java.sql.*; java.thread.*;
String s = u1.getContentType();
System.out.println("Content type:"+s);
d= u1.getDate();
System.out.println("Date:"+new Date(d));
InputStream ip = u1.getInputStream();
while((c = ip.read())!=-1)
System.out.print((char)c);
}
}
Fill in correct code at blank space:- import java.net.*;
public class getDatagramExample { public static void
main(String args[]) { String s="This is a test"; byte{}
data=new byte[s.length()]; s.getBytes(0,s.length(),data,0);
try { InetAddress
ia=InetAddress.__________("www.msbte.com"); int
getName, getByName, getByName, getByName,
port=7; DatagramPacket dp=new
54 UnknownHost UnknownExc UnknownHost UnknownHost C
DatagramPacket(data,data.length,ia,port);System.out.println
Exception eption Exception exception
("This packet is addressed to "+dp.getAddress()+"on
port"+dp.getPort());System.out.println("There are"
+dp.getLength()+"bytes of data in the
packet");System.out.println(new
String(dp.getData(),0,0,dp.getLength()));}
catch(___________ e){System.err.println(e);}}}
What is the output of the following code if Host URL was
last modified on June 18 Tuesday 2013. import java.net.*;
class networking { public static void main(string args[])
Tue Jun 18
55 throws Exception { URL obj=bew URL("http:// 0 1 None of these A
2013
www.sanfoundry.com/javamcq"); URLConnection
obj1=obj.openConnection();System.out.print(obj1.getLastM
odified);}}
Which of these are protocol for breaking and sending packets to
56 TCP/IP DNS Socket Proxy Server A
an address across a network?
Domain
Data Network Data Name Domain Name
57 Which of these is a full form of DNS? Network D
Service Service Service
Service
the server
the server is
java.net.BindE the server is encounteres a
blocked until
58 When creating a server on port that is already in use, ______ xceptionError created with no fatal error and A
the port is
occur problem must be
available
terminated.
the client can
the client
connect to the the client is
java.net.BindE encounteres a
server blocked until
59 When creating a client on a server port that is already in use,___ xceptionError fatal error and A
regardless of the port is
occur must be
whether the available
terminated.
port is use.
Socket s= new Socket s= Socket s= Socket s= new
the client request a connection to a server using the following
60 Socket(servern serverSocket.ac serverSocket.ge Socket(servern A
statement:
ame, port); cept(); tSocket(); ame);
Which method of serverSocket will wait for a client to initiate
61 accept() wait() resume() None of these A
communication and then communicate with the client
Which of these methods of DatagramPacket issued to obtain the
62 getData() getBytes() getArray() receiveBytes() A
byte array of data contained in a datagram?
The _____ which contains a set of pre-written networking java.net.packag
63 java.io java.awt None of these A
routines. e
java.net.UDPS java.net.Datagr
64 Which socket class can send packets unreliably? java.net.Socket None of these B
ocket amSocket
65 ____ class is used to create client in TCP/IP ServerSocket Server Calient None of these A
A ____ object is responsible for determining whether code
66 executing in the Java runtime environment has permission to Policy Security Both None of these A
perform a security-sensitive operation
What is default length of the queue in following constructor of
67 25 75 50 15 C
Servesocket serverSocket(int portno)
68 ____ is a bundle of information passed between machines. Datagram serversocket clientsocket None of these A
69 The ______ class is used to create TCP server. ServerSocket Server Calient None of these A
DatagramPacke
DatagramPacke DatagramPacke t(byte data[],int
70 select the proper constructor of DatagramPacket class? t(byte data[],int t(byte data[],int size,InetAddres All of above D
size) offset,int size) s ipAddress,int
port)
71 UDP protocol are knowing as ____ Datagram socket server None of these A
returns the socket and establish a connection between server public socket public void public void
72 None of these A
and client accept() wait() resume()
as a part of the
73 How to send data in get method? File Both None of these A
URL
Connection Connection
74 ___ class is used for accessing the attribute of a remote resource. Both None of these A
class oriented
what is the default length of the queue in following constructor of
75 50 75 100 180 A
Serversocket? ServerSocket(int portno)
which method of ServerSocket will wait for a client to
76 initiate communications and then communicate with the accept() wait() resume() None of these A
client
DatagramServe
77 The ___ class is used to create TCP server. ServerSocket Server Socket A
r()
DatagramSocke DatagramPacke DatagramClient DatagramServe
78 Which class is used to create UDP client? A
t() t() () r()
DatagramPacke DatagramSocke
79 Which of these classes is necessary to implement datagrams? Both None of these C
t t
Which of these methods of DatagramPacket is used to find the
80 port() getPort() findPort() receivePort() A
port number?
Which of these is a return type of getAddress method of DatagramPacke DatagramSocke
81 InetAddress ServerSocket C
DatagramPacket class? t t
ServerSocket(i Socket(InetAdd
82 Select the proper constructor of serversocket ntport, ressipAddress, Socket(int port) ServerSocket() A
intmaxQueue) intport)
Complete following server code for accepting client request.
Import java.io.*; import java.net.*; public class MyServer {
public static void main(String [] args) { try{ ServerSocket
Socket Socket
83 ss=new ServerSocket(6666); _____________ DataInputStream accept(); None of these B
sss.accept(); s=ss.accept();
dis=new DataInputStream(s.getInputStream()); String
str=(String)dis.readUTF();System.out.println("message="+str);ss.
close();}catch(Exception e){System.out.println(e);}}}
Which of these method of DatagramPacket is used to find the
84 getnumber() length() Length() getLength() D
length of byte array?
DatagramPacke DatagramSocke
85 Which of these class is necessary to implement datagrams? all none of these C
t t
Which of these method of DatagramPacket class is used to find getAddress()
86 findAddress() Address() whois() B
the destination address?
Which of these is a return type of getAddress method of DatagramPacke DatagramSocke
87 InetAddress ServerSocket C
DatagramPacket class? t t
Which of these methods is used to know when was the URL last getLastModifie GetLastModifie getlastModified
88 LastModified() B
modified? d() d() ()
Which of these methods is used to know the type of content getContentTyp GetContentTyp
89 ContentType() contentType() C
used in the URL? e() e()
DatagramSocke
Which constructor of DatagramSocket class is used to creates a DatagramSocke t(int port, DatagramSocke None of the
90 B
datagram socket and binds it with the given Port Number? t(int port) InetAddress t() above
address)
public
public
OutputStream public Socket
91 Which methods are commonly used in ServerSocket class? synchronized none of these B
getOutputStrea accept()
void close()
m()
Which class is used to create servers that listen for either local None of the
92 ServerSockets httpServer httpResponse A
client or remote client programs? above
The DatagramSocket and DatagramPacket classes are not used
93 TRUE FALSE B
for connection-less socket programming.
Sr.No. Question Option A Option B Option C Option D Answer
Which of the following is used ResultSet
execute
1 generally for reading the content executeQuery execute() none of these A
update()
of the database? ()
ODBC
The JDBC-ODBC bridge allows JDBC drivers, Drivers, Application,
2 drivers, JDBC C
……….. to be used as ……….. ODBC drivers Application drivers
drivers
Native API converts JDBC calls, ODBC class,
ODBC class, JDBC calls,
3 ____________ into the network network A
user call user call
___________ used by DBMS. protocol protocol
Prepared statement object in
4 JDBC used to execute ____ executable simple high level parameterized D
queries.
5 JDBC-ODBC Bridge is multidynamic multithreaded both none of these B
The ____ method sets the query
6 parameters of the setString() setBoolean() setByte() setObject() A
PreparedStatement Object.
Prepared Statement
updatreemp=con.preparedStatem
ent("insert into emp
7 1 2 3 4 C
values(?,?,?)"); How many
values are need to iunsert for
PreparedStatement parameter?
Which JDBC driver Type(s) can
Both type 1 Both type 1 Both type 3
8 be used in either applet or servlet only Type 4 C
and 2 and 3 and 4
code?
Best for any All of the
9 JDBC-ODBC Bridge is multithreaded Three tiered A
platform above
ResultSet navigation method All of the
10 afterLast() beforeFirst() next() D
consist of above
Which of the following methods
Class.forNam registerDriver getConnection
11 are needed for loading a Both A and B C
e() () method ()
database driver in JDBC?
prepareStatement method is from PreparedState collableState
12 Both A and B none of these A
which class ment class ment class
_____ method of DriverManager
createConnect getConnection
13 class is used to establish with the both none of these B
ion() ()
database.
We can use ResultSet navigation
backward
14 methods when we have ResultSet Forward only both none of these A
only
that is of type
Which method is used for an
preparedState collableState
15 SQL statement that is executed statement() none of these A
ment ment()
frequently?
Which type of driver is unique in JDBC-ODBC JDBC-Native JDBC-Net 100% Pure
16 B
JDBC? bridge API pure Java Java
Which of the following method
preparedState collableState
17 is used to create object of statement() none of these A
ment() ment()
PreparedStatement interface
Which models does JDBC API
18 2Tier model 3 Tier model both none of these C
supports for database access?
select
TABLE_NA
ME from
INFORMATI
select * from
What is the query used to display ON_SCHEM
19 infromation_s both none of these B
all tables names in SQL Server? A.TABLES
chema,table
where
TABLE_TYP
E = 'BASE
TABLE'
Which statement is static and executeQuery executeUpdat getConnection
20 preparecall() C
synchronized in JDBC API () e() ()
executeBatch(
21 method returns the number of rowsexecuteUpdate() execute() executeQuery() A
)
The ____ method executes a
executeBatch(
22 simple query and returns a single executeUpdate() execute() executeQuery() D
)
Result Set object.
____ returns a
getColumnNa
23 ResultSetMetaData object getResultSet getMetaData getData C
me
describing the ResultSet.
___ method of DriverManager
getConnection acceptconnect establish
24 classes used to establish none of these A
() ion() connection()
connection with the database.
ResultSet navigation method
25 beforeFirst afterLast previous all D
consist of
The syntax for creating table create table create table
26 table course { table course( C
named course should begin with course { course(
Which method is used to retrive retriveResultS updateResultS
27 getResultSet() none of these B
the resultset created. et() et()
In JDBC ___ imports all Java
28 classes concerned with database javax.sql.* java.mysql.* java.sql.* com.* C
connectivity.
in MYSQL in MYSQL in MYSQL
Where is metadata stored in
29 database database database none of these C
MySQL?
metadata metasql mysql
MY-SQL stored data in ___ file
30 .DAT .MDB .MSSQL .OBJ A
format
ODBC
The JDBC-ODBC bridge allows JDBC drivers, Drivers, Application,
31 drivers, JDBC C
____ to be used as ____ ODBC drivers Application drivers
drivers
For execution of DELETE SQL
executeQuery executeDelete executeUpdat executeDelete
32 query in JDBC, ___ method must C
() Query() e() ()
be used.
executeQuery() method ResultSet Single Database
33 Single row B
returns_____________________ object Column Table
PreparedStatement interface
34 extends____________________ Connection Statement ResultSet Driver B
interface
executeUpdate() method ResultSet
35 Single row Integer Single column C
returns_____________________ object
Standard Sequential Structured Server side
36 ____ is a full form of SQL query query query query C
language language language language
To select all column from the select all from select * from select from
37 none of these B
table the syntax is table name table name table name
How many JDBC driver types
38 One Two Three Four D
does sun define?
Which JDBC driver Type(s) is
39 Type 1 Type 2 Type 3 Type4 A
(are) the JDBC-ODBC bridge?
A Java program cannot directly ODBC written ODBC written ODBC written
ODBC written
40 communicate with an ODBC in C# in C++ in Basic D
in C language
driver because ....... language language language
The JDBC-ODBC Bridge driver
41 translates the JDBC API to the JDBC drivers ODBC drivers Both none of these B
ODBC API and used with .......
. The
................................method executeUpdat executeDelete
42 execute() nonexecute() B
executes a simple query and e() Query()
returns a single Result Set object
State true or false. Is the
43 JDBC-ODBC bridge is TRUE FALSE A
Multithreaded?
Which of the following type of JDBC-ODBC
Native-API, JDBC-Net, Native-protoc
JDBC driver, uses database Bridge plus
44 partly Java pure Java ol, pure Java D
native ODBC
driver driver driver
protocol? driver
Which of the following type of JDBC-ODBC
Native-API, JDBC-Net, Native-protoc
JDBC driver, is also called Type Bridge plus
45 partly Java pure Java ol, pure Java B
2 JDBC ODBC
driver driver driver
driver? driver
A JDBC
RowSet object
holds tabular
data in a way A RowSet
Which of the following is correct that makes it objects are Both of the
46 none of these C
about RowSet? more JavaBeans above.
flexible and components.
easier to use
than a result
set.
Select the class or interface
Driver Driver ResultSet Connection
47 which is not used for database B
Manager interface interface interface
connectivity
1. Consider the following
program.
What should be the correction
done in the program to get
correct output?
import java.sql.*;
class Ddemo1
{
public static void main(String
args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.Jd
bcOdbcDriver");
Connection
c=DriverManager.getConnection
Missing Missing
48 ("jdbc:odbc:ODSN"," "," "); Missing { Missing } C
semicolon statement
Statement s=c.createStatement();
ResultSet
rs=s.executeQuery("select *from
StudTable");
System .out.println("Name" + " \t
" + "Roll_No" + " \t " + "Avg");
while(rs.next())
{
System.out.println(rs.getString(1
)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3));
s.close();
c.close();
}}
1. Consider the following
program.
What should be the correction
done in the program to get
correct output?
import java.sql.*;
class Ddemo1
{
{
Class.forName("sun.jdbc.odbc.Jd
bcOdbcDriver");
Connection
c=DriverManager.getConnection
("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
Missing Missing
49 ResultSet Missing { Missing } D
semicolon statement
rs=s.executeQuery("select *from
StudTable");
System .out.println("Name" + " \t
" + "Roll_No" + " \t " + "Avg");
while(rs.next())
{
System.out.println(rs.getString(1
)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3));
}
s.close();
c.close();
}
}
1. Consider the following
program.
What should be the correction
done in the program to get
correct output?
import java.sql.*;
class Ddemo1
{
public static void main(String
args[]) throws Exception;
{
Class.forName("sun.jdbc.odbc.Jd
bcOdbcDriver");
Connection
c=DriverManager.getConnection Error in
Error in Error in
50 ("jdbc:odbc:ODSN"," "," "); Error in loop connection A
main() close()
Statement s=c.createStatement(); statement
ResultSet
rs=s.executeQuery("select *from
StudTable");
System .out.println("Name" + " \t
" + "Roll_No" + " \t " + "Avg");
while(rs.next())
{
System.out.println(rs.getString(1
)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3));
}
s.close();
c.close();}}
1. Consider the following
program.
What should be the correction
done in the program to get
correct output?
class Ddemo1
{
public static void main(String
args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.Jd
bcOdbcDriver");
Connection
c=DriverManager.getConnection
("jdbc:odbc:ODSN"," "," "); Missing
Missing
51 Statement s=c.createStatement(); Missing { Missing } packagestate D
semicolon
ResultSet ment
rs=s.executeQuery("select *from
StudTable");
System .out.println("Name" + " \t
" + "Roll_No" + " \t " + "Avg");
while(rs.next())
{
System.out.println(rs.getString(1
)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3));
}
s.close();
c.close();
}}
Consider the following program
Select the statement that should
be added to the program to get
correct output.
import java.sql.*;
public class db15
{public static void main(String
args[])throws Exception
{Class.forName("sun.jdbc.odbc.J
dbcOdbcDriver");
Connection c
=DriverManager.getConnection("
jdbc:odbc:MyDSN","","");
PreparedStatement
s=c.prepareStatement( "update
db3 set Name=? where
c.createStatem
52 Roll_no=?"); s.executeUpda s.close() c.close() A
ent( )
Statement s=c.createStatement( ); te()
s.setString(1,args[0]);
s.setString(2,args[1]);
s.setString(3,args[2]);
ResultSet
rs=s.executeQuery("select* from
db3");
System.out.println("Name"+"\t"+
"Roll no"+"\t"+"Avg");
while(rs.next())
{System.out.println(rs.getString(
1)+"\t"+rs.getInt(2)+"\t"+rs.getD
ouble(3));}
s.close();
c.close();}}
2. Consider the following
program
import java.sql.*;
public class db15
{
public static void main(String
args[])throws Exception
{
Class.forName("sun.jdbc.odbc.
JdbcOdbcDriver");
Connection c
=DriverManager.getConnectio
n("jdbc:odbc:MyDSN","","");
PreparedStatement
s=c.prepareStatement( "update
db3 set Name=? where
Roll_no=?");
Statement s=c.createStatement(
);
s.setString(1,*);
s.setString(2,*);
A. Command
53 s.setString(3,*); B. Array C. Vector D. Integer A
line argument
s.executeUpdate();
ResultSet
rs=s.executeQuery("select*
from db3");
System.out.println("Name"+"\
t"+"Roll no"+"\t"+"Avg");
while(rs.next())
{
System.out.println(rs.getString
(1)+"\t"+rs.getInt(2)+"\t"+rs.g
etDouble(3));
}
s.close();
c.close();
}
}
Option Option Option Option
Sr.No. Question A B C D Answer
< @ %= none of
JSP starts and end with symbol <% %> <%= %>
1 %> these A
both a and none of
A JSP page consists of which tags? HTML JSP
2 b these C
getRequest
Which method of HTTPServeltResponse is used to redirect an redirectUR sendRedirc redirctHttp
Dispatcher(
HTTP request to another URL L() t() ()
3 ) B
Non-Persis
Which cookies it is valid for single Session only, it is removed Persistent both a and none of
tent
each time when user closes the browser? Cookies b these
4 Cookies A
In order to create a HTTPServelet following import
statements are used:- a.import java.io.*; a,b,c are only a and only a and
only a
b.import javax.servlet.* c.import compulsary c b
5 javax.servlet.http.*; A
getServlet none of
Which is not method of GenericServlet class destroy() init()
6 Config() these D
Platform
both a and none of
Servlet is __________ interface independen
b these
7 t C
Which of the following is the deployment descriptor file in none of
web.xml web.html web.java
8 servlet these A
javax.servl javax.Servl
In servlet programming a cookies is respresented by the javax.servl javax.servl
et.http.coo et.http.coo
cookie class in ____ package et.cookie et.cookie
9 kie kie B
startapache none of
Which file will start tomcat server? startup.txt start.bat
10 .bat these B
javax.servl
javax.servl
et.servletC both a and none of
init(), service(), destroy() method are declared in ____ et.Servlet
onfig b these
interface
11 interface A
state
informatio Client Server Program
A cookie contains___ n of userr Informatio Informatio Informatio
like name, n n n
12 address A
enumeratio
n of all the an object
parameter the name
The getInitParameter() method of ServletConfig interface initializatio of
passes to of the
returns _____ n ServletCon
the servlet servlet.
parameter text.
13 names. A
The session
The session The session object is
getSession() method with true as parameter it will return the The session
is does not passed to
appropriate session object is existing
completed exists another
14 method D
none of
_____ is destructive phase of JSP life cycle. cleanup Service() destroy()
15 these A
CGI is not
CGI is
platform
platform
independen
independen
t but
Servlet offer following advantages over CGI t but
servlet are
servlet are
platform
platform
independen
depended
16 t A
Tag library tag library both a and none of
TLD stands for _____
17 descriptor Data b these A
what is the limit of the data to be passed from HTML when
2kb 3kb 4kb 5kb
18 doGet() is used? A
Which mechanism is included by jsp for defining custom static local dynamic global
19 tags? attributes attributes attributes attributes C
PUT FTP WRITE COPY
Name the http method used to send resources to the server
20 Method Method Method Method A
The ___ method is called when servlet is First created and not
init() service() destroy() all of these
21 called again A
Servlet, HTML, HTML, Java,
JSP embeds in ____ in ____
22 HTML Java Servlet HTML C
23 Servlet life cycle have ____ state 2 3 4 5 B
appends
Sends a
includes the request
request to
resource of and
another none of
The inculde() method of RequestDispatche file like response
resource these
servlet, jso objects to
like servlet
or html the current
,jsp or html
24 servlet A
jspService( jspDestroy( none of
JSP page performs request processing by calling ___ method. JspInit()
25 ) ) these B
The following methods belongs to life cycle methods of
init() Service() destroy() all of these
26 servlet D
getSession( GetSession getsessionI none of
______ method gives the current session
27 ) () D() these A
ServletReq ServletReq ServletCon
Suppose you want to know each time request comes in, so HttpReque
uestListene uestAttribu textListene
that you can log it.Which listener is appropriate for that? stListener
28 r teListener r A
Which class provides stream to read binary data such as ServltInput ServletOut both a and none of
29 image etc. from the request object? Stream putStream b these A
ServletReq ServletCon HttpSessio
If you want to track active session or how many users are HttpSessio
uestListene textListene nBindingLi
there ? Which listener you should use. nListener
30 r r stener C
Disadvantage of CGI: 1.It has lack of scability abnd reduced
1 and 2 1 and 3 only 3 all of these
31 speed. 2.High performance time 3.CGI is platform dependent B
Java Java Either 1 or
A JSP is transformed into a(n): None
32 Applet Servlet 2 B
The Java __________ specification defines an application
programming interface for communication between the Web Servlet Server Program Randomize
33 server and the application program. A
What programming language(s) or scripting language(s) does VBScript
Jscript only Java only All
34 Java Server Pages (JSP) support? Only C
35 ___ are JSP code fragments embedded within <%...%> tags. Scriptlets Servlet Cookie all A
request.get request.set responce.g responce.g A
The doGet() method in the example extracts values of the
Parameter( Parameter( etParamete etAttribute(
parameter’s type and number by using __________
36 ) ) r() )
web web B
web
component component
A deployment descriptor describes component all
response request
settings
37 settings objects
Name the class that includes the getSession() method that is HttpServlet HttpServlet SessionCo SessionCo A
38 used to get the HttpSession object Request Response ntext nfig
A user types the URL http://www.msbte.com/result.php. A
GET POST HEAD PUT
Which HTTP request gets generated. Select the one correct
method method method method
39 answer
A session A
refers to
the entire
interaction
between
A session A session
client and A session
is a time refers to
What is session in Servlet programming? server from is a
taken by time taken
the time of interaction
server by client
client
logon to
logout
from
40 system
Open Open go to A
Write
Notepad, Notepad, explorer
HTML
Write Save file and write
code, Save
HTML with command
file with
code, Save extension http://locati
extension
file with .html, go to on:8080/cr
.html, go to
extension explorer eated
explorer
.html, go to and write folder
Find correct Steps for creating and executing HTML file for and write
explorer command name/*.ht
Servlet programming command
and write http://locati ml, Open
http://locati
command on:8080/cr Notepad,
on:8080/cr
http://locati eated Write
eated
on:8080/cr folder HTML
folder
eated name/*.ht code, Save
name/*.ht
folder ml, Write file with
ml, open
name/*.ht HTML extension
notepad
41 ml code .html
Browser C
Browser Browser
will
will Browser will
What is meaning of following statement interpret
interpret will take interpret
Res.setContentType(“text/html”); content as
content as contents as content as
HTML
source plain text Java source
source
code. code.
42 code.
void void void void A
service(Ser service( service(Ser service(Ser
vletReques ServletRes vletReques vletRespon
Identify correct syntax of service() method of servlet class
t req, ponse res t req, se req,
ServletRes ServletReq ServletReq ServletRes
43 ponse res) uest req, ) uest req ) ponse res)
Choose missing statements in following code from given
options.
Program for session
// program for session
public class session1 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException {
// Get the HttpSession object.
import
HttpSession hs = request.getSession(true); import import
java.io.*; import
// Get writer. javax.servl javax.servl
import java.Vector
response.setContentType("text/html"); et.http.*; et.http.*;
java.util.*; .* ; import
PrintWriter pw = response.getWriter(); import import
import java.Threa
pw.print("<B>"); java.Threa java.String.
javax.servl d.*; import
// Display date/time of last access. d.*; import *; import
et.*; import javax.servl
Date date = (Date)hs.getAttribute("date"); javax.Clien java.Vector
javax.servl et.*;
if(date != null) { t.*; ;
et.http.*;
pw.print("Last access: " + date + "<br>");
}
// Display current date/time.
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}
44 B
. In following Java program fill statement showing ***.Select
any one option fro given options
Program for cookie
// program for cookie
import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException {
// Get parameter from HTTP request.
new new new new
String data = request.getParameter("data");
Cookie("M Cookie("M Cookie("M Cookie("M
// Create cookie.
yCookie", yCookie", yCookie", yCookie",
Cookie cookie = ***************
data); data1); data2); database);
// Add cookie to HTTP response.
response.addCookie(cookie);
// Write output to browser.
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}
45 A