You are on page 1of 871

Questions

Load the appropriate driver in following program:

import java.sql.*;

class exp10_2
{

public static void main(String m[])throws Exception


1
{
Class.forName("___________________________");
Connection con=DriverManager.getConnection("jdbc:odbc:dsnname");
Statement cmd=con.createStatement();
cmd.executeUpdate("insert into tabel1 values(4,100,'aaaa')");
System.out.println("db is updated");
cmd.close();
con.close();
}
}

A. sun.jdbc.odbc.JdbcOdbcDriver

B. sun:jdbc:odbc:JdbcOdbcDriver

C. sun.jdbc.JdbcDriver

D. sun.oracle.odbc.JdbcOdbcDriver

Answer optiona

Marks: 2

what may be the output of following program

import java.sql.*;

class exp10_1
{

public static void main(String m[])throws Exception

{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:dsnname");
2 Statement cmd=con.createStatement();
ResultSetrs=cmd.executeQuery("select * from tabel1");

while(rs.next())
{
System.out.println(rs.getInt(1)+""+rs.getInt(2)+""+rs.getString(3));
}
cmd.close();
con.close();
}
}

1 123 Mahesh
A. 2 453 Suresh

B. 1 1323 1231
2 5454 4545

1 mahesh 1231
C. 2 Suresh 4545

D. None of above

Answer optiona

Marks: 2

import java.io.*;
import java.net.*;

class demo{
3 public static void main(String args[]) throws MalformedURLException{
URL a=new URL("http://www.msbte.com:/index.html");
System.out.println("port :"+a.getPort());
}
}

A. port : 80

B. 0

C. -1

D. port : -1

Answer optiond

Marks: 2
write the correct class names at blank space 1 and 2 :import java.net.*;
import java.io.*;
public class exp8_35
{
public static void main(String args[])
{
int c;
try
{
String s;
4 BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a URL: ");
s=in.readLine();
1.___________ u = new URL(s);
2.______________ uc = u.openConnection();
String ty = uc.getContentType();
System.out.println("Type: " + ty);
}
catch(Exception ae){}
}}

A. 1.URL 2.URLConnection

B. 1.URLConnection 2.URL

C. 1.URL 2.OpenConnection

D. 1.openConnection 2.URL

Answer optiona

Marks: 2

Write the missing statement in following program:import javax.swing.*;


import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class Exp12p2 extends JFrame implements ActionListener
{
String str;
ButtonGroup gp = new ButtonGroup();
JRadioButton l = new JRadioButton("Red");
JRadioButton lb = new JRadioButton("Green");
JRadioButton la = new JRadioButton("Blue");
Container ca = ___________________();
public Exp12p2()
{
ca.setLayout(new FlowLayout());
this.setSize(500,600);
this.add(l);
this.add(lb);
this.add(la);
gp.add(l);
5 gp.add(lb);
gp.add(la);
l.addActionListener(this);
la.addActionListener(this);
lb.addActionListener(this);
this.setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==l)
this.ca.setBackground(Color.RED);
else if(ae.getSource()==la)
this.ca.setBackground(Color.BLUE);
else
this.ca.setBackground(Color.GREEN);
}
public static void main(String []a)
{
Exp12p2 a1=new Exp12p2();
}
}

A. getPane()

B. ContentPane()

C. getContentPane()

D. getContent()

Answer optionc

Marks: 2
State whether given code is correct or not?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/* <applet code="app41.class" height=200 width=200></applet>*/
public class app41 extends Frame
{
public static void main(String arg[])
{
app41 obj=new app41();
obj.setSize(20,30);
obj.setVisible(true);
MenuBar mb1=new MenuBar();
obj.setMenuBar(mb1);
6 Menu Format=new Menu("Format");
Menu Tool=new Menu("Tool");
Menu Help=new Menu("Help");
mb1.add(Format);
mb1.add(Tool);
mb1.add(Help);
MenuItem mi1,mi2,mi3;
mi1=new MenuItem("font");
mi2=new MenuItem("ToolBar");
mi3=new MenuItem("View Help");
Format.add(mi1);
Tool.add(mi2);
Help.add(mi3);
}
}

A. TRUE

B. FALSE

C.

D.

Answer optiona

Marks: 2

What is the output of following program:import java.awt.*;


import java.awt.event.*;
import java.applet.*;

public class app3 extends Frame


{
public static void main(String m[])
{
7 Frame f=new Frame("BUTTON FRAME");
Button b=new Button("save");
f.add(b);
f.setSize(100,200);
f.setLayout(new FlowLayout());
f.setVisible(false);
}
}

A. It displays the frame with title BUTTON FRAME and having save Button

B. Compilation Error

C. Runtime error

D. doesn't show frame

Answer optiond

Marks: 2

8 Which of the following method throws UnknownHostException?

A. getLocalHost()

B. getByName()

C. getAllByName()

D. All of the above

Answer optiond

Marks: 2

9 Which of the following methods are needed for loading a database drivers in JDBC?

A. registerDriver() method

B. Class.forName()

C. both a and b

D. getConnection()
Answer optionc

Marks: 2

10 Which are true about the Container class?

A. The validate() is used to cause container to be laid out & redisplayed

B. The add() is used to add a component to a container

C. getComponent() is used to access a component that is contained in container

D. All of the above

Answer optiond

Marks: 2

11 To create a server socket on the specified port with a maximum queue length of maxlength which of the following constructor use?

A. ServerSocket(int port)

B. ServerSocket(int port,int maxqueue)

C. ServerSocket(int port,int maxqueue,InetAddress localaddress)

D. ServerSocket(int maxqueue)

Answer optionc

Marks: 2

12 What the method getDate() of URLConnection class returns?

A. returns time and date of response in terms of millisecond

B. returns time and date of response in terms of second

C. returns time and date of response in terms of minute

D. none of these

Answer optiona

Marks: 2

13 Which of the following is used for sending SQL statements?

A. Statement

B. CallableStatement

C. Both a and b

D. None of these

Answer optiona

Marks: 1

14 In oredr to run JSP ___________________ is required.

A. Mail Server

B. Appletviewer

C. Java Web Server

D. Database connection

Answer optionc

Marks: 1
How many controls are shown on Applet after executing
following program

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code="app2.class" height=100 width=200>
</applet>*/

public class app2 extends Applet


{

Checkbox cb1,cb2;
15 TextField tf1;
String str,str1;

public void init()


{
Label c=new Label("COLORS");
cb1=new Checkbox();
cb2=new Checkbox("WHITE");
tf1=new TextField("ABC");

add(cb1);
add(c);
add(tf1);

}
}

A. 1

B. 2

C. 3

D. 4

Answer optionc

Marks: 2

16 Which method is used to perform DML statements in JDBC?

A. execute()

B. executeUpdate()

C. executeQuery()

D. None of these

Answer optionb

Marks: 1

17 Which of the following class is used for establishing connection?

A. DriverManager

Connection
B.

C. Statement

D. ResultSet

Answer optionb

Marks: 1

18 A ScrollPane is _______________

A. Component

B. Container

C. Both a and b

D. None of these

Answer optionb

Marks: 1

19 Which of these packages contains all the event handling interfaces?

A. java.lang
B. java.awt

C. java.awt.event

D. java.event

Answer optionc

Marks: 1

20 Which of these event is generated when the component is added or removed?

A. ComponentEvent

B. ContainerEvent

C. FocusEvent

D. InputEvent

Answer optionb

Marks: 1

21 MouseEvent is subclass of which of these classes?

A. ComponentEvent

B. ContainerEvent

C. ItemEvent

D. InputEvent

Answer optiond

Marks: 1

22 Name the method defined in EventObject class that returns the Object generated from the event.select the one correct answer.

A. getEvent()

B. getObject()

C. getID()

D. getSource()

Answer optiond

Marks: 1

23 Which of the following is the immidiate superclass of the MenuComponent class?

A. Object

B. Menu

C. EventObject

D. Component

Answer optiona

Marks: 1

24 How do you change the current layout managers for a container?

A. Use the setLayout method

B. once created you can not change the current layout manager

C. Use the setLayoutManager method

D. Use the UpdateLayout method

Answer optiona

Marks: 1

25 Which TextComponent method is used to set a TextComponent to the read-only state?


A. Editable

B. NonEditable

C. setEchoChar

D. setEditable

Answer optiond

Marks: 1

26 which Container use a Border Layout as their default layout?

A. Window

B. Frame

C. Dialog

D. All of the above

Answer optiond

Marks: 1

27 Choose the incorrect statement.

A. BorderLayout b = new BorderLayout(3,4);

B. Label name = new Label("Name:");

C. m.setMenuBar(mbr);

D. DefaultMutableTreeNode top = new DefaultMutableTreeNode("Options");

Answer optiona

Marks: 1

28 Which of these methods can be used to know the degree of adjustment made by the user?

A. getValue()

B. getAdjustmentType()

C. getAdjustmentValue()

D. getAdjustmentAmount()

Answer optiona

Marks: 1

29 What does the openConnection() method of java.net.* return?

A. Internet Address of localhost

B. Object of URLConnection class

C. URL object

D. Properties of URL

Answer optionb

Marks: 1

30 byte[] getData() method of DatagramPacket class returns______________________

A. Internet address of localhost

B. Socket connection with the local host

C. Sends the packet of data contained in datagram

D. Byte array of data contained in datagram

Answer optiond

Marks: 1
What will be displayed in the output?
import java.net.*;
class myAddress
{
public static void main (String args[])
{
try
{
31 InetAddress address = InetAddress.getLocalHost();
System.out.println(address);
}
catch (UnknownHostException e)
{
System.out.println("Could not find this computer's address.");
}
}
}

A. The internet address of the server

B. The internet address of the client

C. The internet address of the host

D. The internet address of any other PC

Answer optionc

Marks: 1

32 select proper syntax for getInputStream method

A. InputStream getInputStream()

B. String getInputStream()

C. void getInputStream()

D. InputStream getInputStream(String str[])

Answer optiona

Marks: 1

33 How can you retrieve information from a ResultSet?

A. By invoking the method get(..., String type) on the ResultSet, where type is the database type

B. By invoking the method get(..., Type type) on the ResultSet, where Type is an object which represents a database

C. By invoking the method getValue(...), and cast the result to the desired Java type.

D. By invoking the special getter methods on the ResultSet: getString(...), getBoolean (...), getInt(…)

Answer optiond

Marks: 1

34 Choose the correct syntax for getConnection() method

A. public static Connection getConnection(String url, String password) throws SQLException

B. public static Connection getConnection(String name, String password) throws SQLException

C. public static Connection getConnection(String url, String name, String password) throws SQLException

D. public static Connection getConnection(String url, String name) throws SQLException

Answer optionc

Marks: 1

35 Which class/ interface is used for an SQL statement that is executed frequently?

Statement
A.

B. Callable statement

C. PreparedStatement

D. None of the above

Answer optionc

Marks: 1
Which of the following correctly represents the following JSP statement.
36 <%=x%>

A. <jsp:expression=x/>

B. <jsp:expression>x</jsp:expression>

C. <jsp:statement>x</jsp:statement>

D. <jsp:declaration>x</jsp:declaration>

Answer optionb

Marks: 1

What is the use of panel in the program given below


import java.awt.*;
import java.applet.*;
public class Demo5 extends Applet
{
public void init()
{
setLayout(new BorderLayout());
Panel p1=new Panel();
Panel p2=new Panel();

p1.setLayout(new FlowLayout());
p1.add(new TextField(20));
p1.add(new TextField(20));
37
p2.setLayout(new GridLayout(5,3));
p2.add(new Button("OK"));
p2.add(new Button("Submit"));

add(p1,BorderLayout.EAST);
add(p2,BorderLayout.WEST);
}
}
/*<applet code=Demo5.class width=300

height=400>
</applet>
*/

A. Panels contain textfields and buttons

B. Panel is used to assign layout to appletviewer window

C. The appletviewer window is divided into two parts using two panels so that different layouts can be assigned to the two parts.

D. None of the above

Answer optionc

Marks: 2

Find the missing statement from the following program. import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
/*
<applet code="ctest" width=300 height=100>
</applet>
*/
public class ctest extends JApplet
{
38 public void init()
{
Container co = getContentPane();
co.setLayout(new FlowLayout());
JComboBox jc=new JComboBox();
jc.addItem("cricket");
jc.addItem("football");
jc.addItem("hockey");
jc.addItem("tennis");
}
}

A. Missing semicolon

B. Missing contentpane

C. mising import statement

D. Missing add statement

Answer optiond

Marks: 2
What will be the output of the program given below import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code = sample4.class width = 400 height = 400></applet>*/
public class sample4 extends Applet implements MouseListener
{
Font f;
int i=0,c=14;
public void init()
{
f=new Font("Times New Roman",Font.BOLD,c);
setFont(f);
addMouseListener(this);
}
public void mousePressed(MouseEvent me)
{
39 if(i<10)
{
c=c+2;
f=new Font("Times New Roman",Font.BOLD,c);
setFont(f);
}
i=i+1;
}
public void mouseClicked(MouseEvent me) {}
public void mouseReleased(MouseEvent me) {}
public void mouseEntered(MouseEvent me) {}
public void mouseExited(MouseEvent me) {}
public void paint(Graphics g)
{
g.drawString("Advanced Java programming",50,50);
}
}

A. The output will display the string "Advanced Java Programming" in appletviewer window.

B. The output will display the string "Advanced Java Programming" in appletviewer window. The size of the string will increase by two points with every mouse

C. None of the above

D. The program will not compile.

Answer optionb

Marks: 2

40 Select the correct combination

A. Button - ItemEvent Checkbox - adjustmentEvent

B. Button - AdjustmentEvent Checkbox - ItemEvent

C. Button - ActionEvent Checkbox - ItemEvent

D. Button - MouseEvent Checkbox - ActionEvent

Answer optionc

Marks: 2

41 Select the correct code for the output shown

import java.awt.*;
import java.applet.*;
public class app1 extends Applet
{
public void init()
{
TextField tf = new TextField();
A. TextArea t1=new TextArea(3,20);
Checkbox c=new Checkbox("a",true);
Checkbox c1=new Checkbox("b",true);
add(tf);
add(t1);
add(c);
add(c1);
}

import java.awt.*;
import java.applet.*;
public class app1 extends Applet
{
public void init()
{
TextField tf = new TextField();
TextArea t1=new TextArea(3,20);
B. Checkbox c=new Checkbox("a",false);
Checkbox c1=new Checkbox("b",false);
add(tf);
add(t1);
add(c);
add(c1);
}
}
import java.awt.*;
import java.applet.*;
public class app1 extends Applet
{
public void init()
{
TextField tf = new TextField();
C. TextArea t1=new TextArea(3,20);
Checkbox c=new Checkbox("a",true);
Checkbox c1=new Checkbox("b",false);
add(tf);
add(t1);
add(c);
add(c1);
}

D. None of the above

Answer optionc

Marks: 2

42 Which of the following is not a factory method of InetAddress class

A. static InetAddress getLocalHost() throws UnknownHostException

B. static InetAddress getByName() throws UnknownHostException

C. static InetAddress getAllByName() throws UnknownHostException

D. static InetAddress getAllLocalHost() throws UnknownHostException

Answer optiond

Marks: 2

43 IPv6 uses _____________

A. Four groups of 8 bits each

B. Four groups of eight hexadecimal digits

C. Eight groups of four digits each

D. Eight groups of four� hexadecimal� digits� each

Answer optiond

Marks: 2

Rearrange the steps to connect to the database in SQL


a. Create the connection object
b. Execute the query
44 c. Close the connection object
d. Register the driver class
e. Create the statement object

A. � a-b-c-d-e

B. d-a-e-b-c

C. e-d-c-b-a

D. d-a-c-b-e

Answer optionb

Marks: 2

45 Identify correct syntax of service() method of servlet class

A. void service(ServletRequest req, ServletResponse res)

B. void service( ServletResponse res ServletRequest req )

C. void service(ServletRequest req, ServletRequest req )

D. void service(ServletResponse req, ServletResponse res)

Answer optiona

Marks: 2

Observe the image shown below.


46 Which AWT component will the image as shown

A. ComboBox
B. Checkbox

C. CheckboxGroup

D. None of the above

Answer optionc

Marks: 2

47 To get the actual character of (" ?" )of password textbox which method is used in given below output?

A. setText('?')

B. getText()

C. getEchoChar('?')

D. setEchoChar('?')

Answer optionb

Marks: 2

48 How to add image on button

ImageIcon ii = new ImageIcon(“India.gif”);


A. JButton Jb= new JButton(“ok”,ii);

ImageIcon i = new ImageIcon(“India.gif”);


B. JLabelJb= new JLabel(“ok”,ii);

C. Button b= new Button (‘.gif”);

D. JButton b1= new JButton (“Exit”,”.jpeg);

Answer optiona

Marks: 2

49 Identify the layout of the image .

A. Card Layout

B. Box ayout

C. Border Layout

D. Grid Layout

Answer optionc

Marks: 2

The following program will increase the font size of a given string by 2 point with every mouse click(max 10 clicks). Select the
missing statement and indicate where the statement should be added. import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class sample4 extends Applet implements MouseListener
{
Font f;
int i=0,c=14;
public void init()
{
f=new Font("Times New Roman",Font.BOLD,c);
setFont(f);
}
public void mousePressed(MouseEvent me)
{
if(i<10)
50 {
c=c+2;
f=new Font("Times New Roman",Font.BOLD,c);
setFont(f);
}
i=i+1;
}
public void mouseClicked(MouseEvent me) {}
public void mouseReleased(MouseEvent me) {}
public void mouseEntered(MouseEvent me) {}
public void mouseExited(MouseEvent me) {}
public void paint(Graphics g)
{
g.drawString("Java prog",50,50);
}
}

A. addMouseMotionListener(this); in the init() method

B. addMouseMotionListener(this); outside the init() method


C. addMouseListener(this); outside the init() method

D. addMouseListener(this); inside the init() method

Answer optiond

Marks: 2

The following program contains some errors. Select the correct option to indicate them.
import java.awt.*;
import java.awt.event.*;
import java.applet.*; /*<applet code="exp.class"
height=200 width=300>
</applet>*/
public class exp extends Applet implements AdjustmentListener
{
Scrollbar sbr,sbg,sbb;
public void init()
{
sbr=new Scrollbar(Scrollbar.VERTICAL,0,1,0,255);
sbg=new Scrollbar(Scrollbar.VERTICAL,0,1,0,255);
sbb=new Scrollbar(Scrollbar.VERTICAL,0,1,0,255);
add(sbr);
add(sbg);
51 add(sbb);
sbr.addAdjustmentListener(this);
sbg.addAdjustmentListener(this);
sbb.addAdjustmentListener(this);
}
public void actionPerformed(AdjustmentEvent ae)
{
Color c;
int red,green,blue;
red=sbr.getValue();
green=sbg.getValue();
blue=sbb.getValue();
c=new Color(red,green,blue);
setBackground(c);
}
}

A. Missing Listener Statement

B. Incorrect Listener method

C. Incorrect declaration of Variables

D. None of the above

Answer optionb

Marks: 2

52 1. Choose the correct option to establish a connection to database named student and display its contents.

import java.sql.*;
class OracleCon{
public static void main(String args[])throws Exception
{
try{

Class.forName("oracle.jdbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle");

Statement stmt=con.createStatement();

A.
ResultSet rs=stmt.executeQuery("select * from student");
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));

con.close();

}
catch(Exception e)
{
System.out.println(e);
}

}
}

B. static InetAddress[ ] getAllByName(String hostName)

import java.sql.*;
class Ddemo1
{
public static void main(String args[]) throws Exception
{
C. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
Result rs=s.executeQuery("Insert into table STUDENT");
}
import java.sql.*;
class Ddemo1
{
public static void main(String args[]) throws Exception
D. {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
ResultSet rs=s.executeQuery("select * from stud");
}

Answer optiona

Marks: 2

53 Choose the correct syntax of creating query to read records with salary > 10000

A. select record from employee where salary >10000

B. select *** from employee where salary >10000

C. select * from employee where salary >10000

D. select record * from employee where salary >10000

Answer optionc

Marks: 2

What is the return value from


54 stmt.executeQuery("insert into T values (100, 'Smith')")

A. An int value indicating how many rows are effected from the invocation

B. void

C. An object that contains the status of the execution

D. ResultSet object

Answer optiond

Marks: 2

55 Which of the following methods can be used to change the size of a java.awt.Component object?

A. dimension()

B. setSize()

C. area()

D. size()

Answer optionb

Marks: 1

56 To create window with title bar which of the following class is used?

A. Frame

B. Applet

Panel
C.

D. None of these

Answer optiona

Marks: 1

57 Which class of java.net package can be used to find the host name and IP address of the client.

A. The Socket class

B. The serverSocket class

C. The Connection Interface

D. The InetAddress class

Answer optiond

Marks: 1
58 JDBC is a --------------------- interface, which means that it is used to invoke SQL commands directly.

A. low level

B. middle level

C. high level

D. user

Answer optiona

Marks: 1

59 ODBC minimum SQL grammar contains

A. stored procedure

B. date ,time and time stamp only

C. CREATE or Drop view

D. INSERT, UPDATE ,DELETE ONLY

Answer optiond

Marks: 1

60 Which metod allows the client to send data of unlimited length to the web pageserver a single time.

A. doGet()

B. doPost()

C. doPut()

D. doHead()

Answer optionb

Marks: 1

Find the missing statement.


import javax.swing.*;

class MyFrame extends JFrame {


public MyFrame() {
setTitle("My Empty Frame");
setSize(300,200);
61 setLocation(10,200);
}

JFrame f = new MyFrame();


f.show();

A. None

B. MyFrame()

C. public static void main(String[] args)

D. import javax.swing

Answer optionc

Marks: 2

62 Which statement allows the button named click to react to a mouse click?

A. click.ActionListener(this)

B. click.ActionListener()

C. click.addActionListener(this)

D. click.addActionListener()

Answer optionc

Marks: 2

63 To access the URLConnection Class object which of the transfer protocol is used?

A. ftp
B. URL

C. http

D. None Of The Above

Answer optionc

Marks: 2

64 The service phase of the servlet life cycle represents all interactions with requests until the servlet is ......................

A. created

B. running

C. initiated

D. destroyed

Answer optiond

Marks: 2

An Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to change to another Layout
65 Manager?

A. setLayoutManager(new GridLayout());

B. setLayout(new GridLayout(2,2));

C. setGridLayout(2,2);

D. setBorderLayout();

Answer optionb

Marks: 2

Select the missing statement in the program for following output


import java.awt.*;
public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
Menu filemenu = new Menu("File");
66
Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
MenuItem new1 = new MenuItem("New");
MenuItem open1 = new MenuItem("Open");
filemenu.add(new1);
filemenu.add(open1);
}
}

A. mbr.add(view);

B. mbr.add(menu);

C. mbr.add(vieweditmenu);

D. mbr.add(viewmenu);

Answer optiond

Marks: 2

67 Some of the event listener interfaces are_____________

A. ActionListener, ComponentListener

B. ContainerListener, FocusListener

C. WindowListener, MouseListener

D. All of these

Answer optiond

Marks: 2
Consider the following program
Select the statement that should be added to the program to get correct
output.

import java.sql.*;

public class JdbcOdbc {


public static void main(String args[]) {

try {
Connection con;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:datastud");
try {
System.out.println("Getting All Rows from a table!");
Statement st = con.createStatement();
ResultSet res =---------------------------("SELECT * FROM college");
68 System.out.println("student_code: " + "\t" + "student_name: ");
while (res.next()) {
int i = res.getInt("stud_code");
String s = res.getString("stud_name");
System.out.println(i + "\t\t" + s);
}
con.close();
} catch (SQLException s) {
System.out.println("SQL code does not execute.");
}
} catch (Exception e) {
System.out.println("Error:connection not created");
}

A. st.createStatement( )

B. st.executeUpdate()

C. st.executeQuery()

D. res.executeQuery()

Answer optionc

Marks: 2

Choose missing statements in following code from given options.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class MyServlet extends HttpServlet {

public void doGet(HttpServletRequest request,


HttpServletResponse response)

{
69 response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>");
out.println("Servlet");
out.println("</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<H1>Hello servlet</H1>");
out.println("</BODY>");
out.println("</HTML>");
}
}

A. throws IOException, ServletException

B. class can not be declared as public

C. Syntax of init method is wrong

D. noe

Answer optiona

Marks: 2

70 Choose the correct syntax of directive

A. <%@ directive_name %>

B. <% directive_name %>

C. <%@ directive_name @%>

D. None
Answer optiona

Marks: 1

The Java __________ specification defines an application programming interface for communication between the Web server and the
71 application program.

A. Servlet

B. Server

C. Program

D. Randomize

Answer optiona

Marks: 2

72 Which componant canot be added to a container?

A. JPanel

B. JButton

C. JComponent

D. JFrame

Answer optiond

Marks: 1

73 Which of the following are not swing componant?

A. Button

B. Textfield

C. Jcomponant

D. both a & b

Answer optiond

Marks: 1

74 Which of the following is not true about TCP Socket?

A. Socket is inteface between application layer and transport layer

B. Socket resembles electrical socket

C. There is socket at both server and client side.

D. Socket is not used to create connection between client and server

Answer optiond

Marks: 1

75 UDP is not __________oriented protocol.

A. Connection

B. Connectionless

C. string

D. message

Answer optiona

Marks: 1

76 What is bytecode?

A. jave source code

B. Machine Independent code

C. Machine specific code


D. None of these

Answer optionb

Marks: 1

77 Which is componant in AWT which contain another componant?

A. Window

B. Panel

C. Frame

D. Container

Answer optiond

Marks: 2

78 The _________ interface handles list event?

A. ContainerListener

B. ItemListener

C. ActionListener

D. FocusListener

Answer optionb

Marks: 2

79 Java.net package consist of interface_____________

A. ContentHandlerFactory

B. SocketImplFactory

C. FileNameMap and URLStreamHandlerFactory.

D. All of above

Answer optiond

Marks: 2

80 ���������.method of datagram packet is used to find the port number.

A. port()

B. getPort()

C. GetPort()

D. findPort()

Answer optionb

Marks: 2

81 ����...is first phase of servlet life cycle.

A. intitialization

B. Service

C. Destruction

D. Non of thsese

Answer optiona

Marks: 2

82 To creat panel of borderlayout use_________

A. Jpanel p=new Jpanel()

B. Jpanel p=new Jpanel(BorderLayout())


C. Jpanel p=new Jpanel(new BorderLayout())

D. Jpanel p=new Jpanel().setLayout(new BorderLayout())

Answer optionc

Marks: 2

83 _______________method can be used to change location of event

A. ChangePoint()

B. TranslatePoint()

C. ChangeCoordinates()

D. TranslateCoordinates()

Answer optionb

Marks: 2

84 ______________is used to obtained the object that generate Window event

A. getMethod()

B. getWindow()

C. getWindowEvent()

D. getWindowObject()

Answer optionb

Marks: 2

85 An event is generated when internal stae of event source is________

A. Not change

B. changed

C. Either change or not

D. None of these

Answer optionb

Marks: 2

Consider the following program


Which package should be added to the program to get corret code?.
public class db15
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:Mybm","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
Statement s=c.createStatement( );
86 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.getDouble(3));
}
s.close();
c.close();
}
}

A. java.net

B. java.sql.*

C. java.oracle.*

D. java.util

Answer optionb

Marks: 2

87 Which one method is used to set the visibility of the frame?

A. setVisible(true)
B. setVisible()

C. setVisible(false)

D. none

Answer optiona

Marks: 1

88 Which are various AWT controls from following?

A. Labels, Push buttons, Check boxes, Choice lists.

B. Text components, Threads, Strings, Servelts, Vectors

C. Labels, Strings, JSP, Netbeans, Sockets

D. Push buttons, Servelts, Notepad, JSP

Answer optiona

Marks: 1

89 JPanel and Applet use ___________________ as their default layout

A. FlowLayout

B. GridLayout

C. BorderLayout

D. GridBagLayout

Answer optiona

Marks: 1

90 Which of the following component class cannot be add on applet

A. Button

B. Checkbox

C. Menu

D. ScrollBar

Answer optionc

Marks: 1

91 Which of these method cannot be called on JLabel object?

A. setIcon()

B. getText()

C. setLabel()

D. setBorderLayout()

Answer optiond

Marks: 1

92 Which of these events is generated when the a window is closed?

A. TextEvent

B. MouseEvent

C. FocusEvent

D. WindowEvent

Answer optiond

Marks: 1

93 Which of these package contains classes and interfaces for networking?


A. java.io

B. java.util

C. java.net

D. java.network

Answer optionc

Marks: 1

94 The JDBC �ODBC Bridge is________

A. Multithreaded

B. Singlethreaded

C. Both of above

D. None of above

Answer optiona

Marks: 1

95 What JSP Stands for______

A. Java server pages

B. a.Java server programming

C. a.Java service programming

D. a.Java servvice pages

Answer optiona

Marks: 1

96 The Jtable used to display data in form of?

A. JTable object displays columns of data

B. JTable object displays rows and columns of data.

C. JTable object displays rows of data.

D. JTable object displays data in Tree form.

Answer optionb

Marks: 2

97 Which method is used to display icon on a Button?

A. rollOverIcon(ImageIcon i)

B. setIcon(ImageIcon i)

C. displayIcon(ImageIcon i)

D. removeIcon (ImageIconi )

Answer optionb

Marks: 2

98 4.To create a Following output which control is required.

A. Label, TextField, Button

B. Label, Button

C. Label, Button ,CheckBox

D. 2 Label, 1 Button

Answer optiond

Marks: 2
99 __________________returns the time at which event took place

A. getType()

B. getSource()

C. getEventType()

D. getWhen()

Answer optiond

Marks: 2

100 Which Exception is thrown by DatagramSocket class constructor

A. IoException

B. UnkownHostException

C. SocketException

D. None of above

Answer optionc

Marks: 2

101 Select the proper method to retrieve the host name and IP Address of local machine

A. static InetAddress getLocalHost( )throws UnknownHostException

static InetAddress getByName(String hostName)throws UnknownHostException


B.
WQ

C. string getHostAddress()

D. static InetAddress[ ] getAllByName(String hostname) throws UnknownHostException

Answer optiona

Marks: 2

102 How will JDBC help the programmers to write java applications that manage programming activities:

A. It helps us to connect to a data source, like a database.

B. It helps us in sending queries and updating statements to the database

C. Retrieving and processing the results received from the database in terms of answering to your query.

D. All of Above

Answer optiond

Marks: 2

103 ReslutSetMetaData Interface Object created by ______________ method, of ____________ interface

A. getMetaData(), ResultSet

B. getMetaData(), Statement interface

C. getResultSet(), PreparedStatement interface

D. getMetaData(), DatabaseMetaData interface

Answer optiona

Marks: 2

104 getConnection() method have which parameters: _____________________

A. URL -JdbclOdbc:DSN ,String Username, String Password

B. URL -OdbclJdbc:DSN

C. Both A and B

D. None of Above

Answer optiona
Marks: 1

105 3.What servlet processor was developed by Apache Foundation and Sun?

A. Apache Tomcat

B. Apache Web server

C. Sun servlet processor

D. None of the above is correct.

Answer optiona

Marks: 2

3. Select the proper command to run the following code import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
/*
<applet code="combodemo11" width=300 height=100>
</applet>
*/
public class combodemo11 extends JApplet
{
public void init()
106 {
Container co = getContentPane();
co.setLayout(new FlowLayout());
JComboBoxjc=new JComboBox();
jc.addItem("cricket");
jc.addItem("football");
jc.addItem("hockey");
jc.addItem("tennis");
co.add(jc);
}
}

A. javac combodemo11.java

B. java combodemo11

C. appletviewer combodemo11.java

D. All of above

Answer optionc

Marks: 2

Which line of code is missing in following code


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="KeyEventDemo.class" width=400 height=400>
</applet>*/
public class KeyEventDemo extends Applet implements KeyListener
{
String msg="";
public void init()
{
addKeyListener(this);
}
public void keyPressed(KeyEvent e)
107 {
showStatus("Key Down");
int key=e.getKeyCode();
repaint();
}
public void keyTyped(KeyEvent e)
{
msg+=e.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,10,20);
}
}

public void keyShow(KeyEvent e)


{
A. showStatus("Key up");
}

public void keyReleased(KeyEvent e)


{
B. showStatus("Key up");
}

public void keyMoved(KeyEvent e)


{
C. showStatus("Key up");
}

D. None of this
Answer optionb

Marks: 2

For the following code select the method that can be used to handle event.
importjava.awt.event.*;
import java.awt.*;
importjava.applet.*;
public class checkbackg extends Applet implements ItemListener
{
Checkbox m1,m2,m3;
public void init()
{
m1=new Checkbox("A");
m2=new Checkbox("B");
m3=new Checkbox("C");
add(m1);
add(m2);
108 add(m3);
m1.addItemListener(this);
m2.addItemListener(this);
}
public void __________________(ItemEvent ie)
{
if(ie.getSource()==m1)
setBackground(Color.red);
if(ie.getSource()==m2)
setBackground(Color.green);
}
}
/*<applet code=checkbackg.class height=150 width=150>
</applet>*/

A. actionPerformed(ActionEvent ae)

B. itemStateChanged(ActionEvent ie)

C. itemStateChanged(ItemEvent ie)

D. adjustmentPerformed(AdjustmentEvent ae)

Answer optionc

Marks: 2

109 Which Event is /are handdled on List Component

A. ItemEvent

B. ActionEvent

C. Both A and B

Any of one depends on single click and double click


D.

Answer optiond

Marks: 2

What will happen when you attempt to compile and run the following code?
import java.awt.*;
import java.awt.event.*;
public class MClick extends Frame implements MouseListener
{
public static void main(String argv[])
{
MClick s = new MClick();
}
110 MClick()
{
this.addMouseListener(this);
}

public void mouseClicked(MouseEvent e)


{
System.out.println(e.getWhen());
}
}

A. Compile time error

B. Run time error

C. Compile and at runtime the date and time of each click will be output

D. Compile and at runtime a timestamp will be output for each click

Answer optiona

Marks: 2
5. Which statement is incorrect or missing in the following code

import java.awt.*;
import java.awt.event*;
import javax.swing.*;
public class radio extends JApplet implements ActionListener
{
pulic void init()
{
c.setLayout(new FlowLayout());
JRadioButton b1=new JRadioButton("Red");
b1.addActionListener(this);
c.add(b1);

JRadioButton b2=new JRadioButton("Green");


111 b2.addActionListener(this);
c.add(b2);

JRadioButton b3=new JRadioButton("Blue");


b3.addActionListener(this);
c.add(b3);
ButtonGroup bg=new ButtonGroup();
bg.add(b1);
bg.add(b2);
bg.add(b3);
}
public void actionPerformed(ActionEvent e){
setBackground(e.getActionCommand());
}
}

A. There should ItemListener implemented instead of ActionListener

B. Container c=getContentPane();

C. Both A and B

D. None of Above

Answer optionb

Marks: 2

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
{
112 URL url = new URL("http://www.msbte.com/download");
System.out.println("Protocol:"+ url1.getProtocol());
System.out.println("Port:"+ url1.getPort());
System.out.println("Host:"+ url1.getHost());
System.out.println("File:"+ url1.getFile());
}
}

A. Exception type is wrong.

B. Class should not be public.

C. Creation of object is not correct.

D. Use of created object not correct

Answer optiond

Marks: 2

Which Statement is missing in following code

import java.net.*;
public class InetAddressExample
{
public static void main(String arg[])
{
try
113 {
System.out.println("CTE:"+ad);
System.out.println("CTE:"+ad.getHostAddress());
System.out.println("CTE:"+ad.getHostName());
}
catch(UnknownHostException e)
{}
}
}

InetAddress ad=InetAddress.getByName("localhost");
A.

B. URL ad=InetAddress.getByName();

C. URLConnection ad=InetAddress.getByName();

D. InetAddress ad=getByName();

Answer optiona
Marks: 2

Which statement should be correct for displaying the correct out put?

import javax.swing.*;
import java.io.*;

class dataM
{
public static void main(String a[])
{
String type[]={�TABLE�,�View�};
try
{
Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver�);
Connection con =DriverManager.getConnection("Jdbc:Odbc:xxx");
Statement s=con.createStatement();

DatabaseMetaData md=rs.getMetaData();

System.out.println("Database is:�+md.getDatabaseProductName() );
System.out.println("SQL Keywords is:�+md.getSQLKeywords());
114
ResultSet rs=md.getTables(null,null,null,types);

While(rs.next())
{
String to=rs.getString(2);
String tn=rs.getString(3);
String tt=rs.getString(4);

System.out.println(to+� �+tn+� � +tt+� �);


}

con.close();
}

catch()
{
System.out.println(e);
}
}
}

A. package import

B. Import Package and catch() Statement

C. catch() Statement

D. none of above

Answer optionb

Marks: 2

2. In following Java program fill statement showing ***.Select any one option fro given options

import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
115 String data = request.getParameter("data");
Cookie cookie = ***************
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. new Cookie("MyCookie", dat;

B. new Cookie("MyCookie", data);

C. new Cookie("MyCookie", data2);

D. new Cookie("MyCookie", database);

Answer optionb

Marks: 2

___________this packege responssible for following code


Date date = (Date)hs.getAttribute("date");
if(date != null) {
116 pw.print("Last access: " + date + "<br>");
}
date = new Date();

A. Import java.awt.*; package

B. Import java.util.*; package


C. Import java.Date.*; package

D. Import java.awt.event.*; package

Answer optionb

Marks: 2

Which Statement have error in following code


importjava.sql.*;
import java.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
public class p155 extends Servlet{
public void service(HttpServletRequest request,HttpServletResponse response)throws IOException{
PrintWriter z=response.getWriter();
response.setContentType("text/html");
try{
String x=request.getParameter("username");
String y=request.getParameter("password");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:kmps");
Statement stat=conn.createStatement();
ResultSetrs=stat.executeQuery("select * from kmps where username=��+x+��and password=��+y+��);
If (rs.next()==false){
z.println("<html><body><br>");
z.println("<center><b>Authentication Failure</b>");
z.println("<br><br>");
117 z.println("<h3>Try Again</h3></center>");
z.println("<br><br><br>");
z.println("</body></html>");
}
Else{
z.println("<html><body>");
z.println("<br><br>");
z.println("<center><b>"+�Hello�+rs.getString(�username�)+�</b>�);
z.println("<h3>You can Proceed</h3><center>");
z.println("<br><br><br>");
z.println("</body></html>");
}
Conn.close();
stat.close();
}
Catch(Exception e){
System.out.println(�The error has been occurred�+e.getMessage());
}
}
}

A. While Creating Connection object

B. While setting the content type

C. While extending Servlet

D. None of above

Answer optionc

Marks: 2

118 On which side applet always executed?

A. Server side

B. Client side

C. Both

D. None

Answer optionb

Marks: 1

119 Font class is available in ___________

A. java.io package

B. java.lang package

C. java.awt package

D. java.util package

Answer optionc

Marks: 1

120 Which layout example is this?

A. BorderLayout
B. FlowLayout

C. Grid layout

D. CardLayout

Answer optionb

Marks: 2

121 Which of these is a protocol for breaking and sending packets to an address across a network?

A. TCIP/IP

B. b) DNS

C. c) Socket

D. d) Proxy Server

Answer optiona

Marks: 2

122 which interfaces provide methods for batch processing in JDBC

A. � java.sql.Statement�

B. java.sql.PreparedStatement

C. Both A & B

D. None of the above

Answer optionc

Marks: 2

123 Which of these statements are false about GenericServlet?

A. Generic Servlet is an abtract class

B. A GenericServlet has a service() method to handle requests.

C. Genric Servlet extends HttpServlet and override doGet() method

D. Generic servlet implements Servlet Interface and over-rides life-cycle method

Answer optionc

Marks: 2

For the following code select the method that can be used to handle event.
importjava.awt.event.*;
import java.awt.*;
importjava.applet.*;
public class checkbackg extends Applet implements ItemListener
{
Checkbox m1,m2,m3;
public void init()
{
m1=new Checkbox("A");
m2=new Checkbox("B");
m3=new Checkbox("C");
add(m1);
add(m2);
124 add(m3);
m1.addItemListener(this);
m2.addItemListener(this);
}
public void __________________
{
if(ie.getSource()==m1)
setBackground(Color.red);
if(ie.getSource()==m2)
setBackground(Color.green);
}
}
/*<applet code=checkbackg.class height=150 width=150>
</applet>*/

A. A. actionPerformed(ActionEvent ae)

B. B. itemStateChanged(ActionEvent ie)

C. C. itemStateChanged(ItemEvent ie)

D. D. adjustmentPerformed(AdjustmentEvent ae)
Answer optionc

Marks: 2

Which statement is incorrect or missing in the following code

import java.awt.*;
import java.awt.event*;
import javax.swing.*;
public class radio extends JApplet implements _____________
{
pulic void init()
{
c.setLayout(new FlowLayout());
JRadioButton b1=new JRadioButton("Red");
b1.addActionListener(this);
c.add(b1);

JRadioButton b2=new JRadioButton("Green");


125 b2.addActionListener(this);
c.add(b2);

JRadioButton b3=new JRadioButton("Blue");


b3.addActionListener(this);
c.add(b3);
ButtonGroup bg=______________;
bg.add(b1);
bg.add(b2);
bg.add(b3);
}
public voidactionPerformed(ActionEvent e){
setBackground(e.getActionCommand());
}
}

A. ActionListener, new ButtonGroup();

B. Container c=getContentPane();

C. Both A and B

D. ItemListener, new Button();

Answer optionc

Marks: 2

while(rs.next())
{
String n=rs.getString("name");
System.out.println("name:"+n);
126 String n1=rs.getString("rollnumber");
System.out.println("rollnumber:"+n1);
}

What does the above code do?

A. A. Display Record

B. B. create connection

C. C. prepare the statement object

D. D. none of the above

Answer optiond

Marks: 2

Select the correct option for fill in the blank


import java.sql.*;
class data
{
public static void main(String a[])
{
try
{
Driver d= new sun.jdbc.odbc.JdbcOdbcDriver();
DriverManager.registerDriver(d);
Connection con =DriverManager.getConnection("Jdbc:Odbc:_____________________");
Statement s=_____________________________
int n=s.executeUpdate("Insert into Table1 values('hhh',12)");
127
if(n==1)
{
System.out.println("Record inserted ");
con.close();
}
}
catch(Exception e)
{
System.out.println("not Inserted"+e);
}
}
}

A. DSN name and con.callableStatement();

B. DSN name and con.createStatement();


C. Table name and con.preparedStatement();

D. DNS name and con.createStatement();

Answer optionb

Marks: 2

Select the correct option for fill in the blank


import java.sql.*;
class data
{
public static void main(String a[])
{
128 Driver d= new sun.jdbc.odbc.JdbcOdbcDriver();
DriverManager.registerDriver(d);
Connection con =DriverManager.getConnection("Jdbc:Odbc:UUU");
_____________________________________________
}
}

A. PreparedStatement ps=con.prepareStatement("Select * from table1");

B. PrepareStatement ps=con.preparedCall();

C. Prepare ps=con.preparedCall("Select * from table1");

D. PreparedCall ps=con.preparedStatement("Select * from table1");

Answer optiona

Marks: 2

Which statement create an error


import java.sql.*;
class data
{
public static void main(String a[]) throws Exception
{
129 Driver d= new Driver();
DriverManager.registerDriver(d);
Connection con =DriverManager.getConnection("Jdbc:Odbc:XXX");
Statement s=con.createStatement();
}
}

A. while createing connection object

B. while creating Driver object

C. While registering Driver

D. none of this

Answer optionb

Marks: 2

130 Which are the Alignment Constant of Label ?

A. Label.LEFT

B. Label.RIGHT

C. Label.CENTER

D. All The Above

Answer optiond

Marks: 1

131 What are the TextCompoent ?

A. ListBox ,CheckBox

B. TextBox , List

C. TextField , TextArea

D. Choice ,Text

Answer optionc

Marks: 1

132 What Are The Types of Dialogbox ?


A. modal DialogBox

B. modal and Modeless Dialogbox

C. Modem

D. None of the above

Answer optionb

Marks: 1

133 How To Apply Image To Button ?

A. Using Label

B. Using ImageIcon

C. Using Text

D. Using SrollBar

Answer optionb

Marks: 1

134 ActionEvent Class is used for Which Control ?

A. Button , List ,MenuItem

B. CheckBox

C. RadioButton

D. ScrollBar

Answer optiona

Marks: 1

135 Which of the following method is used to return the mouse co-ordinates?

A. getX () ,getY()

B. GETXY ()

C. get ()

D. get xz()

Answer optiona

Marks: 1

136 Which integer constants are defined by WindowEvent?

A. WINDOW_ACTIVATED

B. WINDOW_CLOSING

C. WINDOW_DEACTIVATED

D. All The Above

Answer optiond

Marks: 1

137 Native � protocol pure Java converts ���.. in to the ���� used by DBMSs directly.

A. JDBC calls, network protocol

B. ODBC class, network protocol

C. ODBC class, user call

D. JDBC calls, user call

Answer optiona

Marks: 1
138 What is use of GridLayout Manager ?

A. lays out components in a two-dimensional grid

B. four sides are referred to as north, south, east, and west

C. ListBox ,CheckBox

D. CheckBox

Answer optiona

Marks: 2

Select the missing statement in given code import java.awt.*;


import java.awt.event.*;
import java.applet.*;
/*
<applet code="ChoiceDemo" width=300 height=180> </applet>
*/

public class ChoiceDemo extends Applet implements ItemListener {


Choice os, browser;
String msg = "";

public void init() {

// add items to os list


os.add("Windows 98/XP");
os.add("Windows NT/2000");
os.add("Solaris");
os.add("MacOS");

// add items to browser list


browser.add("Netscape 3.x");
browser.add("Netscape 4.x");
browser.add("Netscape 5.x");
browser.add("Netscape 6.x");

browser.add("Internet Explorer 4.0");


139 browser.add("Internet Explorer 5.0");
browser.add("Internet Explorer 6.0");

browser.add("Lynx 2.4");

browser.select("Netscape 4.x");
// add choice lists to window
add(os);
add(browser);

// register to receive item events


os.addItemListener(this);
browser.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie) {
repaint();
}

// Display current selections. public void paint(Graphics g) {


msg = "Current OS: ";
msg += os.getSelectedItem();
g.drawString(msg, 6, 120);
msg = "Current Browser: ";
msg += browser.getSelectedItem();
g.drawString(msg, 6, 140);
}
}

browser.add("Netscape 3.x");
browser.add("Netscape 4.x");
A. browser.add("Netscape 5.x");
browser.add("Netscape 6.x");

os = new Choice();
B. browser = new Choice();

os.addItemListener(this);
C. browser.addItemListener(this);

os.add("Windows 98/XP");
D. os.add("Windows NT/2000");

Answer optionb

Marks: 2
Select the Missing Statment in Program
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="ButtonDemo" width=250 height=150> </applet>
*/

public class ButtonDemo extends Applet implements ActionListener {


String msg = "";
Button yes, no, maybe;

public void init() {


yes = new Button("Yes");
no = new Button("No");
maybe = new Button("Undecided");
-----------------------
----------------------
-----------------------
yes.addActionListener(this);
140 no.addActionListener(this);
maybe.addActionListener(this);
}

public void actionPerformed(ActionEvent ae) {


String str = ae.getActionCommand();
if(str.equals("Yes")) {
msg = "You pressed Yes.";
}
else if(str.equals("No")) {
msg = "You pressed No.";
}
else {
msg = "You pressed Undecided.";
repaint();
}
}
public void paint(Graphics g) {
g.drawString(msg, 6, 100);
}
}

yes.addActionListener(this);
A. no.addActionListener(this);
maybe.addActionListener(this);

yes = new Button("Yes");


B. no = new Button("No");
maybe = new Button("Undecided");

add(yes);
C. add(no);
add(maybe);

if(str.equals("Yes")) {
msg = "You pressed Yes.";
D. }
else if(str.equals("No")) {
msg = "You pressed No.";

Answer optionc

Marks: 2

141 What is the proper constructor of serversocket

A. ServerSocket(int port)

B. ServerSocket(int port, int maxQueue)

C. ServerSocket(int port, int maxQueue, InetAddress localAddress)

D. All The Above

Answer optiond

Marks: 2

142 What is proper method to retrieve the host name of local machine

A. static InetAddressgetLocalHost( )throws UnknownHostException

B. static InetAddressgetByName(String hostName)throws UnknownHostException

C. static InetAddress[ ] getAllByName(String hostname throws UnknownHostException

D. string getHostAddress()

Answer optiona

Marks: 2

143 What is Servlet Job ?

A. Read explicit data sent by client


B. Generate the results

C. Send the explicit data back to client

D. All The Above

Answer optiond

Marks: 2

Select the proper command to run the following code


import java.awt.*;
import java.applet.*;
/*
<applet code="TextFieldDemo" width=380 height=150> </applet>
*/
public class TextFieldDemo extends Applet
{
TextField name, pass;
public void init()
{
144 Label namep = new Label("Name: ", Label.RIGHT);
Label passp = new Label("Password: ", Label.RIGHT); name = new TextField(12);
pass = new TextField(8); pass.setEchoChar('?'); add(namep);
add(name);
add(passp);
add(pass);
}
public void paint(Graphics g)
{
}
}

Javac TextFieldDemo.java
A.

B. java TextFieldDemo

C. appletviewer TextFieldDemo.java

D. All of above

Answer optionc

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;
class StudentData
{
public static void main(String args[])
{

{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") Connection con =
DriverManager.getConnection("jdbc:odbc:stud");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from Student"); System.out.println("The Database is:-");
System.out.println("Roll\tName\t\tMarks Pass Birth-Date"); System.out.println("=====================================");
while(rs.next())
145
int roll = rs.getInt(1);
String name = rs.getString(2); int marks = rs.getInt("Marks"); boolean pass = rs.getBoolean(4); Date d = rs.getDate(5);
System.out.printf("%-5d",roll); System.out.printf("%-10s",name); System.out.printf("%-6d",marks);
if(pass)
System.out.printf("Yes ");
else
System.out.printf("No ");
System.out.printf("%-15s\n",d.toString());

con.close();
}
(Exception e){ }
}
}

A. Missing semicolon

B. Missing Curly Bracket

C. Missing statement. Try catch

D. All the Above

Answer optiond

Marks: 2
Consider the following program.
What should be the correction done in the program to get correct output?
import java.sql.*;
class StudentData
{
public static void main(String args[]) ;
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:stud");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from Student");
System.out.println("The Database is:-");
146 System.out.println("Roll\tName\t\tMarks Pass Birth-Date"); System.out.println("=====================================");
while(rs.next())
{
int roll = rs.getInt(1);
String name = rs.getString(2); int marks = rs.getInt("Marks"); boolean pass = rs.getBoolean(4); Date d = rs.getDate(5);
System.out.printf("%-5d",roll); System.out.printf("%-10s",name); System.out.printf("%-6d",marks); if(pass)
System.out.printf("Yes "); else
System.out.printf("No ");
System.out.printf("%-15s\n",d.toString());
}
con.close();
}
catch(Exception e){ }
}
}

A. Error in close()

B. Error in connection statement

C. Error in loop

D. Error in main()

Answer optiond

Marks: 2

What is Error in Program ?


import java.io.*;
import javax.servlet.*;

public class HelloServlet extends GenericServlet {

147 throws ServletException, IOException {


response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

public void service(ServletRequest request,


A. ServletResponse response)

B. public void service(ServletRequest response)

public void (ServletRequest request,


C. ServletResponse response)

D. public void service()

Answer optiona

Marks: 2

148 Which object can be constructed to show and select any number of choices in the visible window?

A. label

B. Choice

C. List

D. Checkbox

Answer optionc

Marks: 1

149 Which of these methods can be used to obtain the reference to the container that generated a ContainerEvent?

A. getContainer()

B. getContainerCommand()

C. getActionEvent()

D. getContainerEvent()
Answer optiona

Marks: 1

150 Panel is used for __________ components

A. Grouping

B. Modifying

C. Creating

D. Deleting

Answer optiona

Marks: 1

151 Applet Container is used to prepare ________________output window.

A. Graphical

B. User Interface

C. Both a and b

D. None of these

Answer optionc

Marks: 1

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

A. ContentType()

B. contentType()

C. getContentType()

D. GetContentType()

Answer optionc

Marks: 1

153 The_____________________ is the language for interacting with Database.

A. Java

B. Java Script

C. Servlet

D. Structured Query Language(SQL)

Answer optiond

Marks: 1

154 The ___________ interface Provides various methods for getting information about Database.

A. Statement

B. DatabaseMetaData

C. Connection

D. PrepareStatment

Answer optionb

Marks: 1

155 To execute SQL query which method is used.

A. execute()

B. executeQuery()

C. executeUpdate()
D. All of these

Answer optiond

Marks: 1

Find missing Lines in following Program.


import java.awt.*;
import java.io.*;
import java.awt.event.*;
import java.applet.*;

public class ex7 extends Applet


implements KeyListener
{
String msg ="";
int X=10,Y=20;
public void init()
{
addKeyListener(this);
requestFocus();
}

public void keyPressed(KeyEvent k)


{
showStatus("KeyDown");
int key=k.getKeyCode();
switch(key)
{
156 case KeyEvent.VK_UP:
showStatus("UP KEY PRESSED");

break;
}

repaint();
}
public void keyReleased(KeyEvent k)
{
showStatus("Key Up");
}

public void paint(Graphics g)


{
g.drawString(msg,X,Y);
}

/*
<applet code =ex7 width =500 height =500>
</applet>
*/

public void keyTyped(KeyEvent k)


{
A. msg+=k.getKeyChar();
repaint();
}

public void keyTyped(KeyEvent k)


{
B. repaint();
}

public void keyTyped(KeyEvent k)


{
C. msg+=k.getKeyChar();
}

public void keyTyped()


{
D. repaint();
}

Answer optiona

Marks: 2

What is output of the following Program


import java.net.*;
class networking {
public static void main(String[] args) throws Exception
{
157 URL obj = new URL("http://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType());
}
}

A. html

B. text

C. text/html

D. html/text

Answer optionc

Marks: 2
Find Missing Statemt in program.
import java.sql.*;
import java.net.*;
class conn
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver are properly loaded");
String url="jdbc:odbc:student";
System.out.println("connection Established");
158 con.close();
}
catch(SQLException e)
{
System.out.println("SQL Error has Occurred");
}
catch(Exception e)
{
System.out.println("Error!Connection not Established");
}

A. Connection con=DriverManager.getConnection(url);

B. Connection con=DriverManager.getConnection();

C. Connection con=Connection.getConnection(url);

D. Connection con=DriverManager.getConnect(url);

Answer optiona

Marks: 2

Find Correction in following statment to prepare prepareStatment Object.

PreparedStatement pstmt;
159 String query = "select deptno, deptloc from dept where deptno > ? AND deptname=?";

rs = pstmt.executeQuery();

pstmt = con.prepareStatement(query);
A. pstmt.setString(1, 1001); pstmt.setString(2,"Pune");

pstmt = con.prepareStatement(query);
B. pstmt.setInt(1, 1001); pstmt.setString(2,"Pune");

pstmt = con.prepareStatement(query);
C. pstmt.setParameter(1, 1001); pstmt.setParameter(2,"Pune");

pstmt = con.prepareStatement(query);
D. pstmt.setValue(1, 1001); pstmt.setValue(2,"Pune");

Answer optionb

Marks: 2

160 In which file do we define a servlet mapping?

A. web.xml

B. servlet.mappings

C. servlet.xml

D. servlet,java

Answer optiona

Marks: 2

161 Abstract Methods of MouseMotion Listener Interface.

mouseClicked(MouseEvent)
A. mouseEntered(MouseEvent)

mouseClicked(MouseEvent)
B. mousePressed(MouseEvent)
mouseReleased(MouseEvent)

mouseMoved(MouseEvent)
C. mouseDragged(MouseEvent)

mouseClicked(MouseEvent)
mouseEntered(MouseEvent)
D. mouseExited(MouseEvent)
mousePressed(MouseEvent)
mouseReleased(MouseEvent)
Answer optionc

Marks: 2

162 Select methods of checkBox calss.

A. void setLabel()

B. String getLabel()

C. boolean getState()

D. All of these

Answer optiond

Marks: 2

select missing statement in given program.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class CheckingTheSession extends HttpServlet{


protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
163 pw.println("Checking whether the session is new or old<br>");

****************
if(session.isNew())
{
pw.println("You have created a new session");
}

}
}

A. HttpSession session = request.getSession();

B. HttpSession session = new HttpSession()

C. HttpSession session = new HttpSession(getSession())

D. HttpSession session = response.getSession()

Answer optiona

Marks: 2

164 The init parameter name and value pairs that are defined in web.xml are handled by.

A. ServletConfig object

B. ServletContext object

C. ServletRequest object

D. ServletResponse object

Answer optiona

Marks: 2

165 Which Action element Includes file at time the page is requested in JSP.

A. jsp:include

B. jsp:import

C. jsp:embed

D. None of these

Answer optiona

Marks: 2

166 Which of these events is generated when a button is pressed?

A. A.) WindowEvent

B. B.) ActionEvent

C. C.) WindowEvent

D. D.) KeyEvent
Answer optionb

Marks: 1

167 mouse click will always generate ________________ event?

A. MouseButtonEvent

B. ActionEvent

C. MouseClickEvent

D. MouseEvent

Answer optiond

Marks: 1

168 The various controls supported by swing are:

A. JList, JTree, JTabbedPane

B. JRadioButton, JTextField

C. JButton, JToggleButton, JTable

D. all of the above

Answer optiond

Marks: 1

169 Which one is the valid constructor of JCheckBox.

A. JCheckBox(int s)

B. JCheckBox(Icon I, int s,Boolean State)

C. JCheckBox(Sting s, Icon I, Boolean State)

D. JCheckBox(Icon I, int s)

Answer optionc

Marks: 1

170 Which of these constant value will change when the button at the end of scroll bar was clicked to increase its value?

A. BLOCK_DECREMENT

B. UNIT_DECREMENT

C. UNIT_INCREMENT

D. BLOCK_INCREMENT

Answer optionc

Marks: 1

171 Which of the following is an approach for state maintenance in Web applications?

A. Hidden Form Field

B. URL Rewriting

C. Cookies

D. All of the above.

Answer optiond

Marks: 1

172 Which JSP tag is used to transfer processing to another JSP page ?

A. <jsp:include>

B. <jsp:redirect>

C. <jsp:useBean>
D. <jsp:forward>

Answer optiond

Marks: 1

173 Which Component subclass is used for drawing and painting?

A. Frame

B. Canvas

C. Window

D. Applet

Answer optionb

Marks: 2

174 What component will be needed to get following output?

A. A)TextField

B. B)JTextField, Horizontal_Scrollbar

C. C)JApplet, JTextField, JScrollPane and Constants related to scrollbars

D. D) JPanel, JTextField, JScrollPane and Constants related to scrollbars

Answer optiond

Marks: 2

1. What will be the output of the following code? import java.awt.*;


import java.applet.*;
import java.awt.event.*;

public class adm extends Applet


{
public void init()
{
addMouseMotionListener(new mma1(this));
}

class mma1 extends MouseAdapter


175 {
adm a;
public mma1(adm a)
{
this.a=a;
}
public void mouseDragged(MouseEvent me)
{
a.showStatus("mouse dragged");
}
}

/*<applet code="adm" width=500 height=500>


</applet>*/

A. S1-chapter2(Q1.A).jpg

B. S1-chapter2(Q1.B).jpg

C. S1-chapter2(Q1.C).jpg

D. S1-chapter2(Q1.D).jpg

Answer optionc

Marks: 2

176 Which of the following statement is false as far as different type of statements is concern in JDBC.

A. Regular statrment

B. Prepared Statement

C. Callable Statement

D. Interim Statement

Answer optiond

Marks: 2
3. Observe the following code and find which statement contains error.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.event.*;
public class ttp extends JApplet implements ActionListener
{
JButton jb=new JButton("click me");
JTextField text=new JTextField(20);
public void init()
{
177 Container cp=getContentPane();
cp.setLayout(new FlowLayout());
jb.setToolTipText("this is button control");

add(jb);
add(text);
text.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
text.setText("hello tyco");
}
}

A. A. Error in setting layout manager.

B. B. Error in setting ToolTip text.

C. C.Error in adding and registering listener to the component.

D. D. Error in declaration of Action_Performed method.

Answer optionc

Marks: 2

Select proper command for compilation and execution of program. import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class square extends Applet implements ActionListener
{
TextField t1,t2;
Label l1,l2;
Button b1;
public void init()
{
t1=new TextField(5);
t2=new TextField(5);
l1=new Label("Enter Number:");
l2=new Label("Result:");
b1=new Button("Square");
b1.addActionListener(this);

178 add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
int n1=Integer.parseInt(t1.getText());
n1=n1*n1;
t2.setText(Integer.toString(n1));
}
}
}
/*<applet code="square" width=400 height=400>
</applet>*/

A. A. javac list and java list

B. B. javac list.java and java list

C. C. java list.java and appletviwer list.java

D. D. javac square.java and appletviewer square.java

Answer optiond

Marks: 2
Find the missing term at ____________ in the following code
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class key extends Applet implements __________________Listener
{
String msg=" ";
public void init()
{
addKeyListener(this);
}
public void keyPressed(KeyEvent k)
{
showStatus("key pressed");
}
public void keyReleased(KeyEvent k)
179 {
showStatus("key released");
}
public void keyTyped(KeyEvent k)
{
showStatus("key typing");
}
public void paint(Grapics g)
{
g.drawString(msg,80,100);
}
}

/*<applet code="Key" width=600 height=600>


</applet>
*/

A. KEY

B. Key

C. key

D. None of the Above

Answer optionb

Marks: 2

Consider following output. Find missing statement from following code.


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class keyEp extends Applet implements KeyListener
{
String msg=" ";
int x=10, y=20;
public void init()
{
addKeyListener(this);
}
public void keyPressed(KeyEvent k)
{
showStatus("key pressed");
int kl=k.getKeyCode();
switch(kl)
{
case KeyEvent.VK_LEFT:
msg+="<left arrow>";
180 break;

case KeyEvent.VK_RIGHT:
msg+="<right arrow>";
break;
}
repaint();
}
public void keyReleased(KeyEvent k)
{
showStatus("key up");
}
public void keyTyped(KeyEvent l)

public void paint(Graphics g)


{
g.drawString(msg,x,y);
}

A. A. Missing }

B. B. Missing ;

C. C. Missing ( )

D. D. Missing{}

Answer optiond

Marks: 2
For the following code that can be used to handle event to be replaced in the given blank space.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class scrl extends Applet implements AdjustmentListener


{
Scrollbar vsb,hsb;
public void init()
{
int width=Integer.parseInt(getParameter("width"));
int height=Integer.parseInt(getParameter("height"));
vsb=new Scrollbar(Scrollbar.VERTICAL,0,1,0,height);
hsb=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,width);
add(vsb);
add(hsb);
181 vsb.addAdjustmentListener(this);
hsb.addAdjustmentListener(this);
}

public void -----------------(---------Event ae)


{
repaint();
}

public void paint(Graphics g)


{
msg="Vertical: "+vsb.getValue();
msg+="Horizontal: "+hsb.getValue();
g.drawString(msg,6,160);
g.drawString("*", hsb.getValue(),vsb.getValue());
}
}

A. AactionPerformed(ActionEvent ae)

B. adjustmentValueChanged(ActionEvent ae)

C. adjustmentValueChanged(AdjustmentEvent ae)

D. adjustmentChangedValue(AdjustmentEvent ae)

Answer optionc

Marks: 2

Find the missing statement to get output.


import java.sql.*;
class conn1
{
public static void main(String h[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver are properly loaded");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
System.out.println("connection established");
String sql="create table stuI4(Name char,Age int)";
boolean res=state.execute(sql);
182 if(res==true)
System.out.println("table not created");
else
System.out.println("table created");

catch(SQLException e)
{
System.out.println("Sql error has occured");
}
catch(Exception e)
{
System.out.println("error!connection not establishd");
}
}
}

A. MISSING ;

B. Missing {

Missing }
C.

D. Missing ()

Answer optionc

Marks: 2
Find the missing method in following code.
class jdbc1
{
public static void main(String ar[])throws Exception
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:oradsn;UID=scott;PWD=tiger");
Statement st=con.---------------------
ResultSet rs=st.executeQuery("select * from emp");
183 while(rs.next())
{
int pid=rs.getInt(1);
String nm=rs.getString(2);
System.out.println("\nProduct ID="+pid+"\nProduct Name="+nm+"\n");
}
con.close();
}

A. createStatement()

B. CreateStatement()

C. createStatement();

D. none of these

Answer optionc

Marks: 2

What will be the output of following program?


import java.sql.*;
class conn1
{
public static void main(String arg[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver are properly loaded");
String url="jdbc:odbc:xyz";
Connection con=DriverManager.getConnection(url);
System.out.println("connection established");
184 Statement state=con.createStatement();
String sql="create table stuI4(Name char,Age int)";
boolean res=state.execute(sql);
if(res==0)
System.out.println("table not created");
else
System.out.println("table created");
}
catch(SQLException e)
{
System.out.println("Sql error has occured");
}
}
}

A. table created

B. connection established and table created.

Driver are properly loaded


C. connection established and table created

Driver are properly loaded


D. connection established and table not created

Answer optionc

Marks: 2

What will be the output of following program.


public class DemoServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{

PrintWriter out = response.getWriter();

out.println("<HTML>");
185 out.println("<HEAD>");
out.println("<TITLE>Servlet Page</TITLE>");
out.println("</HEAD>");

out.println("<BODY>");
out.println("Welcome to the Servlet World");
out.println("</BODY>");
out.println("</HTML>");
}
}

A. Welcome to the Servlet World

B. Servlet Page

C. Servlet Page and Welcome to the Servlet World

D. Welcome to the world.


Answer optiona

Marks: 2

186 setBorder() method is used to set a border for ________?

A. Jcomponent

B. Container

C. Button

D. Label

Answer optiona

Marks: 1

187 Which of the following are subclasses of java.awt.Component?

A. Container

B. LayoutManager

C. Color

D. Font

Answer optiona

Marks: 1

188 The MouseListener's _______________ method is called after mouse button is released

A. public void mouseExited(MouseEvent e)

B. public void mousePressed(MouseEvent e)

C. public void mouseEntered(MouseEvent e)

D. public void mouseReleased(MouseEvent e)

Answer optiond

Marks: 1

189 The method in the ActionEvent ________ returns the action command of the button

A. getId()

B. paramString()

C. getModifiers()

D. getActionCommand()

Answer optiond

Marks: 1

190 Source object can register only one listener

A. True

B. False

C. cant predict

D. none of this

Answer optionb

Marks: 1

191 If a PreparedStatement is a SQL SELECT statement, you execute the statement using ________.

A. PreparedStatement.executeQuery();

B. PreparedStatement.executeUpdate();

C. PreparedStatement.execute();
D. PreparedStatement.query();

Answer optiona

Marks: 1

192 Life cycle of the servlet is managed by

A. servletContext

B. servletContainer

C. Supporting protocol

D. all of the above

Answer optionb

Marks: 1

193 Name the method defined in the HttpServletResponse class that may be used to set the content type.

A. setType

B. setContent

C. setContentType

D. setResponseContentType

Answer optionc

Marks: 1

194 What is the layout of the given output

A. GridLayout

B. BorderLayout

C. FlowLayout

D. CardLayout

Answer optionc

Marks: 2

195 Multiple layouts in the single conainer can be created with the help of _______________

A. Frame

B. Panel

C. Window

D. Container

Answer optionb

Marks: 2

196 Which of following is true?

A. All the methods in the JButton class are inherited from the javax.swing.AbstractButton class

B. You can't create a JButton by specifying an icon

C. There is no default constructor for Jbutton

D. You can’t apply text and icon to Jbutton simultaneouly

Answer optiona

Marks: 2

197 The server listens for a connection request from a client using the following statement:

A. Socket s = new Socket(ServerName, port);

B. Socket s = serverSocket.accept()
C. Socket s = serverSocket.getSocket()

D. Socket s = new Socket(ServerName);

Answer optionb

Marks: 2

198 Which of the following statements loads the JDBC-ODBC driver?

A. Class.forName(sun.jdbc.odbc.JdbcOdbcDriver)

B. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

C. Class.loadClass(sun.jdbc.odbc.JdbcOdbcDriver)

D. Class.loadClass("sun.jdbc.odbc.JdbcOdbcDriver")

Answer optionb

Marks: 2

199 To execute a SELECT statement "select * from Address" on a Statement object stmt, use

A. stmt.execute("select * from Address");

B. stmt.executeQuery("select * from Address");

C. stmt.executeUpdate("select * from Address");

D. stmt.query("select * from Address");

Answer optionb

Marks: 2

200 Apache Tomcat is a ________.

A. Servlet

B. Java program

C. API

D. Web server that is capable of running Java programs.

Answer optiond

Marks: 2

Suppose the two parameters in the doGet or doPost method are request and response. To specify HTML content type sent to the client,
201 invoke ___________.

A. response.setContentType("text/html")

B. request.setContentType("text/html")

C. con.setContentType("text/html")

D. response.setContentType=("text/html")

Answer optiona

Marks: 2

Given the following code


import java.awt.*;
public class SetF extends Frame
{
public static void main(String argv[])
{
202 SetF s = new SetF();
s.setSize(300,200);
s.setVisible(true);
}
}
How could you set the frame surface color to pink

A. s.setBackground(Color.pink);

B. s.setColor(PINK);

C. s.Background(pink);

D. s.color=Color.pink
Answer optiona

Marks: 2

203 Which will be the layout of the output window

A. GridLayout

B. FlowLayout

C. GridBagLayout

D. BorderLayout

Answer optionc

Marks: 2

204 Correct code of the output window is

public class TestDemo extends JApplet


{
public void init()
{
JButton b = new JButton("Button");
A. Container c = getContentPane();
c.setLayout(new FlowLayout());
c.add(b);
}
}

public class TestDemo extends JApplet


{
public void init()
{
B. JButton b = new JButton("Button");
Container c = getContentPane();
c.add(b);
}
}

public class TestDemo extends JApplet


{
public void init()
{
C. JButton b = new JButton("Button");
Container c = getContentPane();
c.setLayout(new FlowLayout());
}
}

public class TestDemo extends JApplet


{
public void init()
{
D. JButton b = new JButton("Button");
c.setLayout(new FlowLayout());
c.add(b);
}
}

Answer optiona

Marks: 2

205 getPort() method of socket class return

A. Port no of current machine

B. Returns the remote port number to which the socket object is connected

C. returns address of the current machine

D. returns address of socket object

Answer optionb

Marks: 2

ResultSet rs = stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");


206 where the stmt is Statement object. Same Code can be replaced by PrepareStatment object pst with which statment

A. ResultSet rs =pst .executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");

pst = con.prepareStatement
B. ("SELECT COF_NAME, PRICE FROM COFFEES");
ResultSet rs = pst.executeQuery();

pst = con.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");


C. ResultSet rs = pst;

D. ResultSet rs = pst.con..executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");


Answer optionb

Marks: 2

<HTML>
<HEAD><TITLE>Hello</TITLE></HEAD>
<BODY>
<H1>
<%
if (request.getParameter("name") == null) {
out.println("Hello World");
207 }
else {
out.println("Hello, " + request.getParameter("name"));
}
%>
</H1>
</BODY></HTML>

A. file will be saved with .java

B. file will be saved with .jsp

C. file will be saved with .servlet

D. file will be saved with .class

Answer optionb

Marks: 2

208 To set title to the frame window___________ method is used.

A. void settitle(String str)

B. void setText(String str)

C. void setTitle(String str)

D. None of these

Answer optionc

Marks: 1

209 ____________ class is used to create set of mutually exclusive checkboxes.

A. Group

B. CheckboxGroup

C. Radiobutton

D. None of these

Answer optionb

Marks: 1

210 __________ method returns currently selected item in choice.

A. getSelectedIndex( )

B. getSelectedElement( )

C. getSelectedItem( )

D. getItem()

Answer optionc

Marks: 1

211 By default page-up and page-down increment of scrollbar is_____________.

A. 2

B. 5

C. 1

D. 10

Answer optiond

Marks: 1
212 __________ method is used to add items in Combobox.

A. add()

B. addElement()

C. insert()

D. addItem()

Answer optiond

Marks: 1

__________is generated when checkbox is clicked, list item is clicked, choice selection is made or checkable menu item is selected or
213 deselected.

A. ItemEvent

B. ActionEvent

C. MouseEvent

D. WindowEvent

Answer optiona

Marks: 1

214 getID() method is provided by __________ class.

A. EventObject

B. AWTEvent

C. ActionEvent

D. None of these

Answer optionb

Marks: 1

215 __________method of URL class is used to obtained file path from given URL.

A. getFile()

B. getPath()

C. getFilePath()

D. None of these

Answer optiona

Marks: 1

216 Which of the following method is used to obtain remote port to which Socket object is connected.

A. getRemotePort()

B. getLocalPort()

C. getPort()

D. None of these

Answer optionc

Marks: 1

217 Statement is__________.

class
A.

B. interface

C. method

D. abstract class

Answer optionb
Marks: 1

218 Which of the following package contains all JDBC API�s those are required to make connection with database?

A. java.sql.*

B. java.oracle.*

C. java.net.*

D. java.jdbc.*

Answer optiona

Marks: 1

219 The PreparedStatement__________symbol is placeholder that is replaced by the input parameter at seen time.

A. *

B. ?

C. #

D. @

Answer optionb

Marks: 1

220 __________declares life cycle methods of servlet.

A. GenericServlet

B. Servlet

C. HttpServlet

D. ServletConfig

Answer optionb

Marks: 1

221 Parameters are present in URL while using__________method

A. doGet()

B. doPut()

C. doPost()

D. None of these

Answer optiona

Marks: 1

222 Which of the following statement is used to create GridLayout in the output shown below?

A. GridLayout g=new GridLayout(2,3);

B. GridLayout g=new GridLayout(3,2);

C. GridLayout g=new GridLayout(3,3);

D. None of these

Answer optionb

Marks: 2

223 What components will be needed to get following output?

A. Applet, MenuBar, Menu, MenuItem

B. Applet, MenuBar, Menu, CheckboxMenuItem

C. Frame, MenuBar, Menu, CheckboxMenuItem

D. Frame, MenuBar, Menu, MenuItem


Answer optionc

Marks: 2

224 What components will be needed to get following output?

A. Applet, TabbedPane, Choice

B. Applet, TabbedPane, ComboBox

C. Frame, TabbedPane, Panel

D. Frame, TabbedPane, List

Answer optionb

Marks: 2

225 What components will be needed to get following output?

A. JApplet, JCheckBox, JComboBox, Jbutton

B. JApplet, JRadioButton, JList, Jbutton

C. JFrame, JCheckBox, JChoice, Jbutton

D. JFrame, JRadioButton, JList, Jbutton

Answer optiona

Marks: 2

To get the proper output complete the code given below.


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DemoKeyEvent extends Applet implements KeyListener
{
public void init()
{
226 this.addKeyListener(this);
}
public void keyTyped(KeyEvent ke)
{
showStatus("Key Typed");
}
}
/*<applet code="DemoKeyEvent.class" width=300 height=300></applet>*/

public void keyPressed(KeyEvent ke){


showStatus("Key Pressed");
A.
}

public void keyReleased(KeyEvent ke)


{
B. showStatus("KeyRealeased");
}

C. All of the above

D. None of these

Answer optionc

Marks: 2

227 Which of the following is the correct syntax of executeQuery() method?

A. int executeQuery()

int executeQuery(String str)


B.

C. ResultSet executeQuery()

D. ResultSet executeQuery(String str)

Answer optiond

Marks: 2

228 Which of the following is correct syntax of init() method of servlet ?

A. void init(SevletContext contex)throws ServletException

B. void init(ServletConfig sc) throws ServletException

C. void init(ServletRequest req) throws ServletException


D. void init(ServletResponse res) throws ServletException

Answer optionb

Marks: 2

229 Which of the following is true about getSession(boolean flag) statement?

A. If flag is true and No session exist, it creates and returns session for this request.

B. If flag is false and No session exist, it creates and returns session for this request.

C. If flag is false it returns existing session for this request.

D. Both A and C are correct

Answer optiond

Marks: 2

Which of the following describes the correct sequence of the steps involved in executing Java Server Pages?
a. Web server forwards HTTP request to JSP engine
b. Browser sends HTTP request for JSP page
230 c. servlet processes the request and produces output in HTML format which is then send as HTTP response to the web browser.
d. JSP engine compiles servlet into executable class and forwards original request to servlet engine
e. JSP engine loads JSP page from disk and converts it into java servlet

A. b-a-e-d-c

B. b-a-e-c-d

C. e-a-c-b-d

D. a-b-c-e-d

Answer optiona

Marks: 2

Select the proper output for following code


import java.awt.*;
import java.applet.*;
public class DemoBorderLayout extends Applet
{
Button b1,b2,b3,b4,b5;
public void init()
{
BorderLayout b=new BorderLayout(20,30);
setLayout(b);

b1=new Button("Top");
231 b2=new Button("Right");
b3=new Button("Bottom");
b4=new Button("Left");
b5=new Button("Center");

add(b1,BorderLayout.NORTH);
add(b2,BorderLayout.EAST);
add(b3,BorderLayout.SOUTH);
add(b4,BorderLayout.WEST);
add(b5,BorderLayout.CENTER);
}
}
/*<applet code="DemoBorderLayout.class" width=350 height=300></applet>*/

A. S1Q42O1

B. S1Q42O2

C. S1Q42O3

D. S1Q42O4

Answer optionb

Marks: 2

232 Identify the code for the output given below.

A. import java.awt.*;import javax.swing.*;public class Demo extends JApplet{ JButton b1,b2; JCheckBox cb1,cb2; public void init() { Container c=getContentPan

B. import java.awt.*;import javax.swing.*;public class Demo extends JFrame{ JButton b1,b2; JCheckBox cb1,cb2; Demo() { Container c=getContentPane(); c.setLa

import java.awt.*;import javax.swing.*;public class Demo extends JApplet{ JButton b1,b2; JCheckBox cb1,cb2; public void init() { Container c=getContentPan
C. }

D. None of these

Answer optionc

Marks: 2
//Identify the error
import java.awt.*;
import javax.swing.*;
/*<applet code="JTableDemo" width=400 height=200></applet>*/
public class JTableDemo extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());

final String[] colHeads = { "Roll No", "Name", "Branch" };


final Object[][] data = {
233 { �11�,"Mayur", �CO� },
{ �22�,"Ritesh", �IF� },
{ "33", �Rahul�, �CM� }
};

JTable table = new JTable(data);


int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(table, v, h);

contentPane.add(jsp, BorderLayout.CENTER);
}
}

A. Error in statement in which JTable is created

B. Error in statement in which JScrollPane is created

C. Error in statement in which applet tag is declared

D. None of these

Answer optiona

Marks: 2

Select the proper output for following code


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Demo extends Applet implements ItemListener
{
Checkbox cb1,cb2,cb3;
public void init()
{
cb1=new Checkbox("Red");
cb2=new Checkbox("Green");
cb3=new Checkbox("Blue");

add(cb1);
add(cb2);
add(cb3);
234
cb1.addItemListener(this);
cb2.addItemListener(this);
cb3.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==cb1)
setBackground(Color.RED);
else if(ie.getSource()==cb2)
setBackground(Color.YELLOW);
else
setBackground(Color.BLUE);
}
}
/*<applet code="Demo.class" width=300 height=200></applet>*/

A. S1Q47O1

B. S1Q47O2

C. S1Q47O3

D. All of the Above

Answer optiona

Marks: 2
Select the missing statement in the following code
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class DemoChoice extends Applet


{
Choice ch;
public void init()
{
ch=new Choice();
ch.add("A");
235 ch.add("B");
ch.add("C");

ch.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==ch)
showStatus(ch.getSelectedItem());
}
}
/*<applet code="DemoChoice.class" width=300 height=200></applet>*/

A. add(ch)

B. ch.addActionListener(this);

C. implements ItemListener

D. A and C are correct

Answer optiond

Marks: 2

Select the missing statement in the following code


import java.awt.*;
class AppWindow extends Frame
{
AppWindow(String title)
{
super(title);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
236 });
}
public void paint(Graphics g)
{
g.drawString("First Application Window",50,100);
}
public static void main(String args[])
{
AppWindow app=new AppWindow("First Window");
app.setSize(300,400);
app.setVisible(true);
}
}

A. Missing import java.awt.event.*; package

B. Missing }

C. Missing {

D. Missing ;

Answer optiona

Marks: 2

Debug the following code and find which statement contains error.
import java.sql.*;
import java.io.*;
class DemoInsertRecord
{
public static void main(String args[])
{
Connection con;
Statement stmt;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
237 con=DriverManager.getConnection("Jdbc:Odbc:student","","");
stmt=con.createStatement();
String insQuery="insert into stud values (12,'abc')";
int res=stmt.executeQuery(insQuery);
if(res>0)
System.out.println("Record Inserted Successfully");

stmt.close();
con.close();
}catch (Exception ex) {}
}
}

A. Error in statement where getConnection() method is called


B. Error in statement where executeQuery() method is called

C. Error in statement where drivers are loaded

D. Error in statement where java.sql package is imported

Answer optionb

Marks: 2

Choose missing statements in following code from given options.


import java.sql.*;
class DemoFetch
{
public static void main(String args[])
{
Connection con;
Statement stmt;
ResultSet rs;
String qry, url;
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
url="Jdbc:Odbc:studdsn";
238 con=DriverManager.getConnection(url,"","");
stmt=con.createStatement();
qry="select * from stud";
rs=_______________;
System.out.println("Roll No\tName\tPercentage");
while(rs.next())
{
int rno=rs.getInt("roll");
String nm=rs.getString("sname");
double per=rs.getDouble("per");
System.out.println(rno+"\t"+nm+"\t"+per);
}
con.close();
}catch(Exception e){}
}
}

A. stmt.executeUpdate(qry)

B. stmt.executeNonQuery(qry)

C. stmt.executeQuery(qry)

D. None of these

Answer optionc

Marks: 2

Debug the following code and find which statement contains error.
import java.sql.*;
import java.io.*;
class DemoInsert
{
public static void main(String args[])
{
Connection con;
Statement stmt;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
239 con=DriverManager.createConnection("Jdbc:Odbc:empDsn","","");
stmt=con.createstatement();
String qry="insert into emp values (123,'Ram')";
int res=stmt.executeQuery(qry);
if(res>0)
System.out.println("Record Inserted Successfully");

stmt.close();
con.close();
}catch (Exception ex) {}
}
}

A. Error in statement where createConnection() method is called

B. Error in statement where createStatement() method is called

C. Error in statement where executeQuery() method is called

D. All of the above

Answer optiond

Marks: 2
Choose missing statements in following code from given options.
import java.sql.*;
class DemoFetch1
{
public static void main(String args[])
{
Connection con;
PreparedStatement pstmt;
ResultSet rs;
String qry,url;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
url="Jdbc:Odbc:studdsn";
con=DriverManager.getConnection(url,"","");
240 qry="select * from stud";
pstmt=con.prepareStatement(qry);
rs=___________________;
System.out.println("Roll No\tName\tPercentage");
while(rs.next())
{
int rno=rs.getInt("roll");
String nm=rs.getString("sname");
double per=rs.getDouble("per");
System.out.println(rno+"\t"+nm+"\t"+per);
}
con.close();
}catch(Exception e){System.out.println(e.toString());}
}
}

A. pstmt.executeUpdate(qry)

B. pstmt.executeUpdate()

C. pstmt.executeQuery(qry)

D. pstmt.executeQuery()

Answer optionc

Marks: 2

Choose missing statements in following code from given options.


import java.sql.*;
import java.io.*;
class DemoPreparedStmt
{
Connection con;
PreparedStatement pstmt;
String qry,url;
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
url="Jdbc:Odbc:studdsn";
con=DriverManager.getConnection(url,"","");
qry=___________________________;
241 pstmt=con.prepareStatement(qry);

pstmt.clearParameters();
pstmt.setInt(1,11);
pstmt.setString(2,"XYZ");
pstmt.setDouble(3,65.77);
int res=pstmt.executeUpdate();

if(res>0)
System.out.println("Record Inserted...");
else
System.out.println("Error...");
con.close();
}catch(Exception e){}
}
}

A. "insert into stud values(?,?,?)";

B. "insert into stud values(?,?)";

C. "insert into stud values(22,’XYZ’,65.77)";

D. None of these

Answer optiona

Marks: 2
Choose missing statements in following code from given options.
import java.io.*;
import javax.servlet.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
242 String data=request.getParameter("txtdata");
Cookie c=new Cookie("MyCookie",data);
response.addCookie(c);
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<B>My cookie has been sent<BR>");
pw.close();
}
}

A. Missing } statement

B. response.setCookie(c) instead of response.addCookie(c )

C. import javax.servlet.http.*;

D. None of these

Answer optionc

Marks: 2

Debug the following code and find which statement contains error.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DemoServlet extends HttpServlet


{
public void service(HttpServletRequest req,HttpServletResponse res)
243 throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter pw= res.getWriter();
pw.println("<h2> Welcome to servlet programming...");
pw.close();
}
}

A. Error in statement where service method is written

B. Error in statement where package javax.servlet.http is imported

C. Error in method where setContentType() method is called

D. No error

Answer optiond

Marks: 2

244 What maintains a cursor that points to a particular row of data .Initially, cursor points to before the first row?

A. Connection interface

B. Statement interface

C. ResultSet object

D. None of the Above

Answer optionc

Marks: 1

245 Which of the following layout mangers honours the preferred size of component( Multiple)

A. CardLayout

B. FlowLayout

C. BorderLayout

D. GridLayout

Answer optionb

Marks: 2

246 The JDBC-ODBC Bridge driver is

A. Multithreaded
B. singlethreaded

C. Both A & B

D. None of the Above

Answer optiona

Marks: 2

247 Which tag is used to execute java source code in JSP

A. Declaration Tag

B. Scriptlet Tag

C. Expression Tag

D. None of the Above

Answer optionb

Marks: 2

248 Choose the correct Program for the following output

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Fifth5 extends Applet implements ItemListener
{
Checkbox cb1,cb2,cb3;
CheckboxGroup cbg;
Label l1;
public void init()
{
A. cbg=new CheckboxGroup();
cb1=new Checkbox("C programming",cbg,false);
cb2=new Checkbox("C programming",cbg,true);
cb3=new Checkbox("C programming",cbg,false);
l1=new Lable("Before ItemSelection");
add(cb2);
add(cb3);
add(l1);
}
}

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Fifth5 extends Applet implements ItemListener
{
Checkbox cb1,cb2,cb3;
CheckboxGroup cbg;
Label l1;
public void init()
B. {
cbg=new CheckboxGroup();
cb1=new Checkbox("C programming",cbg,false);
cb2=new Checkbox("C programming",cbg,true);
cb3=new Checkbox("C programming",cbg,false);
l1=new Lable("Before ItemSelection");
add(cb1);
add(cb2);
add(cb3);
}

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Fifth5 extends Applet implements ItemListener
{
Checkbox cb1,cb2,cb3;
CheckboxGroup cbg;
Label l1;
public void init()
{
C. cbg=new CheckboxGroup();
cb1=new Checkbox("C programming",cbg,false);
cb2=new Checkbox("C programming",cbg,false);
cb3=new Checkbox("C programming",cbg,false);
l1=new Lable("Before ItemSelection");
add(cb1);
add(cb2);
add(cb3);
add(l1);
}
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Fifth5 extends Applet implements ItemListener
{
Checkbox cb1,cb2,cb3;
CheckboxGroup cbg;
Label l1;
public void init()
{
D. cbg=new CheckboxGroup();
cb1=new Checkbox("C programming",cbg,false);
cb2=new Checkbox("C programming",cbg,true);
cb3=new Checkbox("C programming",cbg,false);
l1=new Lable("Before ItemSelection");
add(cb1);
add(cb2);
add(cb3);
add(l1);
}

Answer optiond

Marks: 2

Consider the following program.


Select the statement that should be added to the program to get correct output.
import java.sql.*;
class Jdbc6
{
public static void main(String[] args)
{try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
249 String url="jdbc:oracle:thin:@pearl:1521:oracle10g";
Connection conn=DriverManager.getConnection(url,"java","java");
System.out.println("Hello ur sueecssfully concted");
int i=st.executeUpdate("insert into Department67 values(104,'E&TC')");
System.out.println(i);
}
catch(Exception e)
{System.out.println(e); }
}}

A. Statement st1 =con.createStatement();

B. Statement s = con.CreateStatement();

C. Statement st=conn.createStatement();

D. Statements stn=con.Createstatement();

Answer optionc

Marks: 2

Consider the following program and identify the missing statement.


class Type4_simple
{ public static void main(String[] args)
{try
{ Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@pearl:1521:oracle10g";
250 Connection conn = DriverManager.getConnection(url,"java","java");
System.out.println("successfully connected");
}
catch(Exception e){e.printStackTrace()}
}
}

A. Missing package statement

B. Missing semicolon & Package Statement

C. Missing initialization

D. Missing semicolon

Answer optionb

Marks: 2
Select the missing statement in the program to get the output
import java.sql.*;
import java.io.*;
class RS{
public static void main(String args[])throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
PreparedStatement ps=con.prepareStatement("insert into emp130 values(?,?,?)");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
do{
System.out.println("enter id:");
int id=Integer.parseInt(br.readLine());
System.out.println("enter name:");
251 String name=br.readLine();
System.out.println("enter salary:");
float salary=Float.parseFloat(br.readLine());
ps.setInt(1,id);
ps.setString(2,name);
ps.setFloat(3,salary);
System.out.println(" records affected");
System.out.println("Do you want to continue: y/n");
String s=br.readLine();
if(s.startsWith("n")){
break;
} }while(true);
con.close(); }}

A. executeupdate();

B. ps.executeUpdate();

C. ps.executeupdates();

D. rs.executeUpdate();

Answer optionb

Marks: 2

252 setMenuBar() method of which class

A. Menu

B. MenuBar

C. Frame

D. Applet

Answer optionc

Marks: 1

253 By default which layout manager is set on applet

A. BorderLayout

B. GridLayout

C. FlowLayout

D. GridBagLayout

Answer optionc

Marks: 1

254 Which method Is used to add items to JComboBox

A. add()

B. addItem()

C. selectItem()

D. insertItem()

Answer optionb

Marks: 1

255 Jtree class comes under which package

A. java.awt

B. java.applet

C. java.swing
D. javax.swing

Answer optiond

Marks: 1

256 getSource() is method of which class

A. Button

B. ActionEvent

C. ActionListener

D. EventObject

Answer optiond

Marks: 1

257 mouseDragged() method present in which listener

A. MouseListener

B. MouseMotionListener

C. TextListener

D. None of these

Answer optionb

Marks: 1

258 On which awt component event listener can not be aplied

A. TextField

B. Label

C. Frame

D. None of this

Answer optionb

Marks: 1

259 ____________port number is reserved for Http protocol.

A. 80

B. 8084

C. 25

D. 20

Answer optiona

Marks: 1

260 Access control does not deals with

A. Permissions

B. Policy

C. Authenication

D. Autorization

Answer optionc

Marks: 1

261 Resolver in DNS sysytem maps

A. Domain name to ip address

B. ip address to domain name


C. domain name to MAC address

D. MAC address to ip address

Answer optiona

Marks: 1

262 DSN stands for

A. Data Source Name

B. Data System Name

C. Database System Name

D. None of this

Answer optiona

Marks: 1

263 getConnection() method of which class

A. Connection

B. Statement

C. DriverManager

D. sql

Answer optionc

Marks: 1

264 Which method is used to obtain count of total rows of ResultSet

A. getRow

B. getCount

C. countRows

D. getAllRows

Answer optionb

Marks: 1

265 Cookies sent from ______ to _________

A. Client , Client

B. Server, Server

C. Client, Server

D. Server,Client

Answer optiond

Marks: 1

266 Which method is used to end servlet life cycle

A. exit

B. destroy

C. delete

D. end

Answer optionb

Marks: 1

267 Which attribute is mandory while creating cookie

A. Value
B. Maxage

C. Version

D. Path

Answer optiona

Marks: 1

268 If user does not set size of frame then in output size of frame is _____ width ______ height

A. 100 ,100

B. 0,0

C. 50,50

D. 100,50

Answer optionb

Marks: 2

269 Which method is incorrect while creating menubar

A. Menu.add(MenuItem)

B. Menu.add(Menu)

C. MenuItem.add(MenuItem)

D. MenuBar.add(Menu)

Answer optionc

Marks: 2

270 Which constructor was correct to get output

A. Jtable(2,3)

B. Jtable(3,2)

C. Jtable(3)

D. Jtable(2)

Answer optiona

Marks: 2

271 Which components are reuired to get following output (S1Q28)

A. Choice and Button

B. List and Button

C. Choice, List

D. Choice, List and Button

Answer optionb

Marks: 2

272 When user change text present In text field then that event listen by

A. ActionListener

B. ComponentListener

C. MouseListener

D. TextListener

Answer optiond

Marks: 2

273 Window is type of


A. Frame

B. Event Source

C. Class

D. All of this

Answer optiond

Marks: 2

274 Component listener can not be applicable to

A. Button, Choice

B. List, Scrollbar

C. Frame, Label

D. Textfield, Text Area

Answer optionc

Marks: 2

275 InputStream class is used in TCP Client-server program to

A. Send/receive message from client to server & vice versa.

B. receive message from client to server

C. Send message from server to client

D. none of the above.

Answer optiona

Marks: 2

276 Which method is incorrect to execute sql query

A. execute("select * from MSBTE")

execute("delete * from MSBTE")


B.

C. executeUpdate("select * from MSBTE")

D. All of this

Answer optionc

Marks: 2

277 service mthod of servelet is use

A. to send request and to get response

B. to get request and to send response

C. to end life of servlet

D. none of these

Answer optionb

Marks: 2

278 Which coockie name is incorrect

A. "Username"

B. "Username.password"

C. "Username@gmail.com"

D. all of this

Answer optionc

Marks: 2
279 For given figure which method of RequestDispatcher is applicable (S1Q41)

A. forward

B. include

C. add

D. sendRedirect

Answer optiona

Marks: 2

In given constructor what 3rd parameter indictaes


280 Scrollbar s=new Scrollbar(0,10,20,0,1000)

A. Size of thumb

B. Minimum value

C. Increment value

D. Initial value

Answer optiona

Marks: 2

What will be output for following program:


import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
public class feee extends JApplet
{
JTree t1;
DefaultMutableTreeNode d1,d2,d3;
public void init()
{
d1=new DefaultMutableTreeNode("FY");
281 d2=new DefaultMutableTreeNode("SY");
d3=new DefaultMutableTreeNode("TY");
t1=new JTree(d2);
d2.add(d3);
d3.add(d1);
add(t1);
}
}
/*
<applet code="feee.java" width=200 height=100>
</applet>
*/

A. Error

B. Nothing will display

C. S1Q44O3

D. S1Q44O4

Answer optionc

Marks: 2

282 In order to obtain currunt value of scrollbar at run time which method you will use

A. getMaximum()

B. getValue()

C. getMinimum()

D. getCuruntValue()

Answer optionb

Marks: 2

283 which method is required to register mouse listener to awt components

A. add()

B. addListener()

C. addMouseListener

D. All of this
Answer optionc

Marks: 2

What will be output for following program


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class see extends Applet implements ActionListener
{
Button b1;
public void init()
{
b1=new Button("Yellow");
add(b1);
284 b1.addFocusListener(this);
}
public void focusGained(FocusEvent fe)
{
b1.setBackground(Color.yellow);
}
}
/*
<applet code="see.java" width=200 height=100>
</applet>
*/

A. S1Q48O1

B. S1Q48O2

C. Compile time error

D. None of these

Answer optionc

Marks: 2

What will be output if user select second item from choice component in following program:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class gee extends Applet implements ItemListener
{
Choice c1;
TextField t1;
public void init()
{
c1=new Choice();
c1.add("1");
c1.add("2");
c1.add("3");
c1.addItemListener(this);
285 add(c1);
t1=new TextField(5);
add(t1);

}
public void itemStateChanged(ItemEvent ie)
{
int id=c1.getSelectedIndex();
t1.setText(""+id);
}
}
/*
<applet code="gee.java" width=200 height=100>
</applet>
*/

A. S1Q50O1

B. S1Q50O2

C. S1Q50O3

D. S1Q50O4

Answer optionb

Marks: 2

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 Exception
{
ServerSocket s1 = new ServerSocket(2);
286 InputStream i = s.getInputStream();
DataInputStream di = new DataInputStream(i);
DataInputStream d = new DataInputStream(System.in);
String str = di.readUTF();
System.out.println(str);

}
}

A. OutputStream class & accept method call from server


B. IP address

C. accept method call from server

D. close method

Answer optiona

Marks: 2

287 If ResultSet is forward only then which method can not be execute

A. getString()

B. first

C. getRow()

D. next()

Answer optionb

Marks: 2

288 Which class not comes under java.sql package

A. Connection

B. Statement

C. ResultSet

D. Class

Answer optiond

Marks: 2

289 What is an API?

A. Application Programming Interchange

B. Application Programming Intraction

C. Application Programming Interface

D. None Of These

Answer optionc

Marks: 1

290 which of these methods use in cardlayout

A. add(Component C, String s)

B. add(Component C)

C. add(Card c1, Component c)

D. add(String s, Component c)

Answer optiond

Marks: 1

291 _____________________ is not a Swing Component

A. ButtonGroup

B. Jlabel

C. Jbutton

D. CheckboxGroup

Answer optiond

Marks: 1

292 JCheckBox is _______________________Component


A. lightweight

B. heavyweight

C. awt

D. abstract

Answer optiona

Marks: 1

293 MutableTreeNode is extends__________________interface

A. TreeNode

B. DefaultMutableTreeNode

C. TreePath

D. JTree

Answer optiona

Marks: 1

294 which of the following is not a AWT control.

A. ButtonGroup

B. CheckboxGroup

C. Checkbox

D. Button

Answer optiona

Marks: 1

295 Canvas is a ________________

A. Applet

B. Panel

C. Window

D. Frame

Answer optionc

Marks: 1

296 Which of these not a constants defined in ComponentEvent class?

A. COMPONENT_HIDDEN

B. COMPONENT_SHOWN

C. COMPONENT_SIZED

D. COMPONENT_RESIZED

Answer optionc

Marks: 1

297 KeyListener interface has got _______________methods

A. 2

B. 4

C. 1

D. 3

Answer optiond

Marks: 1
298 Which of these a AdapterClass

A. KeyAdapter class

B. TextAdapter class

C. ActionAdapter class

D. ItemAdapter class

Answer optiona

Marks: 1

299 Which of these is a factory methods

A. getAddress()

B. getHostName()

C. getLocalHost()

D. getHostAddress()

Answer optionc

Marks: 1

300 Which of these is a return type of getData() method of DatagramPacket class

A. Object

B. String

C. byte

D. metadata

Answer optionc

Marks: 1

301 forName is a_______________________type method

A. final

B. static

C. abstract

D. super

Answer optionb

Marks: 1

302 Which from the below use "middle-tier"

A. Three-Tier

B. Four-Tier

C. n-Tier

D. All of above

Answer optiond

Marks: 1

303 Which is interface of following

A. Servlet

B. GenericServlet

C. ServletInputStream

D. HttpServlet

Answer optiona
Marks: 1

304 Tomcat is a _____________

A. Servlet

B. Web Server

C. mail Server

D. File Server

Answer optionb

Marks: 1

305 Which Component are present in following image

A. Button, Label, Table, JProgressbar

B. JButton, JLabel, JTable, Progressbar

C. JButton, JLabel, JTable, JProgressBar

D. JButton, JLabel, Table, Progressbar

Answer optionc

Marks: 2

306 Which of these are integer constants of TextEvent class?

A. TEXT_CHANGED

B. TEXT_FORMAT_CHANGED

C. TEXT_VALUE_CHANGED

D. TEXT_SIZE_CHANGED

Answer optionc

Marks: 2

307 select the proper method to retrive the data from DatagramPacket

A. getContent()

B. getData()

C. getFile()

D. getInfo()

Answer optionb

Marks: 2

308 What happens if you call the method close() on a ResultSet object?

A. the method close() does not exist for a ResultSet. Only Connections can be closed

B. the database and JDBC resources are released

C. you will get a SQLException, because only Statement objects can close ResultSets

D. the ResultSet, together with the Statement which created it and the Connection from which the Statement was retrieved, will be closed and release all datab

Answer optionb

Marks: 2

309 Which of these methods are used to register a mouse motion listener?

A. addMouseMotion()

B. addMouseListener()

C. addMouseMotionListener()

D. addMotionListener()
Answer optionc

Marks: 2

310 which of these events will be generated if we close an applet's window?

A. ActionEvent

B. ComponentEvent

C. AdjustmentEvent

D. WindowEvent

Answer optiond

Marks: 2

import java.net.*;
class networking1 {
public static void main(String[] args) throws UnknownHostException {
InetAddress obj1 = InetAddress.getByName("WWW.google.com");
311 InetAddress obj2 = InetAddress.getByName("www.google.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}

A. TRUE

B. FALSE

C.

D.

Answer optionb

Marks: 2

312 What is correct about DDL statements (create, grant,�)?

A. DDL statements are treated as normal SQL statements, and are executed by calling the execute() method on a Statement(or a sub interface thereof) object

B. To execute DDL statements, you have to install additional support files

C. DDL statements cannot be executed by making use of JDBC,you should use the native databse tools for this.

D. Support for DDl satements will be a feature of a future release of JDBC

Answer optiona

Marks: 2

313 The major difference between servlet and CGI is

A. Servlets are thread based and CGI is process based

B. Servlets executes slower compared to CGI

C. Servlet has no platform specific API, where as CGI has

D. All of the above

Answer optiona

Marks: 2

314 In which of the following cases the request.getAttribute() will be helpful?

A. If a servlet or jsp is invoked using sendRedirect method.

B. If a servlet or jsp is invoked using forword method

C. If a servlet or jsp isinvoked using a hyperlink in the page.

D. If a servlet or jsp invoked if when form submits.

Answer optionb

Marks: 2

315 Which of the following method is used to retrive icon of JButton

A. Icon getIcon()
B. ImageIcon getImageIcon()

C. ImageIcon GetIcon()

D. ImageIcon GetImageIcon()

Answer optiona

Marks: 1

316 What is default alignment of components using FlowLayout

A. FlowLayout.RIGHT

B. FlowLayout.CENTER

C. FlowLayout.LEFT

D. FlowLayout.MIDDLE

Answer optionb

Marks: 1

317 What is the minimum and maximum of JProgressBar

A. minimum -1 Maximum -100

B. minimum -10 Maximum -100

C. minimum -50 Maximum -100

D. minimum -0 Maximum -100

Answer optiond

Marks: 1

318 Which event is generated by List

A. ItemEvent

B. ActionEvent

C. WindowEvent

D. Both A and B

Answer optiond

Marks: 1

319 Which of the following Listeners have their Adapter class

A. ActionListener

B. ItemListener

C. WindowListener

D. AdjustmentListener

Answer optionc

Marks: 1

320 public void mouseMoved(MouseEvent me) is method of _______________

A. MouseListener

B. MouseMotionListener

C. WindowListener

D. ActionListener

Answer optionb

Marks: 1

321 Permission class of java.security package is _______ class


A. static

B. abstract

C. interface

D. final

Answer optionb

Marks: 1

322 Which of the following are class

A. ServletContext

B. Servlet

C. GenericServlet

D. ServletRequest

Answer optionc

Marks: 1

323 Which Layout is used in following o/p

A. GridLayout

B. FlowLayout

C. GridBagLayout

D. BorderLayout

Answer optionc

Marks: 2

Which checkbox will be selected in the following code ( Assume with main and added to a Frame)
Frame myFrame = new Frame("Test");
CheckboxGroup cbg = new CheckboxGroup();
Checkbox cb1 = new Checkbox("First",true,cbg);
Checkbox cb2 = new Checkbox("Scond",true,cbg);
324 Checkbox cb3 = new Checkbox("THird",false,cbg);
cbg.setSelectedCheckbox(cb3);
myFrame.add(cb1);
myFrame.add(cb2);
myFrame.add(cb3);

A. cb1

B. cb2,cb1

C. cb1,cb2,cb3

D. cb3

Answer optiond

Marks: 2

What will be the order of four items added


Choice c1 = new Choice();
c1.add("First");
325 c1.addItem("Second");
c1.add("Third");
c1.insert("Lastadded",2);

A. First,Second,Third,Fourth

B. First,Second,Lastadded,Third

C. Lastadded,First,Second,Third

D. First,Second,Third,Lastadded

Answer optionb

Marks: 2
Select the missing statement in given code
import java.lang.*;
import java.awt.*;
import java.applet.*;
------------------------
public class Exp1_3 extends Frame implements WindowListener
{
public Exp1_3()
{
String msg="";
Button b1=new Button("One");
TextArea t1=new TextArea("Welcome to javaProgramming");
setLayout(new FlowLayout());
add(b1);
add(t1);
--------------------
}
326 public void windowClosing(WindowEvent we)
{
dispose();
System.exit(0);
}
public void windowClosed(WindowEvent we){}
public void windowActivated(WindowEvent we){}
public void windowDeactivated(WindowEvent we){}
public void windowIconified(WindowEvent we){}
public void windowDeiconified(WindowEvent we){}
--------------------
public static void main(String args[])
{
Exp1_3 e1=new Exp1_3();
e1.setVisible(true);e1.setSize(200,200);
}
}

A. import java.awt.event.*;

B. addWindowListener(this);

C. public void windowOpened(WindowEvent we){}

D. All of Above

Answer optiond

Marks: 2

327 What is default value of session attribute in JSP

A. <%@ page session="true" %>

B. <%@ page session="false"%>

C. <%@ page session="yes" %>

D. <%@ page session="no"%>

Answer optiona

Marks: 2

To Send binary output in the response ,the following method of HttpServletResponse may be used to get the appropriate Writer/Stream
328 object

A. getStream()

B. getOutputStream()

C. getBinaryStream()

D. getWriter()

Answer optionb

Marks: 2
Select the missing statement in the following program for following output
import java.awt.*;
public class MenuTest extends Frame
{
MenuTest(String title)
{
super(title);
MenuBar mb=new MenuBar();
Menu file=new Menu("File");
Menu edit=new Menu("Edit");
Menu view=new Menu("View");
MenuItem nw=new MenuItem("New");
MenuItem open=new MenuItem("Open");
329 MenuItem nw1=new MenuItem("Blank document");
file.add(nw);
file.add(open);
mb.add(file);
mb.add(edit);
mb.add(view);
setMenuBar(mb);
}
public static void main(String arg[])
{
MenuTest obj=new MenuTest("My Frame");
obj.setSize(200,400);
obj.setVisible(true);
}}

A. mb.add(open);

B. Menu nw1;

C. nw1.add(nw);

D. nw.add(nw1);

Answer optiond

Marks: 2

What will happen when any item from list is selected


import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*<applet code="cho" width=300 height=300></applet>*/
public class cho extends Applet implements ItemListener
{
TextField t1;
Choice l1;
public void init()
{
t1=new TextField(10);
330 l1=new Choice();
l1.add("sangamner");
l1.add("nasik");
l1.add("pune");
l1.add("mumbai");
add(l1);
add(t1);
l1.addItemListener(this);
}
public void itemStateChanged(ItemEvent e)
{
if(e.getItemSelectable()==l1)
t1.setText(((Choice)e.getItemSelectable()).getSelectedItem());}}

A. No Item from list can be selected

B. Selected item will be displayed in textfield

C. Selected Item will be displayed on applet window

D. Text of textfield is added to list

Answer optionb

Marks: 2
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*<applet code="mlst" width=300 height=300></applet>*/
public class mlst extends Applet implements ActionListener
{
TextArea t1;
List l1;
public void init()
{
t1=new TextArea(" ",10,20,TextArea.SCROLLBARS_VERTICAL_ONLY);
l1=new List(4,true);
l1.add("sangamner");
331 l1.add("nasik");
l1.add("pune");
l1.add("mumbai");
add(l1);
add(t1);
l1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==l1)
for(int i=0;i<((String)l1.getSelectedItem()).length();i++)
{
t1.insert((String)l1.getSelectedItem(),0);
}}}

A. Program will not execute

B. Program will append the selected item in text area when list item is double clicked

C. Program will append the selected item in text area when item from list is selected

D. Program will add text of textarea to list

Answer optionb

Marks: 2

import java.applet.Applet;
For the following code select the method that can be used to handle event
import java.awt.*;
import java.awt.event.*;
/*<applet code="scr" width=300 height=300></applet>*/
public class scr extends Applet implements AdjustmentListener
{
Scrollbar r,g,b;
public void init()
{
r=new Scrollbar(Scrollbar.HORIZONTAL,0,50,0,255);
g=new Scrollbar(Scrollbar.HORIZONTAL,0,50,0,255);
332 b=new Scrollbar(Scrollbar.HORIZONTAL,0,50,0,255);
add(r);
add(g);
add(b);
r.addAdjustmentListener(this);
g.addAdjustmentListener(this);
b.addAdjustmentListener(this);
}
public void _______________________________________
{
Color c=new Color(r.getValue(),g.getValue(),b.getValue());
setBackground(c);
}}

A. adjustmentChanged(AdjustmentEvent e)

B. adjustmentValueChanged(ItemEvent e)

C. adjustmentValueChanged(AdjustmentEvent e)

D. ItemStateChanged(AdjustmentEvent e)

Answer optionc

Marks: 2
What will happen when Button with caption "<" is clicked
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=llist2.java width=300 height=300></applet>*/
public class llist2 extends Applet implements ActionListener
{
List l1,l2;
TextField tdata;
Button badd1,badd2,b1,b2,b3,b4;
public void init()
{
l1=new List(5,true);
l2=new List(5,true);
tdata=new TextField(10);
badd1=new Button("Add1");
badd2=new Button("Add2");
b1=new Button("<");
b2=new Button(">");
b3=new Button("<<");
b4=new Button(">>");
add(l1);
add(b1);
add(b2);
add(b3);
add(b4);
add(badd1);
add(tdata);
add(badd2);
add(l2);
badd1.addActionListener(this);
badd2.addActionListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
333 {
int n;
String s=ae.getActionCommand();
if(s=="Add1")
l1.addItem(tdata.getText());
if(s=="Add2")
{
l2.addItem(tdata.getText());
}

if(s=="<")
{
n=l1.getSelectedIndex();
if(n!=-1)
l2.addItem(l1.getSelectedItem());
}
if(s!=">")
{
n=l2.getSelectedIndex();
if(n!=-1)
l1.addItem(l2.getSelectedItem());
}
if(s=="<<")
{
n=l1.countItems();
for(int i=0;i<n;i++)
{
l1.select(i);
l2.addItem(l1.getSelectedItem());
}}
if(s==">>")
{
n=l2.countItems();
for(int i=0;i<n;i++)
{
l2.select(i);
l1.addItem(l2.getSelectedItem());
}}}}

A. “<” is pressed item from list1 is added to list2

B. “<” is pressed item from list2 is added to list1

C. “<” is pressed text from textfield list1 is added to list2

D. “<” is pressed text from textfield is added to list1

Answer optiona

Marks: 2

Which statements are required in following program to insert one record in table
import java.sql.*;
public class JDBCExample {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connecting to database...");
334 conn = DriverManager.getConnection(jdbc:odbc:stud�);
System.out.println("Inserting records into the table...");
stmt = conn.createStatement();
______________________________________________________
__________________________________________________________________
System.out.println("Inserted records into the table...");
System.out.println("Goodbye!");
}}
String sql = "INSERT INTO Registration "+"VALUES (100, 'Zara', 'Ali', 18)";
A. stmt.executeUpdate(sql);

String sql = "udpate INTO Registration "+"VALUES (100, 'Zara', 'Ali', 18)";
B. stmt.executeUpdate(sql);

String sql = "udpate INTO Registration "+"VALUES (100, 'Zara', 'Ali', 18)";
C. stmt.executeQuery(sql);

D. None of these

Answer optiona

Marks: 2

Which of the following statement should be inserted to display contents of last record and where that statement should be inserted
1.import java.sql.*;
2.public class JDBCExample {
3. public static void main(String[] args) {
4. Connection conn = null;
5. Statement stmt = null;
6. Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver");
7. System.out.println("Connecting to database...");
8.conn = DriverManager.getConnection(jdbc:odbc:stud�);
9.System.out.println("Creating table in given database...");
335 10.System.out.println("Creating statement...");
11. stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
12.String sql = "SELECT id, age FROM Registration";
13. ResultSet rs = stmt.executeQuery(sql);
14. int id = rs.getInt("id");
15. int age = rs.getInt("age");
16. System.out.print("ID: " + id);
17. System.out.print(", Age: " + age); }
18. rs.close();
19. System.out.println("Goodbye!");}}

A. After line no 13 conn.last()

B. Before line no 13 conn.last()

C. After line no 13 rs.last()

D. Before line no 13 rs.last()

Answer optionc

Marks: 2

336 ����.are responsible for placing components on a window

A. Controls

B. EventHandler

C. LayoutManagers

D. both b&c

Answer optionc

Marks: 1

337 We can add menus to _________________________

A. Applets

B. Frames

C. both a& b

D. neither a& b

Answer optionb

Marks: 1

338 Plugable Look & Feel is the feature of

A. AWT

B. Swing

C. Canvas

D. Window

Answer optionb
Marks: 1

339 FileDialog is which kind of dialog box?

A. Floating

B. Modaltype

C. Modeless type

D. both a& b

Answer optionb

Marks: 1

340 Event Listeners are____________________________________

A. Classes

B. Interfaces

C. Abstract Classes

D. Adapter Classes

Answer optionb

Marks: 1

341 TextField generates which events

A. ActionEvent,ItemEvent

B. ActionEvent,TextEvent

C. ScrollEvent,TextEvent

D. ActionEvent,ScrollEvent

Answer optionb

Marks: 1

342 Adapter Class provides_____________________________

A. Empty implementation of all methods of a listener

B. Emplemantation of threads

C. A way to handle threads

D. both b&c

Answer optiona

Marks: 1

343 Which class is used to create client in TCP/IP?

A. ServerSocket

B. DatagramPacket

C. Socket

D. InetAddress

Answer optionc

Marks: 1

______________class is used to access the attributes of a remote host.


344

A. URL

B. URLConnection

C. Socket

D. InetAddress
Answer optionb

Marks: 1

345 In UDP send() and receive() methods belong to which class?

A. Socket

B. ServerSocket

C. DatagramSocket

D. DatagramPacket

Answer optionc

Marks: 1

346 Which driver provides JDBC API access via one or more ODBC drivers

A. ODBC driver

B. JDBC-ODBC bridge driver

C. Native API partly java driver

D. JDBC driver

Answer optionb

Marks: 1

347 Which tag is used to declare one or more variables or methods

A. <%!-----%>

B. <%= ---%>

C. <% %>

D. <%@ %>

Answer optiona

Marks: 1

348 Which swing components use ListSelectionModel

A. JList and JTree

B. JList and JTable

C. Jtree and Jtable

D. JtabbedPane and Jtree

Answer optionb

Marks: 2

349 Which componenet is needed to get the following output?

A. JScrollBar ,imageIcon

B. JScrollPane,Icon

C. JTabbedPane

D. ScrollBar

Answer optionb

Marks: 2
Select the missing statements at ---------------------in bellow program
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code=keydemo width=400 height=400>
</applet>*/
public class keydemo extends Applet implements KeyListener
{
String msg="";
int i=0;
public void init()
{
------------------------------
}
public void keyPressed(KeyEvent e)
{
----------------------------
msg=e.getKeyChar()+"";
repaint();
switch(i)
{
case KeyEvent.VK_UP: showStatus("up key pressed");
break;
case KeyEvent.VK_DOWN: showStatus("Down key pressed");
350 break;
case KeyEvent.VK_ENTER: showStatus("Enter key pressed");
break;
case KeyEvent.VK_LEFT: showStatus("left key pressed");
break;
case KeyEvent.VK_RIGHT: showStatus("right key pressed");
break;
default : showStatus("nothing to print");
}

}
public void keyReleased(KeyEvent e)
{
showStatus("Key released");
}
public void keyTyped(KeyEvent e)
{
msg=e.getKeyChar()+"";
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,100,100);
}
}

A. addKeyListener(this);

B. i=e.getKeyCode();

C. Only A

D. both A and B

Answer optiond

Marks: 2

351 Which are the methods of MouseMotionListener

A. void mouseMoved(MouseEvent e) , void mouseDragged(MouseEvent e)

B. void mousePressed(MouseEvent e), void mouseMoved(MouseEvent e)

C. void mouseWheelMoved(MouseEvent e)

D. void mouseWheelMoved(MouseEvent e), void mouseMoved(MouseEvent e),

Answer optiona

Marks: 2

352 Which constructors of DatagramPacket class are used for receiving purpose?

DatagramPacket(byte data[],int size)


A. DatagramPacket((byte data[],int offset,int size)

B. DatagramPacket(byte data[],int size,InetAddress ipaddr,int port), DatagramPacket((byte data[],int offset,int size,InetAddress ipaddr,int port)

DatagramPacket(byte data[],int size)


C. DatagramPacket(byte data[],int size,InetAddress ipaddr,int port)

D. All

Answer optiond

Marks: 2

353 To set the parameters in PreparedStatement which methods are used?

A. setXXX(int index,value) here XXX indicates datatype like Int,String


B. setObject(int parameterindex,object x)

C. setValue()

D. both a& b

Answer optiond

Marks: 2

354 What the ServletContainer does?

A. Provides the Runtime environment for servlets.

B. Destroys the Servlet

C. Provides the information about servlet environment

D. It gives the Configuration data

Answer optiona

Marks: 2

355 To declare the variables in JSP which tag is used

A. ScriptLet tag

B. Declaration Tag

C. Action Tag

D. Directive Tag

Answer optionb

Marks: 2

Which statements are missing in following program to get the output as shown in fig
/*<applet code=GridBagDemo width=300 height=300>
</applet>*/
import java.awt.*;
import java.applet.*;
public class GridBagDemo extends Applet
{
GridBagLayout gdb=new GridBagLayout();
GridBagConstraints c ______________________________:

Button b1=new Button("One");


Button b2=new Button("Two");
Button b3=new Button("Three");
Button b4=new Button("Four");
Button b5=new Button("Five");
public void init()
{
__________________
c.gridx=0;c.gridy=0;c.weightx=0.5;
c.weighty=0.5;
356 gdb.setConstraints(b1,c);
c.gridx=1;c.gridy=0;
gdb.setConstraints(b2,c);
c.gridx=2;c.gridy=0;
gdb.setConstraints(b3,c);
c.gridx=0;c.gridy=1;
c.gridwidth=3;
c.ipady=20;
c.fill=GridBagConstraints.BOTH;
gdb.setConstraints(b4,c);
c.gridx=0;c.gridy=3;
c.ipady=0;
c.insets=new Insets(20,20,20,20);
c.fill=GridBagConstraints.NONE;
c.anchor=GridBagConstraints.PAGE_START;
c.fill=GridBagConstraints.HORIZONTAL;
gdb.setConstraints(b5,c);
add(b1);add(b2);add(b3);add(b4);add(b5);
}
}

A. c=new GridBagConstraints();

B. setLayout(gdb);

C. setLayout(new GridLayout(4,4));

D. both a& b

Answer optiond

Marks: 2
Consider the following program and find out the method which is wrong and correct it
/*<applet code=TextAreaDemo width=300 height=300>
</applet>*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TextAreaDemo extends Applet implements FocusListener,TextListener
{
TextArea text=new TextArea("AWT stands for Abstract Window ToolKit");
TextField tf=new TextField();
public void init()
{
add(text);
add(tf);
text.addFocusListener(this);
357 text.addTextListener(this);
}
public void focusGained(FocusEvent e)
{
showStatus("TextArea got focus");
}
public void focusLost(FocusEvent e)
{
showStatus("TextArea lost focus");
}
public void valueChanged(TextEvent e)
{
showStatus("change in value of textarea");
}
}

A. The method public void valueChanged(TextEvent e) is wrong it should be public void textValueChanged(TextEvent e)

B. The method public void focusLost(FocusEvent e) is wrong it should be public void lostFocus(FocusEvent e)

C. The method public void valueChanged(TextEvent e) is wrong it should be public void textChanged(TextEvent e)

D. Nothing is wrong

Answer optionc

Marks: 2

Which statements are missing in following program


/*<applet code=ScrollRGB width=300 height=300>
</applet>*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class ScrollRGB extends Applet implements AdjustmentListener
{
Color bkColor;
Scrollbar red=new Scrollbar(Scrollbar.VERTICAL,0,1,0,255);
Scrollbar green=new Scrollbar(Scrollbar.VERTICAL,0,1,0,255);
Scrollbar blue=new Scrollbar(Scrollbar.VERTICAL,0,1,0,255);
int i,j,k;
public void init()
{
add(red);
add(green);

358 green.addAdjustmentListener(this);
blue.addAdjustmentListener(this);
}
public void adjustmentValueChanged(AdjustmentEvent e)
{
if(e.getSource()==red||e.getSource()==green||e.getSource()==blue)
{
i=red.getValue();
j=green.getValue();
k=blue.getValue();
}
repaint();
}
public void paint(Graphics g)
{
bkColor=new Color(i,j,k);
setBackground(bkColor);
}
}

A. add(blue);

add(blue);
B. red.addAdjustmentListener(this);

C. red.addAdjustmentListener(this);

D. Nothing is missing.

Answer optionb

Marks: 2
What is wrong in below program
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code=adaptdemo width=400 height=400>
</applet>*/
public class adaptdemo extends Applet
{
public void init()
{
359 addKeyListener(new keydemo());
}
class keydemo extends MouseAdapter
{
public void keyTyped(KeyEvent e)
{
showStatus("pressed"+e.getKeyChar()+"key");
}
}
}

A. The adaptdemo class should extends KeyAdapter

B. The adaptdemo class should implement KeyListener interface

C. The keydemo class should extends KeyAdapter

D. The keydemo class should implement KeyListener interface

Answer optionc

Marks: 2

What statement should be modified to get the output as shown in fig.


import java.sql.*;
class stud1
{
public static void main(String ar[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:studdsn");
Statement s1=con.createStatement();
ResultSet res;
System.out.println("Before insertion");
res=s1.executeQuery("select * from student");
while(res.next())
360 {
System.out.println("Name\t"+res.getInt(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
Statement st=con.createStatement();
st.executeUpdate("insert into student values('Joshi',10,75)");
System.out.println("inserted");
System.out.println("After insertion");
res=s1.executeQuery("select * from student");
while(res.next())
{
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
}
}

A. System.out.println("Name "+res.getInt(1)+" Roll_NO "+res.getInt(2)+" per "+res.getInt(3)); should be System.out.println("Name "+res.getString(1)+" Roll

B. System.out.println("Name "+res.getInt(1)+" Roll_NO "+res.getInt(2)+" per "+res.getInt(3)); should be System.out.println("Name "+res.getChar(1)+" Roll_N

C. System.out.println("Name "+res.getInt(1)+" Roll_NO "+res.getInt(2)+" per "+res.getInt(3)); should be System.out.println("Name "+res.getChar(1)+" Roll_N

D. System.out.println("Name "+res.getInt(1)+" Roll_NO "+res.getInt(2)+" per "+res.getInt(3)); should be System.out.println("Name "+res.getString(1)+" Roll

Answer optiona

Marks: 2

Find out the missing statement to get the correct output in bellow program
import java.sql.*;
class stud2
{
public static void main(String ar[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:studdsn");
Statement s1;
ResultSet res;
System.out.println("Before deletion");
res=s1.executeQuery("select * from student");
while(res.next())
361 {
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
Statement st=con.createStatement();
st.executeUpdate("delete from student where Roll_No=2");
System.out.println("deleted");
System.out.println("After deletion");
res=s1.executeQuery("select * from student");
while(res.next())
{
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
}
}

A. s1=con.createStatement();
B. s1=con.prepareStatement();

C. s1=createStatement();

D. s1=prepareStatement();

Answer optiona

Marks: 2

Which statements are wrong in below program


import java.sql.*;
class stud5
{
public static void main(String ar[])throws Exception
{
Class.forName("jdbc:odbc:studdsn");
Connection con=DriverManager.getConnection("sun.jdbc.odbc.JdbcOdbcDriver");
Statement s1=con.createStatement();
ResultSet res;
System.out.println("Before insertion");
res=s1.executeQuery("select * from student");
while(res.next())
{
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
362 PreparedStatement st=con.prepareStatement("insert into student values(?,?,?) ");
st.setString(1,"Sayali");
st.setInt(2,45);
st.setInt(3,70);
st.executeUpdate();
st.setString(1,"Katta");
st.setInt(2,43);
st.setInt(3,70);
st.executeUpdate();
System.out.println("After insertion");
res=s1.executeQuery("select * from student");
while(res.next())
{
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
}
}

A. Class.forName("jdbc:odbc:studdsn"); Connection con=DriverManager.getConnection("sun.jdbc.odbc.JdbcOdbcDriver");

B. st=con.prepareStatement("insert into student values(?,?,?) ");

C. st.executeUpdate();

D. res=s1.executeQuery("select * from student");

Answer optiona

Marks: 2

Select the statement from options that should get added at ********************** in bellow program
import java.sql.*;
class stud4
{
public static void main(String ar[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:studdsn");
Statement s1=con.createStatement();
ResultSet res;
System.out.println("Before Updation");
res=s1.executeQuery("select * from student");
while(res.next())
{
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
363
}
PreparedStatement st=con.prepareStatement("update student set Name=? where Name=? ");
st.setString(1,"Ram");
st.setString(2,"Ramesh");
****************************************************
System.out.println("updated");
System.out.println("After updation");
res=s1.executeQuery("select * from student");
while(res.next())
{
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
}
}

A. st.execute();

B. st.executeUpdate();

C. st.executeQuery();

D. st.update();

Answer optionb

Marks: 2
364 Which Among the below is not an AWT class

A. Checkbox

B. RadioButton

C. Button

D. CheckboxGroup

Answer optionb

Marks: 1

365 ____________ can be used to enter and display a string

A. A Label

B. A Button

C. A Checkbox

D. A TextField

Answer optiond

Marks: 1

366 ____________ Layout lays components in a Two Dimensional Grid

A. BorderLayout

B. GridLayout

C. FlowLayout

D. CardLayout

Answer optionb

Marks: 1

367 Which of these methods is used to get x coordinate of the mouse

A. getX()

B. getXCoordinate()

C. getCoordinateX()

D. getPointX()

Answer optiona

Marks: 1

368 A ________________ is an object that is notified when an event occurs

A. Listener

B. Sources

C. Events

D. None

Answer optiona

Marks: 1

369 What is the optional part of URL Address

A. Host Name

B. Port Number

C. File Path

D. Protocol

Answer optionb
Marks: 1

370 Which of the following are Factory Methods of InetAddress class

A. getLocalHost()

B. getByName()

getAllByName()
C.

D. All the Above

Answer optiond

Marks: 1

371 UDP Protocol uses following classes for communication

A. Socket & ServerSocket

B. DatagramPacket and DatagramSocket

C. Both a And B

D. none

Answer optionb

Marks: 1

372 Which among the below is not an interface of java.sql Package

A. Statement

B. PreparedStatement

C. CallableStatement

D. ResultSetStatement

Answer optiond

Marks: 1

373 JSDK stands for

A. Java Server Development Kit

B. Java Servlet Development Kit

C. Java Server Develop Kit

D. Java Servlet Develop Kit

Answer optionb

Marks: 1

374 Which among the below is the class of javax.servlet package

A. Servlet

B. ServletResponse

C. GenericServlet

D. ServletRequest

Answer optionc

Marks: 1

375 Name a class that includes the getSession() method that is used to get the HttpSession

A. HttpServletRequest

B. HttpServletResponse

C. SessionContext

D. SessionConfig
Answer optiona

Marks: 1

376 Which components are used in following output

A. Label,List,Button

B. Label,TextArea,Button

C. TextArea , Button

D. List,Button

Answer optionb

Marks: 2

377 Which of these Events will be notified if scroll bar is manipulated

A. ActionEvent

B. ComponentEvent

C. AdjustmentEvent

D. WindowEvent

Answer optionc

Marks: 2

378 Which Event is generated when a component is added to or removed from a container

A. ComponentEvent

B. ContainerEvent

C. FocusEvent

D. InputEvent

Answer optionb

Marks: 2

379 PrepareStatement() method is of ____________________ interface

A. Connection

B. Statement

C. ResultSet

D. Driver

Answer optiona

Marks: 2

380 Which among the below are methods of Servlet Interface

A. init()

B. service()

C. destroy()

D. All are methods above are of Servlet Interface

Answer optiond

Marks: 2

381 ____________________ method is used to Return the value of the Parameter named pname

A. getParameterNames(pname)

B. getParameterName(pname)

C. getParameterValues(pname)
D. Both A and B

Answer optionb

Marks: 2

What is missing statement here ------------------

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Radiodemo extends JFrame implements ActionListener
{
Container cp;
JRadioButton jb1,jb2,jb3;

Radiodemo(String str)
{
super(str);
cp=getContentPane();
cp.setLayout(new FlowLayout());
jb1=new JRadioButton("Red");
jb2=new JRadioButton("Green");
jb3=new JRadioButton("Blue");

ButtonGroup bg=new ButtonGroup();


bg.add(jb1);
bg.add(jb2);
bg.add(jb3);
cp.add(jb1);
382 cp.add(jb2);
cp.add(jb3);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==jb1)
{
cp.setBackground(Color.red);
}
if(ae.getSource()==jb2)
{
cp.setBackground(Color.green);
}
if(ae.getSource()==jb3)
{
cp.setBackground(Color.blue);
}
}
public static void main(String args[])
{
Radiodemo r=new Radiodemo("Changing Color");
r.setVisible(true);
r.setSize(500,400);
}
}

jb1.addActionListener(this);
A. jb3.addActionListener(this);
jb2.addActionListener(this);

jb2.addActionListener(this);
B. jb3.addActionListener(this);
jb1.addActionListener(this);

jb1.addActionListener(this);
C. jb2.addActionListener(this);
jb3.addActionListener(this);

D. All of the above

Answer optiond

Marks: 2
Select the missing statement in the program

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
<applet code="combodemo" width=300 height=100>
</applet>
*/
public class combodemo extends JApplet
implementsItemListener
{
JLabeljl;
ImageIconfrance, germany, italy, japan;
public void init()
{
383 Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JComboBoxjc = new JComboBox();
jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");
jc.addItemListener(this);
contentPane.add(jc);
contentPane.add(jl);
}
public void itemStateChanged(ItemEventie)
{
String s = (String)ie.getItem();
jl.setIcon(new ImageIcon(s + "star.gif"));
}
}

A. jl = new JLabel(new ImageIcon("star.gif"));

B. jl = new JLabel("star.gif");

C. jl = JLabel( ImageIcon("star.gif"));

D. JLabel(new ImageIcon("star.gif"));

Answer optiona

Marks: 2

Consider the following output. Find the missing statement in the program.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/*
<applet code="SimpleKey1" width=300 height=100>
</applet>
*/
public class SimpleKey1 extends JApplet implements KeyListener
{
String msg = "";
int X = 10, Y = 20;
public void init()
{
addKeyListener(this);
requestFocus();
384 }
public void keyPressed(KeyEvent ke)
{
showStatus("Key Down");
}
public void keyReleased(KeyEvent ke)
{
showStatus("Key Up");
}
public void keyTyped(KeyEvent ke)
{
msg += ke.getKeyChar();
}
public void paint(Graphics g)
{
g.drawString(msg, X, Y);
}
}

A. paint();

B. paintGraphics()

C. repaint();

D. None of these

Answer optionc

Marks: 2
Consider the following program.
What will be the output?
import java.sql.*;
class Ddemo1
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
385 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();
}
}

A. Display All the Records of StudTable

B. Update the Records of StudTable

C. Insert the Records of StudTable

D. Create a Table StudTable and display it's Records

Answer optiona

Marks: 2

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.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
Statement s=c.createStatement( );
386 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.getDouble(3));
}
s.close();
c.close();
}
}

A. s.executeUpdate()

B. c.createStatement( )

C. s.close()

D. c.close()

Answer optiona

Marks: 2

Consider the following program.Find out the output ?

import java.sql.*;
class Ddemo1
{
public static void main(String args[]) throws Exception
{
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
387 PreparedStatement s=c.prepareStatement("insert into student values (?,?));
s.setString(1,"Riya");
s.setString(2,17);
int i=s.executeUpdate();
System.out.println("Record Updated");
s.close();
c.close();
}
}

A. Riya will be inserted in first column and 17 will be inserted in second column

B. 17 will be inserted in first column and Riya will be inserted in second column

C. only 17 will be inserted in second column

D. only Riya will be inserted in first column

Answer optiona
Marks: 2

Choose missing statements in following code from given options.

public class session1 extends HttpServlet


{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
HttpSession hs = request.getSession(true);
response.setContentType("text/html");
388 PrintWriter pw = response.getWriter();
pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. Missing semicolon

B. Missing package statement

C. Missing initialization

D. None of the above

Answer optionb

Marks: 2

Choose missing statements in following code from given options.


import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*;
public class session1 extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
389 response.setContentType("text/html");
String p1=req.getParameter("T1");
String p2=req.getParameter("T2");
pw.print(p1);
pw.print(p2);
pw.close();
}
}

A. Missing semicolon

B. Missing Object of PrintWriter

C. Missing Header File

D. None of the above

Answer optionb

Marks: 2

In following Java program fill statement showing ***.Select any one option fro given options

import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
390 String data = request.getParameter("data");
Cookie cookie = new Cookie("MyCookie", data);
response.addCookie(*************);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. cookie

B. "cookie"

C. data

D. cookies

Answer optiona

Marks: 2
What will be the outpt of the Program
import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*;
public class session1 extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
HttpSession hs = request.getSession(true);
response.setContentType("text/html");
391 PrintWriter pw = response.getWriter();
pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. Display the Last Session Date

B. Display the Current Date

C. Display the Last Session Date and the Current Date

D. None of the above

Answer optionc

Marks: 2

392 Which class is used to represent a single line textbox with password character facility?

A. TextField

B. TextArea

C. Label

D. Checkbox

Answer optiona

Marks: 1

393 Which of the following is not valid alignment constant for Label?

A. CENTER

B. LEFT

C. RIGHT

D. MIDDLE

Answer optiond

Marks: 1

394 ___________________ class is used to display hierarchical data.

A. JTable

B. Jpanel

C. JTree

D. JApplet

Answer optionc

Marks: 1

395 Which of the following is not valid style constant for Font?

A. BOLD

B. ITALIC

C. NORMAL

D. PLAIN

Answer optionc
Marks: 1

396 Which of the following is not true about Swing Components?

A. Pluggable look and feel

B. Heavy weight components

C. ToolTips

D. Border and Icon support

Answer optionb

Marks: 1

397 Which of the following is not valid constructor for JCheckBox?

A. JCheckBox()

B. JCheckBox(String text)

C. JCheckBox(String text, boolean selected, CheckboxGroup group)

D. JCheckBox(Icon icon)

Answer optionc

Marks: 1

398 The following method is an abstract method of TextListener interface.

A. actionPerformed(ActionEvent obj)

B. textChanged(TextEvent obj)

C. itemStateChanged(ItemEvent obj)

D. adjustmentValueChanged(AdjustmentEvent obj)

Answer optionb

Marks: 1

399 Which constant is define by ItemEvent?

A. ITEM_CHANGED_STATE

B. ITEM_CHANGE_STATE

C. ITEM_STATE_CHANGE

D. ITEM_STATE_CHANGED

Answer optiond

Marks: 1

400 The factory method for retrieving objects of InetAddress is ___________________.

A. getByName(String hostname)

B. getAllByName(String hostname)

C. getLocalHost()

D. All of the mentioned

Answer optiond

Marks: 1

401 Connection oriented communication is possible using ___________________classes of Java.

A. Socket and ServerSocket

B. DatagramSocket and DatagramPacket

C. All of the mentioned

D. None of the mentioned


Answer optiona

Marks: 1

402 The valid sequence for URL format is ___________________

A. Hostname, protocol, portnumber, filepath

B. protocol, Hostname, portnumber, filepath

C. Hostname, portnumber, protocol, filepath

D. protocol, port number, Hostname, filepath

Answer optionb

Marks: 1

403 ___________________ method of DatagramSocket class is used to receive DatagramPacket.

A. receive(InetAddress port)

B. send(DatagramPacket packet)

C. receive(DatagramPacket packet)

D. connect(InetAddress address, int portnumber)

Answer optionc

Marks: 1

404 The valid constant to represent ResultSet type is ___________________

A. TYPE_FORWARD_ONLY

B. TYPE_SCROLL_SENSITIVE

C. TYPE_SCROLL_INSENSITIVE

D. All of the mentioned

Answer optiond

Marks: 1

405 ___________________ interface represents the comprehensive information about the database package.

A. DatabaseMetaData

B. ResultSetMetaData

C. ParameterMetaData

D. All of the mentioned

Answer optiona

Marks: 1

406 Session management is possible using ___________________

A. URL Rewriting

B. Cookies

C. HttpSession

D. All of the mentioned

Answer optiond

Marks: 1

407 Following method is not valid life cycle method of JSP

A. jspInit()

B. _jspService()

C. jspStop()
D. jspDestroy()

Answer optionc

Marks: 1

408 Which components are required to display following output?

A. Frame, Label, TextField, Button

B. Frame, TextField, Checkbox, Button

C. Frame, Label, CheckboxGroup, Button

D. Frame, List, Label, Button

Answer optionc

Marks: 2

What is missing in the following program code?

import java.awt.*;
-------------------------

public class DemoFrame extends Frame --------------


{
public DemoFrame()
{
this.setBounds(50,50,400,300);
this.setVisible(true);
-------------------------
}
public void windowOpened(WindowEvent obj)
{
}
public void windowClosed(WindowEvent obj)
{
}
public void windowClosing(WindowEvent obj)
{
409
System.exit(0);
}
public void windowActivated(WindowEvent obj)
{
}
public void windowDeactivated(WindowEvent obj)
{
}
public void windowIconified(WindowEvent obj)
{
}
public void windowDeiconified(WindowEvent obj)
{
}
public static void main(String args[])
{
DemoFrame f = new DemoFrame();
}

A. import java.awt.event.*;

B. implements WindowListener

C. addWindowListener(this);

D. All of the mentioned

Answer optiond

Marks: 2

410 Which of the following methods of ItemListener must be overriden in order to handle ItemEvent?

A. public void itemStateChanged(ItemEvent obj)

B. public void itemChanged(ItemEvent obj)

C. public void actionPerformed(ActionEvent obj)

D. public void addItemListener(ItemListener obj)

Answer optiona

Marks: 2

411 Which of the following statements is true about MouseMotionListener?

A. import java.awt.event package.

B. use method addMouseMotionListener(MouseMotionListener obj)


C. override mouseMoved(MouseEvent obj) and mouseDragged(MouseEvent obj) methods

D. All of the mentioned

Answer optiond

Marks: 2

412 Identify the valid ServerSocket constructor.

A. public ServerSocket(String hostname, int portno)

B. public ServerSocket(InetAddress hostaddress, int portno)

C. public ServerSocket(int port,int maxQueue,InetAddress localaddress)

D. All of the mentioned

Answer optionc

Marks: 2

413 Identify the valid method of URL class.

A. public String getProtocol()

B. public String getHost()

C. public String getFile()

D. All of the mentioned

Answer optiond

Marks: 2

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);
414 String msg="hello";
byte b[]=msg.getBytes();
InetAddress ip=InetAddress.getByName("CLIENT-PC");
int port=3000;
DatagramPacket dp=new DatagramPacket(b,b.length,ip,port);
System.out.println("message sent...");
}
}

A. import java.net.*;

B. ds.send(dp);

C. A & B

D. None of the mentioned

Answer optionc

Marks: 2

415 DriverManager class does not provides methods for ___________________

A. Registering and deregistering database driver

B. Retrieving Connection with database specified by DSN in jdbc url

C. Executing sql statement and retrieving results

D. All of the mentioned

Answer optionc

Marks: 1

416 Select advantage of JSP from the following -

A. JSP allows embedding Dynamic Elements in HTML Pages.

B. JSP are always compiled before it is processed by the server.

C. JSP is used in combination with servlets to handle business logic.


D. All of the mentioned

Answer optiond

Marks: 2

417 The following method of HttpServlet is invoked in response to HTTP POST request.

A. doGet()

B. doPost()

C. doTrace()

D. doPut()

Answer optionb

Marks: 2

Which statement is required in order to complete the following program code?

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet {

private String message;

public void init() throws ServletException


{
message = "Hello World";
}

418 public void doGet(HttpServletRequest request,


HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");

-------------------------
out.println("<h1>" + message + "</h1>");
}

public void destroy()


{
// do nothing.
}
}

A. PrintWriter out = response.getWriter();

B. PrintWriter out= new PrintWriter();

C. OutputStream out= response.getOutputSream();

D. BufferedOutputStream out = response.getOutputStream();

Answer optiona

Marks: 2

Complete the following code for following output.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class DemoApplet extends JApplet implements ActionListener


{
JTextField number,result;
JButton b;
Container c;
public void init()
419 {
c = this.getContentPane();
this.setLayout(new FlowLayout());
number = new JTextField(10);
c.add(number);
b = new JButton("Square");
b.addActionListener(this);
c.add(b);
result= new JTextField(10);
c.add(result);
}
}

public void actionPerformed(ActionEvent obj)


{
A. int n = Integer.parseInt(number.getText());
result.setText("Square="+(n*n));
}
public void itemStateChanged(ItemEvent obj)
{
B. int n = Integer.parseInt(number.getText());
result.setText("Square="+(n*n));
}

public void actionPerformed(ActionEvent obj)


{
C. int n = Integer.parseInt(number.getText());
result.setText("Cube="+(n*n*n));
}

public void actionPerformed(ActionEvent obj)


{
D. int n = Integer.parseInt(number.getText());
result.setText("Square="+(n*n*n));
}

Answer optiona

Marks: 2

420 getKeyChar() and getKeyCode() methods belongs to _____________________

A. KeyListener interface

B. KeyEvent class

C. TextEvent class

D. ItemEvent class

Answer optiona

Marks: 2

The following Server program _____________________

import java.net.*;
import java.io.*;
public class Server {
public static void main(String args[]) throws IOException
{
ServerSocket ss = new ServerSocket(2000);
421 while(true)
{
Socket cs = ss.accept();
PrintWriter pw = new PrintWriter(cs.getOutputStream());
pw.println("welcome");
pw.close();
}
}
}

waits for client request at 2000 port number


A. and accepts welcome message from all clients

waits for client request at 2000 port number


B. and sends welcome message to all clients

C. All of the mentioned

D. None of the mentioned

Answer optionb

Marks: 2

Suggest corrections in the following program segment

import java.sql.*;
import sun.jdbc.odbc.*;
class mydatabase
{
public static void main(String args[])
{
422 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection();
Statement stmt=con.createStatement();
stmt.execute("create table contacts(name varchar(30),mobile varchar(20))");
con.close();
System.out.println("table created...");
}
}

A. public static void main(String args[]) throws SQLException

public static void main(String args[]) throws IOException


B. DriverManager.getConnection("student");

public static void main(String args[]) throws SQLException


C. DriverManager.getConnection("jdbc:odbc:mydsn");

D. public static void main(String args[]) throws JdbcURLException

Answer optionc
Marks: 2

import java.sql.*;
import sun.jdbc.odbc.*;
class mydatabase
{
public static void main(String args[]) throws SQLException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
423 PreparedStatement pstmt=con.prepareStatement("update student set branch=? where branch=?");
pstmt.setString(1,"CO");
pstmt.setString(2,"CM");
stmt.executeUpdate();
con.close();
System.out.println("record updated...");
}
}

A. this program will not change branch codes of all students from 'CO' to 'CM'.

B. this program will change table name of student from 'CM' to 'CO'.

C. this program will change column name of student table from 'CM' to 'CO'.

D. this program will change branch codes of all students from 'CO' to 'CM'.

Answer optiond

Marks: 2

424 The method - "public DatabaseMetaData getMetaData()" - belongs to the Interface _____________________

A. PreparedStatement interface

B. ResultSet interface

C. Statement interface

D. Connection interface

Answer optiond

Marks: 2

425 Valid constant to set ResultSet as Scrollable is _____________________

A. ResultSet.TYPE_FORWARD_ONLY

B. ResultSet.TYPE_SCROLL_SENSITIVE

C. ResultSet.TYPE_SCROLL_INSENSITIVE

D. Both B and C

Answer optiond

Marks: 2

JSP directives provide directions and instructions to the container,


426 telling it how to handle certain aspects of JSP processing. There are three types
of JSP directives and they are ___________________

<%@ page ... %>


A. <%@ include ... %>
<%@ taglib ... %>

<%@ page ... %>


B. <%@ import ... %>
<%@ taglib ... %>

<%@ page ... %>


C. <%@ command ... %>
<%@ taglib ... %>

<%@ page ... %>


D. <%@ include ... %>
<%@ import ... %>

Answer optiona

Marks: 2

427 Which of the following creates a List with 5 visible items and multiple selection enabled?

A. new List(true, 5)

B. new List(5, true)


C. new List(5, false)

D. new List(false,5)

Answer optionb

Marks: 1

428 Which method will cause a Frame to be displayed?

A. paint( )

B. setVisible( true)

C. display( )

D. setVisible(false)

Answer optionb

Marks: 1

429 Which of the following components allow multiple selections?

A. Combo box

B. Radio buttons

C. Choice

D. List

Answer optiond

Marks: 1

430 Which layout should you use to organize the components of a container in a tabular form?

A. CardLayout.

B. BorderLayout.

C. FlowLayout.

D. GridLayout

Answer optiond

Marks: 1

431 Which method is used to set the layout of the Applet?

A. setLayoutManager();

B. setLayout();

C. setGridLayout();

D. setBorderLayout();

Answer optionb

Marks: 1

432 Which of these methods is used to obtain the object that generated a ComponentEvent.

A. getMethod()

B. getComponent()

C. getContainerEvent()

D. getContainerObject()

Answer optionb

Marks: 1

433 Which of these methods is used to get Y coordinate of the mouse?

A. getPointY()
B. getY()

C. getCoordinate()

D. getCoordinateY()

Answer optionb

Marks: 1

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

A. URL

B. URLDecoder

C. URLConnection

D. All of the above

Answer optionc

Marks: 1

435 For execution of SELECT SQL query in JDBC, ___________________ method must be used.

A. executeQuery()

B. executeUpdate()

C. executeBatch()

D. executeSELECT()

Answer optiona

Marks: 1

436 Callable statement object in JDBC is used to execute a call to

A. stored procedure

B. called procedure

C. simple procedure

D. High Level procedure

Answer optiona

Marks: 1

437 Name the interface which is used to get initialization parameters for Servlet

A. Servlet

B. ServletRequest

C. ServletContext

D. ServletConfig

Answer optiond

Marks: 1

438 Which is the correct constructor for JProgressBar

A. JProgressBar()

B. JProgressBar(int orient)

C. JProgressBar(int min, int max)

D. All of the above

Answer optiond

Marks: 1
Select the missing statement in given code
import java.awt.*;
import java.awt.event.*;

class AEvent extends Frame implements ActionListener{


TextField tf;
AEvent(){

tf=new TextField();
Button b=new Button("click me");
add(b);
add(tf);

439 setSize(300,300);
setLayout(null);
setVisible(true);

public void actionPerformed(ActionEvent e){


tf.setText("Welcome");
}

public static void main(String args[]){


new AEvent();
}
}

A. addActionListener(b);

B. b.addActionListener();

C. b.addActionListener(this);

D. addActionListener(this);

Answer optionc

Marks: 2

To get the following output complete the code given below.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class SimpleTableExample extends JFrame


{
private JPanel topPanel;
private JTable table;
private JScrollPane scrollPane;

public SimpleTableExample()
{
setTitle( "Simple Table Application" );
setSize( 300, 200 );
setBackground( Color.gray );

topPanel = new JPanel();


topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel );
440
String columnNames[] = { "Column 1", "Column 2", "Column 3" };

String dataValues[][] =
{
{ "12", "234", "67" },
{ "-123", "43", "853" },
{ "93", "89.2", "109" },
{ "279", "9033", "3092" }
};

topPanel.add( scrollPane, BorderLayout.CENTER );


}

public static void main( String args[] )


{
SimpleTableExample mainFrame = new SimpleTableExample();
mainFrame.setVisible( true );
}
}

table = new JTable( dataValues);


A.
scrollPane = new JScrollPane( table );

table = new JTable( dataValues, columnNames );


B.
scrollPane = new JScrollPane( table );

table = new Jtable(data, column);


C.
scrollPane = new JScrollPane( table );

D. None of the above

Answer optionb

Marks: 2

441 Select the method which throws UnKnownHostException


A. static InetAddress getLocalHost()

B. static InetAddress getByName(String hostName)

static InetAddress[ ] getAllByName(String hostName)


C.

D. All of the above

Answer optiond

Marks: 2

442 Select the proper constructor of the Socket class

A. Socket(String host, int port)

B. Socket(int port)

C. Socket(InetAddress ipAddress)

D. Socket(String hostName)

Answer optiona

Marks: 2

443 Which is not a Navigation method of ResultSet interface

A. next()

B. last()

C. beforeLast()

D. beforeFirst()

Answer optionc

Marks: 2

In Session tracking which method is used in a bit of information that is sent by a web server to a browser and which can later be
444 read back from that browser?

A. HttpSession

B. URL rewriting

C. Cookies

D. Hidden from Fields

Answer optionc

Marks: 2

Difference between JSP and Servlet is______________________________________. Select any of given options
A) In MVC, jsp act as a view.
B) Servlets run faster compared to JSP.
445
C) In MVC, servlet act as a controller.
D) Using JSP, we can build custom tags which can directly call Java beans.

A. All above are valid differences

B. Only A and B

C. Only C and D

D. A, B, C are valid diffrences.

Answer optiona

Marks: 2
//Find out the error.
import javax.swing.JFrame;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.tree.DefaultMutableTreeNode;

public class TreeExample extends JApplet


{
JTree tree;
public void init()
{
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
446 DefaultMutableTreeNode vegetableNode = new DefaultMutableTreeNode("Vegetables");
DefaultMutableTreeNode fruitNode = new DefaultMutableTreeNode("Fruits");

root.add(vegetableNode);
root.add(fruitNode);

tree = new JTree();


add(tree);

}
}
/*<applet code=�TreeExample� width=300 height=300>
</applet>*/

A. Error in statement in which Vegetables node is created

B. Error in statement in which JTree is created

C. Error in statement in which applet tag is declared

D. None of the above

Answer optionb

Marks: 2

Select the proper command to run the following code


import javax.awt.*
import javax.swing.*;
public class JListDemo extends JApplet
{
JTextField t1;
JList jl;
String data[ ]={�Red�, �Green�, �Blue�, �Yellow�, �Pink�};

Public void init()


{
447
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
T1=new JList(data);
cp.add(jl);
cp.add(t1);

}
}
/*<applet code=�JListDemo� width=300 height=300>
</applet>*/

A. java JListDemo

B. java JListDemo.java

C. appletviewer JListDemo.java

D. None of the above

Answer optionc

Marks: 2
Consider the following output. Find the missing statement in the program.
import java.awt.Frame;
import java.awt.event.*;

public class HandleMouseListenerInWindowExample extends Frame implements MouseListener{

int x=0, y=0;


String strEvent = "";
HandleMouseListenerInWindowExample(String title){

super(title);
addWindowListener(new MyWindowAdapter(this));
addMouseListener(this);
setSize(300,300);
setVisible(true);
}
public void mouseClicked(MouseEvent e) {

strEvent = "MouseClicked";
x = e.getX();
y = getY();
repaint();
}
public void mouseReleased(MouseEvent e) {
448 strEvent = "MouseReleased";
x = e.getX();
y = getY();
repaint();
}
public void paint(Graphics g){
g.drawString(strEvent + " at " + x + "," + y, 50,50);
}
public static void main(String[] args) {

HandleMouseListenerInWindowExample myWindow =
new HandleMouseListenerInWindowExample("Window With Mouse Events Example");
}
}
class MyWindowAdapter extends WindowAdapter{

HandleMouseListenerInWindowExample myWindow = null;

MyWindowAdapter(HandleMouseListenerInWindowExample myWindow){
this.myWindow = myWindow;
}
public void windowClosing(WindowEvent we){
myWindow.setVisible(false);
}

public void mouseExited(MouseEvent e) {


strEvent = "MouseExited";
x = e.getX();
A. y = getY();
repaint();
}

public void mouseEntered(MouseEvent e) {


strEvent = "MouseEntered";
x = e.getX();
B. y = getY();
repaint();
}

public void mousePressed(MouseEvent e) {


strEvent = "MousePressed";
x = e.getX();
C. y = getY();
repaint();

D. all of the Above

Answer optiond

Marks: 2

Consider the following code. Find the missing statement.


public class MyClass extends Frame
{
public static void main(String args[])
{
MyClass win=new MyClass();
}
public MyClass()
{
super(�Window Events being tested�);
449 setSize(150,100);
setVisible(true);
}
class WidnowEventHandler extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
}

A. addComponentListener()

B. addContainerListener()

C. addWindowListener()

D. addActionListener()
Answer optionc

Marks: 2

Consider the following code and identify the error.


import java.awt.*;
import javax.swing.*;
import javax.swing.JScrollPane;
/*<applet code=�JScrollPane1� width=150 height=150>
</applet>
*/
public class JSCrollPane1 extends JApplet
{
public void init()
{
Container cp=getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel jp=new JPanel();
jp.setLayout(new GridLayout(10,10));
450 Char b=�A�;
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
jp.add(new JButton(�Button�+b));
++b;
}
}
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h= ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(v,h);
cp.add(jsp,BorderLayout.CENTER);
}
}

A. Error in applet tag

B. Error in package statement

C. Error in statement scrollpane is created

D. Error in statement panel is created

Answer optionc

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;

public class JdbcConnection {

public static void main(String a[]){

try {
Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver");
451 Connection con = DriverManager.getConnection("jdbc:odbc:abc");
Statement stmt = con.createStatement();
System.out.println("Created DB Connection....");
} catch (ClassNotFoundException e) {
System.out.println(e);
} catch (SQLException e) {
System.out.println(e);

}
}

A. Missing semicolon

B. Missing {

C. Missing }

D. Missing statement

Answer optionc

Marks: 2
Consider the following program.
What should be the correction done in the program to get correct output?
import java.sql.*;

public class JdbcConnection {

public static void main(String a[]){

try {
Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:abc");
Statement stmt = con.createStatement();
String s1=�select company,num,cost,memory_capacity from comp order by num�;
ResultSet rs=stmt.executeQuery(s1);
452 System.out.println(�Company�+� � +�num�+� �+�cost�+� �+memory_capacity�);
System.out.println();
While(rs.next())
{
System.out.println(rs.getString(�company�)+� �+rs.getInt(�num�)+
� �+rs.getInt(�cost�)+� �+rs.getString(�memory_capacity�))
}
con.close();
} catch (ClassNotFoundException e) {
System.out.println(e);
} catch (SQLException e) {
System.out.println(e);
}
}
}

A. Missing semicolon

B. Missing {

C. Missing }

D. Missing statement

Answer optiona

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;

public class JdbcTest {

public static void main(String a[]){

try {
Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver");
453 Connection con = DriverManager.getConnection("jdbc:odbc:xyz");
Statement stmt = con.getStatement();
stmt.executeUpdate(�delete from student�);
con.close();
} catch (ClassNotFoundException e) {
System.out.println(e);
} catch (SQLException e) {
System.out.println(e);
}
}
}

A. Error in main()

B. Error in close()

C. Eror in creation of connection object

D. Error in creation of Statement object

Answer optiond

Marks: 2
Consider the following program.
What should be the correction done in the program to get correct output?

import java.sql.*;

public class JdbcTest {

public static void main(String a[])


{

try {
Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:xyz");
PreparedStatement stmt = con.prepareStatement(�Insert into employee values(?,?,?,?,?�);
454 stmt.setInt(1,23);
stmt.setString(2,�Roshan�);
stmt.setString(3,�Sales�);
stmt.setString(4,�Manager�);
stmt.setInt(5,20000);
stmt.executeUpdate();
con.close();
catch (ClassNotFoundException e) {
System.out.println(e);
} catch (SQLException e) {
System.out.println(e);
}
}
}

A. Missing semicolon

B. Missing {

C. Missing }

D. Missing statement

Answer optionc

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;

public class JdbcTest {

public static void main(String a[]){

try {
Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:xyz");
stmt.executeUpdate(�Update Employee set Basic=
Basic+(Basic*0.10)�);
455 ResultSet rs=stmt.executeQuery(�Select * from Employee�);
while(rs.next())
{
System.out.println(rs.getInt(1)+� �+rs.getString(2)+� �+rs.getString(3)+� �+rs.getString(4)+� �+rs.getFloat(5));
}
con.close(); stmt.close();
}
catch (ClassNotFoundException e) {
System.out.println(e);
} catch (SQLException e) {
System.out.println(e);
}
}
}

A. stmt.executeUpdate()

B. con.createStatement()

C. con.close()

D. stmt.close()

Answer optionb

Marks: 2

Choose missing statements in following code from given options.


public class ColorGetSevlet extends HttpServlet
{
public void doGet(HtttpServletRequest request, HttpServletRespose response) throws ServletException, IOException
{
String color=request.getParameter(�color�);
456 Respose.setContentType(�text/html�);
PrintWriter pw=response.getWriter();
pw.println(�<B>The selected color is:�);
pw.println(color);
pw.close();
}
}

A. import java.io.*;import java.util.*;import javax.servlet.*;

B. import java.io.*; import javax.servlet.*; import javax.servlet.http.*;


C. import javax.servlet.http.*; import java.String.*; import java.Vector;

D. import javax.servlet.http.*; import java.Thread.*; import javax.Client.*;

Answer optionb

Marks: 2

Consider the following program and identify the missing statement.


public class Hellot extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res)
{
String data= request.getParameter(�data�);
resp.setContentType(�text/html�);
PrintWriter pw=res.getWriter();
457 String name=req.getParameter(�name�);
out.Println(�<HTML>�);
out.Println(�<HEAD><TITLE>Hello,�+name+</TITLE></HEAD>�);
out.Println(�<BODY>�);
out.Println(�Hello,�+name);
out.Println(�</BODY></HTML>�);
}
}

A. Missing semicolon

B. Missing package statement

C. Missing initialization

D. None of the above

Answer optionb

Marks: 2

458 ______________method returns a reference to the component that was added to or removed from the container.

A. getContainer()

B. getChild()

C. getValue()

D. None of these

Answer optionb

Marks: 1

459 Which of these methods is defined in ContainerListener interface?

A. componentResized()

B. componentAdded()

C. componentShown()

D. componentHidden()

Answer optionb

Marks: 1

460 Type 1 driver is also known as

A. JDBC-Native API

B. JDBC-ODBC Bridge Driver

C. JDBC-net pure java

D. Noe of these

Answer optionb

Marks: 1

461 By which method You can set or change the text in a Label?

A. setText()

B. getText()

C. Both A & B
D. None of the above

Answer optiona

Marks: 2

Fill in blank

import java.awt.*;
import java.awt.event.*;
public class MClick extends Frame implements --------------------------
{
public static void main(String argv[]){
462 MClick s = new MClick();
}
MClick(){
this.addMouseListener(this);
}

public void mouseClicked(MouseEvent e){


System.out.println(e.getWhen());
}
}

A. MouseListener()

B. ItemListener

C. Action Listener

D. AdjustmentListener

Answer optiona

Marks: 2

What will be output of program when "Ok" button is pressed?


import java.applet.Applet;
import java.awt.Button;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/*
<applet code="HandleActionEventExample" width=200 height=200>
</applet>
*/

public class HandleActionEventExample extends Applet implements ActionListener{

String actionMessage="";

public void init(){


Button Button1 = new Button("Ok");
Button Button2 = new Button("Cancel");

add(Button1);
463 add(Button2);

Button1.addActionListener(this);
Button2.addActionListener(this);
}

public void paint(Graphics g){


g.drawString(actionMessage,10,50);
}

public void actionPerformed(ActionEvent ae){


String action = ae.getActionCommand();

if(action.equals("Ok"))
actionMessage = "Ok Button Pressed";
else if(action.equals("Cancel"))
actionMessage = "Cancel Button Pressed";

repaint();
}
}

A. OK button pressed

B. Cancel button pressed

C. Ok Cancel button pressed

D. No button pressed

Answer optiona

Marks: 2
What is output of following program?

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Button;

/*
<applet code="DetermineIfButtonEnabled" width=100 height=200>
</applet>
*/

public class DetermineIfButtonEnabled extends Applet{

boolean isButton1Enabled;
boolean isButton2Enabled;

public void init(){


//create Buttons
Button Button1 = new Button("Ok");
464 Button Button2 = new Button("Cancel");

//add Buttons
add(Button1);
add(Button2);

Button1.setEnabled(false);

isButton1Enabled = Button1.isEnabled();
isButton2Enabled = Button2.isEnabled();

public void paint(Graphics g){


g.drawString("Is Button 1 enabled? " + isButton1Enabled, 10,50);
g.drawString("Is Button 2 enabled? " + isButton2Enabled, 10,70);
}

Is Button 1 enabled?False
A. Is Button 2enabled?False

Is Button 1 enabled?false
B. Is Button 2 enabled?true

Is Button 1 enabled?True
C. Is Button 2 enabled?False

Is Button 1 enabled?True
D. Is Button 2 enabled?True

Answer optionb

Marks: 2

465 Connection object can be initialized using the ............................ method of the Driver Manager class.

A. putConnection()

B. setConnection()

C. Connection()

D. getConnection()

Answer optiond

Marks: 1

466 These methods doGet(),doPost(),doDelete(),doTrace() are used in?

A. Genereic Servlets

B. HttpServlets

C. Both A & B

D. None of the above

Answer optionb

Marks: 2
What is output of follwing programmissing statement?
import java.awt.*;
import javax.swing.*;

public class MyGridLayout{


JFrame f;
MyGridLayout(){
f=new JFrame();

JButton b1=new JButton("1");


JButton b2=new JButton("2");
JButton b3=new JButton("3");
JButton b4=new JButton("4");
JButton b5=new JButton("5");
JButton b6=new JButton("6");
467 JButton b7=new JButton("7");
JButton b8=new JButton("8");
JButton b9=new JButton("9");

f.add(b1);f.add(b2);f.add(b3);f.add(b4);f.add(b5);
f.add(b6);f.add(b7);f.add(b8);f.add(b9);

f.setLayout(new GridLayout(3,3));

f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new MyGridLayout();
}
}

A. Buttons are displayed in 3 rows and 3 columns

B. Buttons are displayed in 3 rows and 4 columns

C. Buttons are displayed in 3 rows and2 columns

D. Buttons are displayed in 2 rows and 4columns

Answer optiona

Marks: 2

Write the missing code?


import javax.swing.*;
public class Radio {
JFrame f;

Radio(){
f=new JFrame();

JRadioButton r1=new JRadioButton("A) Male");


JRadioButton r2=new JRadioButton("B) FeMale");
r1.setBounds(50,100,70,30);
r2.setBounds(50,150,70,30);
468 ButtonGroup bg=new ButtonGroup();
bg.add(r1);bg.add(r2);

----------------------------------
-----------------------------
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new Radio();
}
}

f.add(r1);
A. f.add(r2);

B. f.add(r1);

C. f.add(r2);

D. None of above

Answer optiona

Marks: 2
What is use of of using action listeners in the following program?
import java.applet.*;
import java.awt.event.*;
import java.awt.*;

public class EventListeners extends Applet implements ActionListener{


TextArea txtArea;
String Add, Subtract,Multiply,Divide;
int i = 10, j = 20, sum =0,Sub=0,Mul = 0,Div = 0;

public void init(){


txtArea = new TextArea(10,20);
txtArea.setEditable(false);
add(txtArea,"center");
Button b = new Button("Add");
Button c = new Button("Subtract");
Button d = new Button("Multiply");
Button e = new Button("Divide");
b.addActionListener(this);
c.addActionListener(this);
d.addActionListener(this);
e.addActionListener(this);

add(b);
add(c);
add(d);
add(e);
}

public void actionPerformed(ActionEvent e){


sum = i + j;
txtArea.setText("");
txtArea.append("i = "+ i + "\t" + "j = " + j + "\n");
Button source = (Button)e.getSource();
if(source.getLabel() == "Add"){
469 txtArea.append("Sum : " + sum + "\n");
}

if(i >j){
Sub = i - j;
}
else{
Sub = j - i;
}
if(source.getLabel() == "Subtract"){
txtArea.append("Sub : " + Sub + "\n");
}

Mul = i*j;
if(source.getLabel() == "Multiply"){
txtArea.append("Mul = " + Mul + "\n");
}

if(i > j){


Div = i / j;
}
else{
Div = j / i;
}

if(source.getLabel() == "Divide"){
txtArea.append("Divide = " + Div);
}
}
}

Here is the HTML code of the program :


<HTML>
<BODY>
<APPLET CODE ="EventListeners" WIDTH="800" HEIGHT="500"></APPLET>
</BODY>
</HTML>

A. To handle the events generated by these buttons

B. To handle the events generated by these textarea

C. To handle the events generated by these buttons and textraea

D. All of above

Answer optiona

Marks: 2
Consider the following output. Find the missing statement in the program.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/*
<applet code="SimpleKey1" width=300 height=100>
</applet>
*/
public class SimpleKey1 extends JApplet implements KeyListener
{
String msg = "";
int X = 10, Y = 20; public void init()
{
addKeyListener(this);
requestFocus();
}
470 public void keyPressed(KeyEvent ke)
{
showStatus("Key Down");

}
public void keyReleased(KeyEvent ke)
{
showStatus("Key Up");

public void keyTyped(KeyEvent ke)


{
msg += ke.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, X, Y);
}
}

A. Missing Semicolon

B. }

C. {

D. ()

Answer optionb

Marks: 2

Write the missing statement


import java.applet.Applet;
import java.awt.Checkbox;
import java.awt.Graphics;
import java.awt.event.ItemEvent;
------------------------------------------------------

/*
<applet code="HandleCheckboxEvent" width=200 height=200>
</applet>
*/

public class HandleCheckboxEvent extends Applet implements ItemListener{

Checkbox java = null;


Checkbox vb = null;
Checkbox c = null;

public void init(){

java = new Checkbox("Java");


vb = new Checkbox("Visual Basic");
471 c = new Checkbox("C");

add(java);
add(vb);
add(c);

java.addItemListener(this);
vb.addItemListener(this);
c.addItemListener(this);
}

public void paint(Graphics g){

g.drawString("Java: " + java.getState(),10,80);


g.drawString("VB: " + vb.getState(), 10, 100);
g.drawString("C: " + c.getState(), 10, 120);

public void itemStateChanged(ItemEvent ie) {


repaint();
}
}

A. import java.awt.event;

B. import java.awt.event.ItemListener;

C. import java.awt.event.Listener;
D. import java.awt.event.Item;

Answer optionb

Marks: 2

Write the missing statements?


import java.sql.*;
class InsertPrepared{
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");

PreparedStatement stmt=con.prepareStatement("insert into Emp values(?,?)");


stmt.setInt(1,101);
472 stmt.setString(2,"Ratan");

int i=stmt.executeUpdate();
System.out.println(i+" records inserted");

-------------------------------------

}catch(Exception e){ System.out.println(e);}

}
}

A. con.start();

B. con.open();

C. con.close();

D. None of above

Answer optionc

Marks: 2

Write the missing statement?


import java.sql.*;
class Rsmd{
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle");

PreparedStatement ps=con.prepareStatement("select * from emp");


ResultSet rs=ps.executeQuery();
473
---------------------------------------------------
System.out.println("Total columns: "+rsmd.getColumnCount());
System.out.println("Column Name of 1st column: "+rsmd.getColumnName(1));
System.out.println("Column Type Name of 1st column: "+rsmd.getColumnTypeName(1));

con.close();

}catch(Exception e){ System.out.println(e);}

}
}

A. ResultSetMetaData rsmd=getMetaData();

B. ResultSetMetaData =rs.getMetaData();

C. ResultSetMetaData rsmd=rs.getMetaData();

D. None of above

Answer optionc

Marks: 2
Which statements are used to display the contents of table?
import java.sql.*;

public class jdbcResultSet {


public static void main(String[] args) {
try {
Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
}
catch(ClassNotFoundException e) {
System.out.println("Class not found "+ e);
}
try {
Connection con = DriverManager.getConnection
("jdbc:derby://localhost:1527/testDb","username",
"password");
474 Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery
("SELECT * FROM employee");
System.out.println("id name job");
while (rs.next()) {
int id = rs.getInt("id");
String name = rs.getString("name");
String job = rs.getString("job");
System.out.println(id+" "+name+" "+job);
}
}
catch(SQLException e){
System.out.println("SQL exception occured" + e);
}
}
}

A. getInt & executeQuery methods

B. getString, & executeQuery methods

C. getString,getInt & executeQuery methods

D. getString,getInt methods

Answer optiond

Marks: 2

A servlet life cycle can be defined as the entire process from its creation till the destruction. The following are the paths
475 followed by a servlet

A. The servlet is initialized by calling the init () method.

B. The servlet calls service() method to process a client's request.

The servlet is terminated by calling the destroy() method.


C. Finally, servlet is garbage collected by the garbage collector of the JVM.

D. All of above

Answer optiond

Marks: 2

476 An Applet is ______________ of Panel

A. subclass

B. superclass

C. Both i and ii

D. None of these

Answer optiona

Marks: 1

477 Which of these events will be generated if we close an Frame's window?

A. ActionEvent

B. ComponentEvent

C. AdjustmentEvent

D. WindowEvent

Answer optiond

Marks: 1

478 Which http method send by browser that asks the server to get the page only?

A. get
B. post

C. option

D. put

Answer optiona

Marks: 1

479 What is the meaning of jar?

A. java archived

B. java array

C. java architecture

D. None of these

Answer optiona

Marks: 1

480 _________ is a protocol for breaking and sending packets to an address across a network?

A. DNS

B. Proxy server

C. Socket

D. TCP/IP

Answer optiond

Marks: 2

481 Which JDBC driver Type(s) is (are) the JDBC-ODBC bridge?

A. Type-1

B. Type-2

C. Type-3

D. Type-4

Answer optiona

Marks: 2

482 The method _______ assigns the name Result to the Text of variable jlbl.

A. jlbl.setText("Result")

B. jlbl.newText("Result")

C. jlbl.text("Result")

D. jlbl.findText("Result")

Answer optiona

Marks: 2

Analyse the following code?


import javax.swing.*;
import java.awt.*;
public class Test extends JFrame
{
public Test()
{
setLayout(new FlowLayout());
add(new JButton("Java"));
add(new JButton("Java"));
483 add(new JButton("Java"));
add(new JButton("Java"));
}
public static void main(String [] args)
{
JFrame frame = new Test();
frame.setSize(200,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
A. One button is displayed with the text "Java"

B. Two buttons are displayed with the same text "Java"

C. Three buttons are displayed with the same text "Java"

D. Four buttons are displayed with the same text "Java"

Answer optiond

Marks: 2

484 What is the preferred way to handle an object's events in java?

A. Override the object's handleEvent() method.

B. Add one or more event listener to handle the events

C. Have the object override its processEvent() methods

D. Have the object override its dispatchEvent() methods

Answer optionb

Marks: 2

485 Java packages such as ____________ support the Event handling mechanism

A. java.util

B. java.awt

C. java.awt.event

D. all of these

Answer optiond

Marks: 2

If you want to override a JSP file's initialization method,


486 within what type of tags must you declare the method?

A. <@@>

B. <%@%>

C. <%%>

D. <%!%>

Answer optiond

Marks: 2

487 How can the Checkbox class be used to create a radio button in AWT?

A. By using RadioButton class

B. By using Checkbox class

C. By associating Checkbox objects with a CheckboxGroup

D. By associating Checkbox objects with a RadioButton

Answer optionc

Marks: 1

488 Components are added to which pane of swing JApplet .

A. ContentPane

B. RootPane

C. GlassPane

D. none of above

Answer optiona

Marks: 1
489 Which of the following component can generate ItemEvent?

A. Scrollbar

B. TextField

C. CheckBoxMenuItem

D. Button

Answer optionc

Marks: 1

490 Which of these events is generated when a window is minimized?

A. WindowDeactivated

B. WindowIconified

C. Both a and b

D. None of the above

Answer optionc

Marks: 1

491 Which of these event is generated when a button is pressed?

A. WindowEvent

B. AdjustmentEvent

C. KeyEvent

D. ActionEvent

Answer optiond

Marks: 1

The ............................. package contains classes that help in connecting to a database, sending SQL statements to the
492 database, and processing the query results.

A. connection.sql

B. db.sql

C. pkg.sql

D. java.sql

Answer optiond

Marks: 1

493 The ........................ object allows you to execute parameterized queries.

A. ResultSet

B. Parametrized

C. PreparedStatement

D. Condition

Answer optionc

Marks: 1

494 Why JSP is basically used today?

A. To make controller

B. To develop server pages

C. In writing business logic

D. Deprecated

Answer optionb
Marks: 1

495 Which methods are used to draw the following output?

A. drawPolygon(),fillPolygon()

B. drawTriangle(),fillTriangle()

C. setColor(),drawRect()

D. drawOval(),setColor()

Answer optionb

Marks: 2

496 Which layout manager is shown in the output?

A. FlowLayout

B. BoxLayout

C. GridLayout

D. CardLayout

Answer optionc

Marks: 2

497 Which swing component is shown in output?

A. JTabbedPane

B. Jtable

C. JTree

D. JScrollPane

Answer optionc

Marks: 2

498 getLocalHost() method is present in which package

A. java.lang

B. java.util

C. java.net

D. java.awt

Answer optionc

Marks: 2

499 Which is the class present in java.net package used to create packet from byte array and destination address?

A. DatagramPacket

B. DatagramSocket

C. ServerSocket

D. Socket

Answer optiona

Marks: 2

500 public class DriverManager extends

A. Object

B. String

C. Connection

D. Statement
Answer optiona

Marks: 2

Servlets only needs be loaded once, while CGI programs needs to be load for every request so that servlet should perform faster than
501 CGI

A. True

B. False

C. only B is correct

D. None of these

Answer optiona

Marks: 2

Find the error.


/*<applet code="MyJTabbedPane" width=900 height=900>
</applet>*/
import java.awt.*;
import javax.swing.*;
public class MyJTabbedPane extends JApplet
{
public void init()
502 {
Container c=getContentPane();
c.setLayout(new FlowLayout());
JTabPane jtp=new JTabPane();
jtp.addTab("Cities",new CitiesPanel());
jtp.addTab("Colors",new ColorsPanel());
jtp.addTab("Flavours",new FlavoursPanel());
c.add(jtp);
}}

A. a)Applet code is incorrect

B. b)JTabPane Constructor is incorrect

C. c)addTab method is incorrect

D. d)Package is missing

Answer optionb

Marks: 2

Whether the given code is correct to generate the given output


import java.applet.*;
import java.awt.*;
public class MyControl5 extends Applet implements ActionListener
{
List l;
TextField t;
Button b;
public void init()
{
b=new Button("Add");
503 l=new List();
t=new TextField();
add(b);
add(l);
add(t);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
l.add(t.getText());
}
}

A. TRUE

B. FALSE

C.

D.

Answer optionb

Marks: 2
Choose the correct output for the given code
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*
<applet code="MyScroll2" width=300 height=200>
</applet>
*/
public class MySrcoll2 extends Applet implements AdjustmentListener
{
Scrollbar vert;
TextField t;
public void init()
{
504 vert = new Scrollbar(Scrollbar.VERTICAL,127, 5, 0, 255);
t=new TextField();
setLayout(null);
vert.setBounds(90,20,20,100);
t.setBounds(75,130,50,20);
add(vert);
add(t);
vert.addAdjustmentListener(this);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
int v=vert.getValue();
t.setText(" "+v);
}
}

A.

B.

C. none of this

D. both

Answer optiona

Marks: 2

Find the error in the code


public void itemStateChanged(ItemEvent ie)
505 {
l.setText(c.getSelectedItem());
}

A. No error

B. Method name is incorrect

C. Return type is incorrect

D. Method parameter is incorrect

Answer optiona

Marks: 2
Choose the correct output for the given code
/*<applet code="MyControl10" width=300 height=300>
</applet>*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MyControl10 extends Applet implements ItemListener
{
CheckboxGroup g;
Checkbox c1,c2,c3;
int red,green,blue;
public void init()
{
g=new CheckboxGroup();
c1=new Checkbox("Red",g,false);
c2=new Checkbox("Green",g,false);
c3=new Checkbox("Blue",g,true);
setLayout(null);
c1.setBounds(20,20,70,20);
c2.setBounds(20,45,70,20);
c3.setBounds(20,70,70,20);
add(c1);
add(c2);
506 add(c3);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
red=blue=green=0;
}
public void itemStateChanged(ItemEvent ie)
{
red=green=blue=0;
if(c1.getState())
red=255;
if(c2.getState())
green=255;
if(c3.getState())
blue=255;
repaint();
}
public void paint(Graphics g)
{
Color c=new Color(red,green,blue);
g.setColor(c);
g.fillRect(90,20,100,100);
}
}

A. S1Q50O1

B. S1Q50O2

C. S1Q50O3

D. All of the above

Answer optiond

Marks: 2

Choose the correct output


import java.net.*;
class networking
{
public static void main(String args[])throws UnknownHostException
{
507 InetAddress obj1 =InetAddress.getByName("msbte.com");
InetAddress obj2 =InetAddress.getByName("msbte.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}

A. 0

B. 1

C. true

D. false

Answer optionc

Marks: 2
Find the error in the given code
import java.sql.*;
class Mydatabase1
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
508 System.out.println("Driver Loaded");
Connection c=Drivermanager.getConnection("jdbc:odbc:MYDSN"," "," ");
System.out.println("Connection Established");
}
catch(Exception e)
{
System.out.println(e);
}
}
}

A. Package is incorrect

B. getConnection() method syntax is incorrect

C. Drivermanager class name is incorrect

D. try is mentioned without catch

Answer optionc

Marks: 2

Choose the correct output for the given code:


import java.sql.*;
class Mydatabase1
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
Connection c=DriverManager.getConnection("jdbc:odbc:MYDSN"," "," ");
System.out.println("Connection Established");
Statement st=c.createStatement();
ResultSet rs=st.executeQuery("Select * from StudTable");
509 while(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2));
}
rs.close();
st.close();
c.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

A. S1Q54O1

B. S1Q54O2

C. S1Q54O3

D. S1Q54O4

Answer optiona

Marks: 2

510 Which code is correct to generate the given output?

A. a) PreparedStatement p=c.prepareStatement("Select * from Employee where Name='Ram'");

B. b) Preparedstatement p=c.prepareStatement("Select * from Employee where Name='Ram'");

C. c) PreparedStatement p=c.PrepareStatement("Select * from Employee where Name='Ram'");

D. d) PreparedStatement p=c.prepareStatement("Select * from Employee where Name=Ram);

Answer optiona

Marks: 2

Find the error in the given code


Statement st=c.createStatement();
Resultset rs=st.executeQuery("Select * from StudTable");
511 while(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2));
}

A. createStatement() should contain parameters


Resultset interface name is incorrect
B.

C. next () cannot be called using object of resultset

D. getString() should contain String type parameter

Answer optionb

Marks: 2

Choose the missing statement in the given method syntax


512
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ____________

A. ServletException,IOException

B. URLMalformedException

C. SecurityException

D. SQLException

Answer optiona

Marks: 2

Which packages needs to be imported to execute the given program


public class First extends GenericServlet{
public void service(ServletRequest req,ServletResponse res)
throws IOException,ServletException{

res.setContentType("text/html");
513 PrintWriter out=res.getWriter();
out.print("<html><body>");
out.print("<b>hello generic servlet</b>");
out.print("</body></html>");

}
}

import java.io.*;
A. import javax.servlet.*;

B. import java.io.*;

C. import javax.servlet.*;

D. import java.lang.*;

Answer optiona

Marks: 2

514 Which method returns the current session associated with this request, or if the request does not have a session, creates one?

A. getSession()

B. getServletPath()

C. getCookies()

D. getPathInfo()

Answer optiona

Marks: 2

515 Which are the methods of servlet life cycle?

A. init(),destroy()

B. init(),service(),destroy()

C. init(),end()

D. init(),start(),destroy()

Answer optionb

Marks: 2

516 Which of the following is not an AWT component

A. List
B. Button

C. Choice

D. Applet

Answer optiond

Marks: 1

517 Default layout manager for panel is

A. CardLayout

B. GridLayout

C. FlowLayout

D. GridBagLayout

Answer optionc

Marks: 1

518 FlowLayout arranges components from

A. Left to Right

B. Right to left

C. Top to Bottom

D. Bottom to top

Answer optiona

Marks: 1

519 Which among the following is not an AWT Event

A. FocusEvent

B. KeyEvent

C. MouseEvent

D. AdjustEvent

Answer optiond

Marks: 1

520 Which of the following is true for TCP ?

A. TCP is realiable and connection oriented

B. TCP is unrelaible but connection oriented

C. TCP is realiable and connection less

D. none of the these

Answer optiona

Marks: 1

521 What is Socket?

A. End point for communication

B. Combination of IP address and port number

C. Predfined class in java

D. All of these

Answer optiond

Marks: 1

522 Which of the following are examples of JSP directive.


A. include

B. exclude

C. servlet

D. taglibrary

Answer optiona

Marks: 1

523 Which among the following is the feature of Jtable

A. Is a user-interface component that presents data in a two-dimensional table format.

B. Displays a grid of data consisting of rows and columns similar to a spreadsheet.

C. Reassessable and reorderable columns.

D. all of these

Answer optiond

Marks: 2

524 Which of the follwing is true about FlowLayout

A. FlowLayout can use multiple rows if the horizontal space in the container is too small to hold the components

B. FlowLayout is the default layout manager of Panel and Applet

C. It is the default layout manager for Window

D. both A and B

Answer optiond

Marks: 2

525 Which among the following is true about the event?

A. An event describes, in sufficient detail, a particular user action.

B. There are many types of events that are generated by an AWT Application.

C. Events are used to make the application more effective and efficient.

D. all of these

Answer optiond

Marks: 2

526 When the event source generates an event, the event source notifies to .............. that the event has occurred.

A. all the listener objects

B. selected listener objects

C. single listener object

D. none of these

Answer optiona

Marks: 2

527 getSession(true) method will return appropriate session object if��

A. the session is completed

B. session object is passed to another method

C. the session does not exists

D. the session is existing

Answer optiond

Marks: 2
528 Which components are needed to get below shown output?

A. Button, Textfield,List

B. Button, Textfield,Choice

C. Button, TextArea, Choice

D. Button, TextField, TabbedPane

Answer optiona

Marks: 2

529 Identify the missing statements in the following code.

A. b1.addActionListener(this);b2.addActionListener(this);

B. b1.addActionListener(this);b3.addActionListener(this);

C. b1.addActionListener(this)

D. b1.addListener(this);b2.addActionListener(this);

Answer optiona

Marks: 2

530 What will be the output of the program?

A. Compilation error

B. Will not show any ouput

C. Run time error

D. none of these

Answer optiona

Marks: 2

531 Which method of the request object is used to extract values of the input fields in a form when it is submitted?

A. getParameter()

B. getParameterNames()

C. getValues()

D. getParameters()

Answer optiona

Marks: 2

532 All swing component classes are placed in

A. java.awt

B. javax.awt

C. java.swing

D. javax.swing

Answer optiond

Marks: 1

533 Which component in swing represents data in rows and columns?

A. JTextArea

B. JTable

C. JPanel

D. JtabbedPane

Answer optionb
Marks: 1

534 Which among the following is true for Adaptor Classes?

A. Adapter classes increases Efficiency of event Listener.

B. Adaptor classes increases Complexity event Listener.

C. Adaptor classes reduce Complexity of event Listener.

D. Adaptor classes reduce code for event Listener.

Answer optionc

Marks: 1

535 An object that would like to be notified of and respond to an event is

A. EventListener

B. Event Source

C. Event

D. Action

Answer optiona

Marks: 1

536 Adapter class belongs to the package

A. java.awt.event

B. javax.awt.event

C. java.event

D. javax.event

Answer optiona

Marks: 1

537 Which of the following is true for UDP ?

A. UDP is realiable and connection oriented

B. UDP is unrelaible but connection oriented

C. UDP is unrealiable and connection less

D. none of the these

Answer optionc

Marks: 1

538 ODBC requires configuring _______ which represents the target database.

A. Domain

B. Data Source Name

C. Server

D. None of these

Answer optionb

Marks: 1

539 Which package need to be imported for establishing connection with database

A. java.sql

B. javax.net

C. java.jdbc

D. java.lang
Answer optiona

Marks: 1

540 Where the servlets run?

A. on client side

B. on server side

C. on proxy side

D. on database side

Answer optionb

Marks: 1

541 Which method is called on every servlet request ?

A. init()

B. doGet()

C. doPost()

D. service()

Answer optiond

Marks: 1

542 Which of the following options is correct about Layout Manager

A. Layout manager manages height and width of layout

B. Layout manager manages positions of different components

C. Layout manager manages size of differnet components

D. Both B and C

Answer optiond

Marks: 2

543 Which among the following is not correct regarding dialog?

A. Use dialogs only for actions that deviate from the primary task flow.

B. Any dialog pauses the interaction of an application with the user.

C. Dialogs should ideally be designed such that they could be ignored altogether, without disrupting the user's ability to complete their job.

D. Use of Dialog effects the working of Application

Answer optiond

Marks: 2

544 Which of the follwing component cannot be registered with actionPerformed() method of ActionListener?

A. Button

B. JComboBox

C. List

D. CheckBox

Answer optiond

Marks: 2

545 Which statement among the following is not true releated to Event?

A. An object that would like to be notified of and respond to an event is an event listener

B. An object that generates a particular kind of event, called an event source

C. A Listener must be added to a component to react to the events occurring on the component
D. A component may or may not have a way to register and deregister listeners

Answer optiond

Marks: 2

546 Which method of the servlet is/are called several times in its life?

A. init()

B. service()

C. destroy()

D. Both (i) and (ii)

Answer optionb

Marks: 2

547 Which Components need to be used to produce this output

A. JTextArea

B. JTabbedPane and TextArea

C. JTabbedPane and icon

D. JtabbedPane,JLabel and ImageIcon

Answer optiond

Marks: 2

548 The JDBC-ODBC Bridge supports multiple concurrent open statements per connection?

A. one

B. zero

C. Does not support connection

D. none of these

Answer optiona

Marks: 2

549 what is the main components of JDBC ?

A. DriverManager

B. Driver

C. Connection

D. all of these

Answer optiond

Marks: 2

550 The values of <servlet-name> and <servlet-class> in web.xml file ��

A. must be same

B. must not be same

C. may be same

D. none of these

Answer optionc

Marks: 2

551 which method is used to set the visibility of the frame?

A. 1.setVisible(true)

B. 2.setVisible(false)
C. 3.setVisible()

none
D.

Answer optiona

Marks: 1

552 Which containers may have a MenuBar?

A. Applet

B. Panel

C. Canvas

D. Frame

Answer optiond

Marks: 1

553 Which of the following is not a constructor of JTree

A. JTree(TreeNode tn)

B. JTree(Vector v)

C. JTree(int x)

D. none of the above

Answer optionc

Marks: 1

554 ----------------------Is super class of all the events

A. EventObject

B. EventClass

C. ActionEvent

D. ItemEvent

Answer optiona

Marks: 1

555 What is the use of setLayout() method

A. To install a container

B. To install a Window

C. To install a new layout manager

D. none of the above

Answer optionc

Marks: 2

556 Which component represents the hierarchical view of data

A. Jtable

B. Jtree

C. JTabbedPane

D. none

Answer optionb

Marks: 2
Select the missing statement in the given code
import javax.swing.*;
import java.awt.*;
class CompDemo extends JFrame
{
public static void main(String[] args)
{
CompDemo jframe=new CompDemo();
cpane.setLayout(new FlowLayout(FlowLayout.CENTER,20,20));
jframe.setSize(300,300);
jframe.setVisible(true);
cpane.setBackground(Color.red);
Label label1=new Label("Name");
557 cpane.add(label1);
JTextField jtextfield=new JTextField(15);
cpane.add(jtextfield);
Label label2=new Label("Enter Address");
cpane.add(label2);
JTextArea jtextarea=new JTextArea(5,10);
cpane.add(jtextarea);
Label label3=new Label("Enter Password");
cpane.add(label3);
JPasswordField jpass=new JPasswordField(10);
cpane.add(jpass);
}
}

A. missing semicolon

B. missing import statement

C. Container cpane=jframe.getContentPane();

D. missing setLayout()

Answer optionc

Marks: 2

Select the proper method at _____________________


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class applet2 extends Applet implements ActionListener
{
public void init()
{
Button r=new Button("RED");
r.addActionListener(this);
Button g=new Button("GREEN");
g.addActionListener(this);
Button b=new Button("BLUE");
b.addActionListener(this);
558 add(r);
add(g);
add(b);
}
public void actionPerformed(ActionEvent arg)
{
String click=arg._________________________();
if(click.equals("RED"))
setBackground(Color.red);
else if(click.equals("GREEN"))
setBackground(Color.green);
else if(click.equals("BLUE"))
setBackground(Color.blue);
}
}

A. getAction()

B. getActionCommand()

C. getSource()

D. getID()

Answer optionb

Marks: 2

559 Select the fullform of DNS

A. Data Network System

B. Domain Name Select

C. Domain Name Server

D. Domain Name Service

Answer optiond

Marks: 2

560 Select pacakge used for handling security related issues in a program
A. java.security

B. java.lang.security

C. java.awt.image

D. java.io.security

Answer optiona

Marks: 2

Select the package used to import the abstract class


561 HttpServlet and interfaces HttpServletRequest and HttpServletResponse

A. import javax.servlet.http.*

B. import javax.servlet.*

C. import java.io.*

D. none of the above

Answer optiona

Marks: 2

Select the proper command to run the following code


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
/*
<applet code="combodemo" width=300 height=100>
</applet>
*/
public class combodemo extends JApplet
{
562 public void init()
{
Container co = getContentPane();
co.setLayout(new FlowLayout());
JComboBoxjc=new JComboBox();
jc.addItem("pen");
jc.addItem("pencil");
jc.addItem("eraser");
jc.addItem("sharpner");
co.add(jc);
}
}

A. Javac combodemo.java

B. Java combodemo

C. appletviewer combodemo.java

D. all of above

Answer optionc

Marks: 2
Select the missing statement in the program to get the correct output
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class app extends Applet implements ActionListener
{
TextField t1,t2;
Label l1,l2;
Button b1;
public void init()
{
t1=new TextField(15);
t2=new TextField(15);
l1=new Label("Enter a no");
l2=new Label("No is");
b1=new Button("Even/Odd");
add(l1);
add(t1);
add(l2);
563 add(t2);
add(b1);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
int a=Integer.parseInt(t1.getText());
if(a%2==0)
{
t2.setText("Even");
}
else
{
t2.setText("Odd");
}
}
}
}

A. b1.addActionListener(this);

B. b2.addActionListener(this);

C. both a & b

D. All of above

Answer optiona

Marks: 2

Select the missing statement in the program to get the correct output
import java.awt.*;
import javax.swing.*;
public class JScrollPaneDemo extends JApplet
{
public void init()
{
Container contentPane=getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel jp=new JPanel();
jp.setLayout(new GridLayout(20,20));
int b=0;
for(int i=0;i<20;i++)
564 {
for(int j=0;j<20;j++)
{
jp.add(new JButton("Button"+b));
++b;
}
}
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
-----------------------------------------------------
contentPane.add(jsp,BorderLayout.CENTER);
}
}

A. JScrollPane jsp=new JScrollPane(v,h);

B. JScrollPane jsp=new JScrollPane(v,h,jp);

C. JScrollPane jsp=new JScrollPane(jp);

D. JScrollPane jsp=new JScrollPane(jp,v,h);

Answer optiond

Marks: 2
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
{
URL u1=new URL("http://localhost:8080/index.htm");
URLConnection u2=u1.openConnection();
565 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);
}
}

A. missing semicolon

B. }

C. {

D. all of above

Answer optionb

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;
class demo11
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:PC","","");
Statement st=c.createStatement();
st.execute("create table PCMODEL(Industry String,SNO Int,Model String)");
566 st.execute("insert into PCMODEL values('ABC',1,'A')");
st.execute("insert into PCMODEL values('BCD',2,'B')");
st.execute("insert into PCMODEL values('CDE',3,'C')");
ResultSet rs=st.executeQuery("Select*from PCMODEL");
System.out.println("Indust"+"\t"+"SNO"+"\t"+"Model");
while(rs.next())
{
System.out.println(rs.getString(1)+"\t"+rs.getString(3));
}
st.close();
}
}

A. missing semicolon

B. missing }

C. missing{

D. missing c.close();

Answer optiond

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
class demo
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:PC","","");
Statement st=c.createStatement();
st.execute("create table PCMODEL(Industry String,SNO Int,Model String)");
st.execute("insert into PCMODEL values('ABC',1,'A')");
567 st.execute("insert into PCMODEL values('BCD',2,'B')");
st.execute("insert into PCMODEL values('CDE',3,'C')");
ResultSet rs=st.executeQuery("Select*from PCMODEL");
System.out.println("Indust"+"\t"+"SNO"+"\t"+"Model");
while(rs.next())
{
System.out.println(rs.getString(1)+"\t"+rs.getString(3));
}
st.close();
c.close();
}
}

A. missing semicolon

B. missing package statement

C. missing {

D. missing }
Answer optionb

Marks: 2

import java.sql.*;
class S14
{
public static void main(String args[])throws Exception;
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:PC","","");
Statement st=c.createStatement();
st.execute("create table PCMODEL(Industry String,SNO Int,Model String)");
st.execute("insert into PCMODEL values('ABC',1,'A')");
st.execute("insert into PCMODEL values('BCD',2,'B')");
568 st.execute("insert into PCMODEL values('CDE',3,'C')");
ResultSet rs=st.executeQuery("Select*from PCMODEL");
System.out.println("Indust"+"\t"+"SNO"+"\t"+"Model");
while(rs.next())
{
System.out.println(rs.getString(1)+"\t"+rs.getString(3));
}
st.close();
c.close();
}
}

A. Error in main()

B. error in loop

C. error in connection statement

D. Error in close()

Answer optiona

Marks: 2

Consider the following program ,what should be the correction done in the program to get the correct output
import java.sql.*;
public class displayemployee
{
public static void main(String[] args)
{
Connection con;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connection established");
}
catch(Exception e)
{
System.out.println("Connection error");
}
try
{
String str="jdbc.odbc:dsn1";
con=DriverManager.getConnection(str,"","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select*from employee");
569 int n=rs.getMetaData().getColumnCount();
for(int i=1;i<=n;i++)
{
System.out.print(rs.getMetaData().getColumnLabel(i)+'\t');
System.out.println("");
while(rs.next())
{
for(int i=1;i<=n;i++)
{
System.out.print(rs.getString(i)+'t');
}
System.out.println("");
}
rs.close();
con.close();
}
catch(SQLException e)
{
System.out.print("SQL error");
}
}
}

A. missing }

B. missing {

C. missing semicolon

D. missing package statement

Answer optiona

Marks: 2
Consider the following program.
What should be the correction done in the program to get correct output?
i
public class displayemployee
{
public static void main(String[] args);
{
Connection con;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connection established");
}
catch(Exception e)
{
System.out.println("Connection error");
}
try
{
String str="jdbc.odbc:dsn1";
con=DriverManager(str,"","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select*from employee");
570 int n=rs.getMetaData().getColumnCount();
for(int i=1;i<=n;i++)
{
System.out.print(rs.getMetaData().getColumnLabel(i)+'\t');
}
System.out.println("");
while(rs.next())
{
for(int i=1;i<=n;i++)
{
System.out.print(rs.getString(i)+'t');
}
System.out.println("");
}
rs.close();
con.close();
}
catch(SQLException e)
{
System.out.print("SQL error");
}
}
}

A. missing getConnection() method

B. error in main()

C. missing package statement

D. all of the above

Answer optiond

Marks: 2

Choose missing statements in following code from given options


public class HelloWorld extends HttpServlet
{
private String message;
public void init()
throws ServletException
{
message ="Hello World";
}
571 public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out= response.getWriter();
out.println("<h1>"+ message +"</h1>");
}}
publicvoid destroy()
{ }

import java.io.*;
A. import javax.servlet.*;
import javax.servlet.http.*;

B. import java.Vector.* ; import java.Thread.*; import javax.servlet.*;

C. import javax.servlet.http.*; import java.String.*; import java.Vector;

D. import javax.servlet.http.*; import java.Thread.*; import javax.Client.*;

Answer optiona

Marks: 2
Select the missing statement to get the correct output
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionIdServlet extends HttpServlet
{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
572 {
response.setContentType("text/html");
printWriter pw=response.getWriter();
HttpSession session=request.getSession();
String id=session.getId();
pw.println("Session Id is:"+ id)
}

A. missing semicolon,missing }

B. missing semicolon

C. missing }

D. missing semicolon,missing {

Answer optiona

Marks: 2

Select the missing statement to get correct output


public class welcomeservelet extends GenericServlet
{
public void service(ServletRequest request,ServletResponce response)
throws ServletException,IOException
{
573 response.setContentType("text/html");
printWriter pw =response.getWriter();
pw.println("<B>welcome to servlet!");
pw.close();
}
}

A. import java.io.*; import javax.servlet.*;

B. import java.io.*;

C. import java.servlet.*;

D. none of the above

Answer optiona

Marks: 2

574 Which of the following components does not have visible borders?

A. Frame

B. Panel

C. Dialog

D. File Dialog

Answer optionb

Marks: 1

575 In AWT Checkbox class is used to create __________

A. Checkbox and Button

B. Checkbox and Choice(Drop-Down List)

C. Checkbox and Menubar

D. Checkbox and Radio buttons

Answer optiond

Marks: 1

576 A __________ automatically arranges the components added to a container.

A. Listener

B. Loader

C. Layout Manager
D. Scrollbar

Answer optionc

Marks: 1

577 Which component displays information in hierarchical manner with parent-child relationship?

A. JTable

B. JTree

C. JTabbedPane

D. JComboBox

Answer optionb

Marks: 1

578 which are the integer constants of ComponentEvent?

A. COMPONENTt_HIDDEN

B. COMPONENT_MOVED

C. COMPONENT_SHOWN

D. ALL THE ABOVE

Answer optiond

Marks: 2

579 Which of the following is not event class is Java?

A. ComponentEvent

B. ContainerEvent

C. FocusEvent

D. ClickEvent

Answer optiond

Marks: 1

580 How many types of component events are in Java?

A. 1

B. 2

C. 3

D. 4

Answer optiond

Marks: 1

581 A socket identifies __________ in network.

A. a communication end point

B. a node

C. a thread

D. a graphical user interface

Answer optiona

Marks: 1

582 When a socket object is created __________

A. It implicitly establishes a connection between the client & server

B. It waits for connect() method to be called


C. It destroys all of previous instances of socket object

D. It asks IP address to be entered from keyboard.

Answer optiona

Marks: 1

583 TCP/IP sockets are used to impelement __________ connections.

A. Reliable and persistent

B. Bidirectional and point-to-point

C. Stream-based

D. All of the above

Answer optiond

Marks: 1

584 When a URL object is created __________

A. a connection is automatically established with that URL

B. openConnection() method is used to establish a connection

C. getConnection() method is used to establish a connection

D. makeConnection() method is used to establish a connection

Answer optiona

Marks: 1

585 __________ method of DriverManager class is used to create connection with database.

A. openConnection()

B. setConnection()

C. getConnection()

D. readConnection()

Answer optionc

Marks: 1

586 Which method is used to send CREATE TABLE queries to database using JDBC?

A. executeQuery()

B. executeUpdate()

C. createTable()

D. insertNewTable()

Answer optionb

Marks: 1

587 The correct string for loading Jdbc-Odbc bridge driver using Class.forName() method is:

A. jdbc.odbc.JdbcOdbcDriver

B. microsoft.odbc.jdbc.OdbcJdbcDriver

C. sun.jdbc.odbc.JdbcOdbcDriver

D. microsoft.sun.JdbcOdbcDriver

Answer optionc

Marks: 1

588 createStatement() method without any parameter is used to create a statement with __________

A. a scrollable and read only ResultSet


B. a scrollable and updatable ResultSet

C. a forward only and updatable ResultSet

D. a forward only and read only ResultSet

Answer optiond

Marks: 1

589 Which method are central to life cycle of a servlet?

A. init(), service() and destroy()

B. init(), paint() and destroy()

C. init(), start() and stop()

init(), service() and paint()


D.

Answer optiona

Marks: 1

590 A cookie is stored on __________ and contains state information.

A. client machine

B. web server

C. dns server

D. All of the above

Answer optiona

Marks: 1

591 If an expiration date is not explicitly assigred to a cookie __________

A. it is permanently stored

B. it is never stored

C. it is deleted when the current browser session ends

D. it is deleted when internet access is lost

Answer optionc

Marks: 1

592 Which layout manager can be used to get the following output?

A. FlowLayout

B. GridLayout

C. BorderLayout

D. CardLayout

Answer optionc

Marks: 2

593 Which components are required to get following output?

A. Applet, Choice, Button, Label, List,Menu

B. Applet, Button, Label, List, TextField

C. Choice, Button, Label, List, Menu

D. Applet, Choice, Button, Menu, MenuItem

Answer optiona

Marks: 2
Select the missing statements at --------------------- for following program:
import java.awt.*;
import java.applet.*;
-------------------------
public class Sample extends Applet implements ActionListener, ItemListener
{
Checkbox check;
Button b;
public void init()
{
check=new Checkbox("AJP");
b=new Button("OK");
add(check);
add(b);
-------------------
-------------------
}
public void itemStateChanged(ItemEvent ie)
{
594 repaint();
}
public void actionPerformed(ActionEvent ae)
{
setBackground(Color.red);
}

public void paint(Graphics g)


{
if(check.getState()==true)
{
g.drawString(check.getLabel()+" is selected",10, 120);
}
else
{
g.drawString(check.getLabel()+" is not selected",10, 120);
}
}
}

import java.awt.event.*;
A. check.addItemListener(this);
b.addActionListener(this);

import javax.swing.*;
B. check.addMouseListener(this);
b.addKeyListener(this);

import java.awt.event.*;
C. check.addAdjustmentListener(this);
b.addActionListener(this);

import java.awt.event.*;
D. Container con=getContentPane();
check.addItemListener(this);

Answer optiona

Marks: 2

Which of the following statements are true?


A. All events will be processed in the order, the listener were added.
595 B. Using the adapter approach to event handling means creating blank method bodies for all event methods.
C. A component may have multiple listeners associated with it.
D. Listeners may be removed once added.

A. Only A

B. C and D

C. All of the thses

D. None of these

Answer optionb

Marks: 2

Following are the life cycle methods of servlet:


1. service()
596 2. init()
3. destroy()
Select the correct sequence in which these methods are executed during life cycle of a particular servlet.

A. 1, 2,3

B. 2, 1,3

C. 2, 3,1

D. 1, 3, 2

Answer optionb

Marks: 2
Cookies and Sessions can be created and used with:
A. Generic servlets
597 B. Http servlets
Select correct option from following.

A. Both A and B

B. Only A

C. Only B

D. None of the above

Answer optionc

Marks: 2

Select the missing statements in the program to get following output:


import java.awt.*;
class Sample extends Frame
{
Sample(String title)
{
super(title);
MenuBar mbar = new MenuBar();
setMenuBar(mbar);
Menu font = new Menu("Font");
font.add(bold);font.add(italic);font.add(under);
font.add(strike);
598 mbar.add(font);
Menu para = new Menu("Paragraph");
mbar.add(para);
Menu styles = new Menu("Styles");
mbar.add(styles);
setSize(400,400);
setVisible(true);
}
public static void main(String args[])
{
new Sample("Menu Example");
}
}

MenuItem bold = new MenuItem("Bold");


MenuItem italic = new MenuItem("Italic");
A. MenuItem under = new MenuItem("Underline");
MenuItem strike = new MenuItem("Stikethrough");

CheckboxMenuItem bold = new CheckboxMenuItem("Bold");


CheckboxMenuItem italic = new CheckboxMenuItem("Italic");
B. CheckboxMenuItem under = new CheckboxMenuItem("Underline");
CheckboxMenuItem strike = new CheckboxMenuItem("Stikethrough");

CheckableMenuItem bold = new CheckableMenuItem ("Bold");


CheckableMenuItem italic = new CheckableMenuItem ("Italic");
C. CheckableMenuItem under = new CheckableMenuItem ("Underline");
CheckableMenuItem strike = new CheckableMenuItem ("Stikethrough");

SelectedMenuItem bold = new SelectedMenuItem ("Bold");


SelectedMenuItem italic = new SelectedMenuItem ("Italic");
D. SelectedMenuItem under = new SelectedMenuItem ("Underline");
SelectedMenuItem strike = new SelectedMenuItem ("Stikethrough");

Answer optionb

Marks: 2

599 Select the correct code to get the following output:

import java.awt.*;
import java.applet.*;
public class Sample extends Applet
{
public void init()
{
A. Checkbox red=new Checkbox("Red");
Checkbox green=new Checkbox("Green");
Checkbox blue=new Checkbox("Blue");
add(red);
add(green);
add(blue);
}

import java.awt.*;
import java.applet.*;
public class Sample extends Applet
{
public void init()
{
CheckboxGroup cbg=new CheckboxGroup();
B. Checkbox red=new Checkbox("Red",false,cbg);
Checkbox green=new Checkbox("Green",false,cbg);
Checkbox blue=new Checkbox("Blue",false,cbg);
add(red);
add(green);
add(blue);
}}
import java.awt.*;
import java.applet.*;
public class Sample extends Applet
{
public void init()
{
C. Button red = new Button("Red");
Button green = new Button("Green");
Button blue = new Button("Blue");
add(red);add(green);add(blue);
}
}

import java.awt.*;
import java.applet.*;
public class Sample extends Applet
{
public void init()
D. {
OptionButton red = new OptionButton("Red");
OptionButton green = new OptionButton("Green");
OptionButton blue = new OptionButton("Blue");
add(red);add(g

Answer optionb

Marks: 2

Choose the missing statements to be added to following program to get correct output.
import java.awt.*;
class Sample extends Frame implements ActionListener, ItemListener
{
MenuItem item1;
CheckboxMenuItem item2;
String str="";
Sample(String title)
{
super(title);
MenuBar mbar = new MenuBar();
setMenuBar(mbar);
Menu m = new Menu("Items");
item1 = new MenuItem("Item-1");
m.add(item1);
item2 = new CheckboxMenuItem("Item-2");
m.add(item2);
mbar.add(m);
setSize(400,400);
setVisible(true);
600 }
public void actionPerformed(ActionEvent ae)
{
str = "Item-1 is selected.";
repaint();
}
public void itemStateChanged(ItemEvent ie)
{
str = "Item-2 is selected.";
repaint();
}
public void paint(Graphics g)
{
g.drawString(str + " is selected.", 10, 240);
}
public static void main(String args[])
{
Sample f=new Sample("Menu Example");
}
}

import java.awt.event.*;
A. item1.addActionListener(this);
item2.addActionListener(this);

import java.awt.event.*;
B. item1.addItemListener(this);
item2.addItemListener(this);

import java.awt.event.*;
C. item1.addActionListener(this);
item2.addItemListener(this);

import java.awt.event.*;
D. item1.addClickListener(this);
item2.addClickListener(this);

Answer optionc

Marks: 2
Consider the following program. Choose the missing statements to get correct output.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
{
List year, branch;
public void init()
{
add(new Label("Select year and branch:"));
year=new List(3);
branch=new List(5);
year.add("First Year");
year.add("Second Year");
year.add("Third Year");
601 add(year);
branch.add("AE");
branch.add("CO");
branch.add("EE");
branch.add("EJ");
branch.add("IF");
branch.add("ME");
add(branch);
}
public void paint(Graphics g)
{
g.drawString("You selected: "+year.getSelectedItem()+" "+branch.getSelectedItem(),10, 160);
}
}

public class Sample extends Applet implements ItemListener


year.addItemListener(this);
branch.addItemListener(this);
A. public void itemStateChanged(ItemEvent ie)
{
repaint();
}

public class Sample extends Applet implements ActionListener


year.addActionListener(this);
branch.addActionListener(this);
B. public void actionPerformed(ActionEvent ae)
{
repaint();
}

public class Sample extends Applet implements AdjustmentListener


year.addAdjustmentListener(this);
branch.addAdjustmentListener(this);
C. public void itemStateChanged(AdjustmentEvent ae)
{
repaint();
}

public class Sample extends Applet implements WindowListener


year.addWindowListener(this);
branch.addWindowListener(this);
D. public void windowActivated(WindowEvent we)
{
repaint();
}

Answer optiona

Marks: 2

Which of the following integer constants are defined by AdjustmentEvent class that can be used to identify adjustment events?
1. BLOCK_DECREMENT
2. BLOCK_INCREMENT
602 3. TRACK
4. UNIT_DECREMENT
5. UNIT_INCREMENT

A. Only 2 and 5

B. All are defined

C. Only 4 and 5

D. Only 1, 2, 4 and 5

Answer optionb

Marks: 2
Consider the following program. What should be the correction done to get correct output?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Sample extends Applet implements ItemListener
{
Button red, green, blue;
public void init()
{
red=new Button("Red");
green=new Button("Green");
blue=new Button("Blue");
add(red);
add(green);
add(blue);
red.addItemListener(this);
green.addItemListener(this);
blue.addItemListener(this);
603 }
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==red)
{
setBackground(Color.red);
}
if(ie.getSource()==green)
{
setBackground(Color.green);
}
if(ie.getSource()==blue)
{
setBackground(Color.blue);
}
}

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Sample extends Applet implements ActionListener
{
Button red, green, blue;
public void init()
{
A. red=new Button("Red");
green=new Button("Green");
blue=new Button("Blue");
add(red);
add(green);
add(blue);
red.actionListener(this);
green.actionListener(this);
blue.actionListener(this);

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Sample extends Applet implements AdjustmentListener
{
Button red, green, blue;
B. public void init()
{
red=new Button("Red");
green=new Button("Green");
blue=new Button("Blue");
add(red);

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Sample extends Applet implements ClickListener
{
Button red, green, blue;
C. public void init()
{
red=new Button("Red");
green=new Button("Green");
blue=new Button("Blue");
add(red);

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Sample extends Applet implements TextListener
{
Button red, green, blue;
D. public void init()
{
red=new Button("Red");
green=new Button("Green");
blue=new Button("Blue");
add(red);

Answer optiona

Marks: 2
select missing class

import java.net.*;
class Sample
{
public static void main(String[] args)throws UnknownHostException
{
try
604 {
____________ address=A_Class.getByName("google.com");
System.out.println(address);
}catch(UnknownHostException e)
{
System.out.println("Caught : "+e);
}
}
}

A. IPAddress

B. InternetAddress

C. RemoteAddress

D. InetAdress

Answer optiond

Marks: 2

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: " + hp.getProtocol());
605 System.out.println("Port: " + hp.getPort());
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

A. Only A

B. Only B

C. Either A or B

D. All

Answer optionb

Marks: 2

Consider the following program. Select the statement that should be added to get correct output.
import java.sql.*;
class DBEx
{
public static void main(String args[])
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:mydsn","","");
ResultSet rs = s.executeQuery("select * from StudTable");
while(rs.next())
{
606 System.out.println("Roll No.: "+rs.getInt(1));
System.out.println("Name : "+rs.getString(2));
System.out.println("Branch : "+rs.getString("Branch")+"\n");
}
s.close();
c.close();
}catch(Exception e)
{
System.out.println("Caught: "+e);
}
}
}

A. CallableStatement s = c.prepareCall();

B. PreparedStatement s = c.prepareStatement();

C. Statement s = c.createStatement();

D. Statement s = c.newStatement();

Answer optionc

Marks: 2
Consider the following program. In which statement there is an error?
import java.sql.*;
class DBEx
{
public static void main(String args[])
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.openConnection("jdbc:odbc:mydsn","","");
Statement s=c.createStatement();
ResultSet rs = s.executeQuery("select * from StudTable");
while(rs.next())
607 {
System.out.println("Roll No.: "+rs.getInt(1));
System.out.println("Name : "+rs.getString(2));
System.out.println("Branch : "+rs.getString("Branch")+"\n");
}
s.close();
c.close();
}catch(Exception e)
{
System.out.println("Caught: "+e);
}
}
}

A. Error in Connection statement

B. Error in ResultSet statement

C. Error in getString() method

D. No correction is required

Answer optiona

Marks: 2

Consider the following program. What should be the correction done to get correct output?
import java.sql.*;
class DBEx
{
public static void main(String args[])
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:mydsn","","");
PreparedStatement ps = c.prepareStatement("insert into Student values(*, *, *)");
608 ps.setInt(1,100);
ps.setString(2,"zaz");
ps.setString(3,"FYCO");
ps.executeUpdate();
c.close();
}catch(Exception e)
{
System.out.println("Exception generated: "+e);
}
}
}

A. Error in Connection statement

B. Use ? symbol instead of * symbol

C. Use + symbol instead of * symbol

D. No correction is required

Answer optionb

Marks: 2

Consider the following program. What should be the correction done to get correct output?
import java.sql.*;
class DBEx
{
public static void main(String args[])
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:mydsn","","");
609 Statement s = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
s.executeUpdate("insert into Student values(8,'H','FYCO')");
c.close();
}catch(Exception e)
{
System.out.println("Exception generated: "+e);
}
}
}

A. Use executeQuery() method instead of executeUpdate() method

B. Use executeInsert() method instead of executeUpdate() method

C. Use executeNewRow() method instead of executeUpdate() method

D. No correction is required
Answer optiond

Marks: 2

In the following program make corrections to get correct output:


import java.sql.*;
class DBEx
{
public static void main(String args[])
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:mydsn","","");
Statement s = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
610 String sql = "create table Product(prod_id Integer, prod_name varchar(25), price Double)";
s.executeCreate(sql);
System.out.println("Table created.");
c.close();
}catch(Exception e)
{
System.out.println("Exception generated: "+e);
}
}
}

A. s.executeTable(sql);

B. s.executeCreateTable(sql);

C. s.executeUpdate(sql);

D. s.executeNewTable(sql);

Answer optionc

Marks: 2

Consider the following program. Fill the missing(*******) statement.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionIdServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException
611 {
**************
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.print("<B>");
pw.print("Your session Id:"+hs.getId());
}
}

A. HttpSession hs = response.setSession(true);

B. HttpSession hs = request.getSession(true);

C. HttpSession hs = request.addSession();

D. HttpSession hs = reponse.insertSession();

Answer optionb

Marks: 2

Choose the missing statements in following code from given options.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class WritingCookies extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException
612 {
Cookie cookie = new Cookie("dept-codes","CO-CD-CM-IF");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("One cookie is set.");
pw.close();
}
}

A. response.insertCookie(cookie);

B. response.addNewCookie(cookie);

C. response.setCookie(cookie);

D. response.addCookie(cookie);

Answer optiond

Marks: 2
Choose missing statement in following code from given options.
public class MyHTTPServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{
response.setContentType("text/html");
613 PrintWriter pw = response.getWriter();
pw.println("<B>AJP-17625</B>");
pw.println("<BR>CO-6G");
pw.close();
}
}

import java.io.*;
A. import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
B. import javax.servlet.*;

import javax.servlet.*;
C. import javax.servlet.http.*;

import java.io.*;
D. import javax.servlet.http.*;

Answer optiona

Marks: 2

Find errors in following code.


import java.io.*;
import javax.servlet.*;
public class MyServlet extends GenericServlet
{
public void service(ServletRequest request, ServletResponse response)
{
614 response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Servlet programming</B>");
pw.println("<BR>It is cool!");
pw.close();
}
}

A. Error in service() method declaration

B. Error in import statements

C. Error in setContentType() method call

D. Error in getWriter() method call

Answer optiona

Marks: 2

615 Select correct option for syntax of servlet life cycle methods.

public void init(ServletConfig config) throws ServletException


A. public void service(ServletRequest, ServletResponse)
public void destroy( )

public void init(ServletContext context) throws ServletException


B. public void service(ServletRequest, ServletResponse)
public void destroy( )

public void init( ) throws ServletException


C. public void service(HttpServletRequest, HttpServletResponse)
public void destroy( )

public void init() throws ServletException


D. public void service(ServletRequest, ServletResponse)
public void destroy( )

Answer optiona

Marks: 2
Which of the missing code need to be inserted in a given code to delete second row in ResultSet.
import java.sql.*;
import java.sql.ResultSet.*;
class delrset
{public static void main(String args[])
{try
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:stud");
Statement s = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=s.executeQuery("select * from stud");
while(rs.next())
616 System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
System.out.println("After deleting row:");
rs.first();
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
while(rs.next())
{System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
}
con.close();
}
catch(Exception e){ }
}
}

rs.next( )
A. rs.delete();

rs.first();
B. rs.next( )
rs.delete();

rs.first( );
C. rs.next( )
rs.deleterow();

rs.absolute(2);
D. rs.deleteRow();

Answer optiond

Marks: 2

Select correct statement which is to be used here for inserting a new record in DB having columns RollNo,Name and Percentage.
import java.io.*;
import java.sql.*;
import java.sql.Statement;
class insertdb
{public static void main(String args[])
{try
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:stud");
Statement s = con.createStatement();
617
System.out.println("No. of row updated:"+r);
ResultSet rs=s.executeQuery("select * from stud");
while(rs.next())
{System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
}
con.close();
}
catch(Exception e){ }
}
}

A. int rs = s.executeUpdate("insert into stud value(5,'Sneha',67)");

B. int r = s.executeUpdate("insert into stud values(5,'Sneha',67)");

C. int r = s.executeUpdate("insert in stud values(5,'Sneha',67));

D. int r= s.executeUpdate("insert in stud where values(5,'Sneha',67)");

Answer optionb

Marks: 2

Complete remaining code for getting output as shown in figure.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*<applet code="jcombodemo" width=300 height=100></applet>*/
public class jcombodemo extends JApplet implements ItemListener
{ JLabel jl;
ImageIcon green, red, black, yellow;
public void init()
{
618 Container cp = getContentPane();
JComboBox jc = new JComboBox();
jc.addItem("Creek");
jc.addItem("Dock");
jc.addItem("Forest");
jc.addItemListener(this);
cp.add(jc);
jl = new JLabel(new ImageIcon("Creek.jpg"));
cp.add(jl);
}

public void itemValueChanged(ItemEvent ie)


{ String s = (String)ie.getItem();
A. jl.setIcon((s + ".jpg"));
}}
public void itemStateChanged(ItemEvent ie)
{ String s = (String)ie.getItem();
B. jl.setIcon(new ImageIcon(s + ".jpg"));
}}

public void StateChanged(ItemEvent ie)


{ String s = (String)ie.getItem();
C. jl.setIcon(new ImageIcon(s + ".jpg"));
}}

public void actionPerformed(ItemEvent ie)


{ String s = (String)ie.getItem();
D. jl.setIcon(new ImageIcon(s+ ".jpg"));
}}

Answer optionb

Marks: 2

619 List control in AWT, generates �������.. Event on ������. Click.

A. ItemEvent on Single click.

B. ActionEvent on Double click

C. ItemEvent on double click.

D. Both Options A and B correct.

Answer optiond

Marks: 2

620 Swing components are light weight because:

A. Swing components are platform independent.

B. Swing components are platform dependent.

C. Swing components are portable.

D. Swing components are not portable.

Answer optiona

Marks: 2

Following statement means:


621 HttpSession getSession( )

It will return existing session object,If not it will create


A. a new sesssion.

It will delete existing session object and it will create


B. a new sesssion.

C. It will return existing session object,If not it will not create a new sesssion.

D. It will delete existing session object and also will not create a new session object.

Answer optiona

Marks: 2

622 TCP does not supports Multicasting and Broadcasting because:

A. It supports full duplex communication.

B. It provides error control.

C. It provides flow control.

D. It is connection oriented protocol.

Answer optiond

Marks: 2
Consider given database and Select correct output for following code:
import java.sql.*;
class StudentData
{ public static void main(String args[])
{ try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:stud");
PreparedStatement ps =con.prepareStatement("select * from Student where Marks > ?");
623 ps.setInt(1,70); //set question marks place holder
ResultSet rs = ps.executeQuery(); //execute
System.out.println("Students having marks > 70 are:");
while(rs.next())
System.out.println(rs.getString(2));
con.close();
}catch(Exception e){ }
}
}

Students having marks > 70 are:


Rakhee
A. Rahul
Karthik

Students having marks > 70 are:


Rakhee 75
B. Rahul 78
Karthik 71

Students are:
Rakhee
C. Rahul
Karthik

Students are:
Rakhee
D. Amit
Ajita

Answer optiona

Marks: 2

What the following statement returns?


624 SQLWarning warning = statement.getWarnings();
System.out.println("Message: " + warning.getMessage());

A. Output of Warning

B. Warning number

C. Description about SQL warning

D. Displays "Message"

Answer optionc

Marks: 2

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 DataInputStream(so.getInputStream());


String pass1 = in.readLine();
625 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");
}
}
}

A. int so=ss.wait( );

B. Socket so = ss.accept();

C. ServerSocket so=ss.accept( )

D. ClientSocket so=ss.accept( )

Answer optionb

Marks: 2

626 getSource( ) method of ActionEvent retrieves:


A. Current X,Y positions where mouse is clicked.

B. Component object which generated event.

C. Caption written on object which generated event.

D. Command written on component which generated event.

Answer optionb

Marks: 2

627 Cookies can be deleted by using����������.. Method.

A. delete( )

B. setMaxAge( )

C. setTime( )

D. destroy( )

Answer optionb

Marks: 1

628 Select correct statement to add component in south region.

A. add(component obj,BorderLayout.SOUTH);

B. BorderLayout.SOUTH.add(component obj);

C. BorderLayout.add(component obj,SOUTH);

D. add(component obj,Borderlayout.SOUTH);

Answer optiona

Marks: 2

629 Tabbedpane Layout can be changed using:

A. setLayout( ) method.

B. Mentioning layout in addTab( ) method.

C. Mentioning layout in constructor only.

D. It can not be changed.

Answer optionc

Marks: 2

630 Which is the correct syntax of next( ) method of ResultSet?

A. boolean next( )

B. int next( )

C. void next( )

D. char next( )

Answer optiona

Marks: 1

631 What is return type of getSession( ) method?

A. boolean

B. int

C. void

D. HttpSession

Answer optiond

Marks: 1
632 Which of the following method is used to destroy the session?

A. dead( )

B. invalidate( )

C. Close( )

D. destroy( )

Answer optiond

Marks: 1

633 The _______ method in servlet life cycle handles all client request.

A. init( )

B. serve( )

C. execute( )

D. service( )

Answer optiond

Marks: 1

634 To retrieve a Connection object,�������. Method is used.

A. connection( )

B. establish( )

C. getConnection( )

D. getConnected( )

Answer optionc

Marks: 1

635 Following is return type of executeUpdate( ):

A. int

B. ResultSet

C. void

D. char

Answer optiona

Marks: 1

636 Which AWT component is not editable?

A. Button

B. TextField

C. TextArea

D. Label

Answer optiond

Marks: 1

637 ���������. method is used to lock text box components.

A. setText( )

B. setLock(boolean flag )

C. setEditable(boolean flag)

D. hide( )

Answer optionc
Marks: 1

638 Checkable menu items are created using object of ��������.class.

A. CheckboxMenuItem

B. CheckBoxMenuItem

C. CheckboxGroupMenuItem

D. CheckableMenuItem

Answer optiona

Marks: 1

639 List can be created for multiple selection by using following constructor.

A. List( )

B. List(int num)

C. List(boolean flag)

D. List(int num,boolean multiselect)

Answer optiond

Marks: 1

640 Which method is used to place component manually ?

A. void setSize(int width,int height)

B. void setBounds(int x,int y,int width,int height)

C. void setLocation(int x,int y)

D. none of the above

Answer optionb

Marks: 1

641 Scrollbar control generates �����������. Event.

A. ItemEvent

B. ActionEvent

C. AdjustmentEvent

D. ScrollEvent

Answer optionc

Marks: 1

642 Which AWT control is used for multi-line text entry?

A. TextBox

B. TextField

C. TextArea

D. Label

Answer optionc

Marks: 1

643 AWT is used for creating a GUI in Java. AWT stands for

A. Advanced Web Technology

B. Abvanced Window Toolkit

C. Abstract Web Toolkit

D. Abstract Window Toolkit


Answer optiond

Marks: 1

644 Double-buffering built in, tool tips, dockable tool bars, keyboard accelerators, custom cursors, etc. are new features of _______?

A. AWT

B. Swing

C. Both AWT and Swing

D. None of the above

Answer optionb

Marks: 1

645 Which class creates a node in Jtree?

A. Node

B. DefaultMutableTreeNode

MutableNode
C.

D. TreeNode

Answer optionb

Marks: 1

646 The class which encapsulates both the numerical IP address and the domain name for that address.

A. DatagramPacket

B. DatagramSocket

C. InetAddress

D. ServerSocket

Answer optionc

Marks: 1

647 In the URL, http://www.osborne.com:80/index.htm, 80 represents

A. Host name

B. Port number

C. File path

D. Protocol

Answer optionb

Marks: 1

API which controls access to the row result of a given Statement and holds data retrieved from a database after you execute an SQL
648 query using Statement objects.

A. java.sql.Connection

B. java.sql.DriverManager

C. java.sql.ResultSet

D. java.sql.Statement

Answer optionc

Marks: 1

649 In which type of driver must Odbc drivers be loaded on client machine?

A. Type 1

B. Type 2

C. Type 3
D. Type 4

Answer optiona

Marks: 1

650 The interface used to execute SQL stored procedures

A. Statement

B. CallableStatement

C. PreparedStatement

D. None of the above

Answer optionb

Marks: 1

651 Which of the following packages are required to create servlets in java?

A. javax.servlet, javax.servlet.http

B. java.servlet, java.servlet.http

C. servlet.http

D. http.servlet

Answer optiona

Marks: 1

652 On typing a URL on the address bar, which HTTP request gets generated? Select the one correct answer

A. GET method

B. POST method

C. HEAD method

D. PUT method

Answer optiona

Marks: 1

653 Which life cycle method is used to process a client's request?

A. start()

B. init()

C. service()

D. destroy()

Answer optionc

Marks: 1

654 Which method is used in the servlet class, to retrieve the input values from HTML page?

A. request.getValues()

B. request.retrieve()

C. response.getValues()

D. request.getParameter()

Answer optiond

Marks: 1
In the below program, why is java.awt package imported?
import javax.swing.*;
import java.awt.*;
public class NewMain extends JFrame
{
public static void main(String[] args)
{
JFrame jf=new JFrame(""My Frame"");
Container cpane=jf.getContentPane();
JLabel l1=new JLabel(""Name"");
JButton b1=new JButton(""OK"");
655 JButton b2=new JButton(""CANCEL"");
JTextField t1= new JTextField();
jf.setLayout(new GridLayout(2,2));
cpane.add(l1);
cpane.add(t1);
cpane.add(b1);
cpane.add(b2);
jf.setSize(100,100);
jf.setVisible(true);
jf.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}

A. Because JFrame belongs to the package java.awt

B. Because JLabel belongs to the package java.awt

C. Because JTextField belongs to the package java.awt

D. Because Container belongs to the package java.awt

Answer optiond

Marks: 2

For the below code, how is a JTable object created?


656 String[] colHeads = { "Name", "Extension", "ID#" };
Object[][] data = {{ "Gail", "4567", "865" },{ "Ken", "7566", "555" }};

A. JTable jt=new JTable(data,colHeads);

B. JTable jt=new JTable(colHeads,data);

C. JTable jt=new JTable();

D. JTable jt=new JTable(data);

Answer optiona

Marks: 2

657 How can a dialog box be closed?

A. Using ActionListener

B. Using DialogListener

C. Using WindowListener

D. Using FocusListener

Answer optionc

Marks: 2

658 Pick the correct statement to register a button b for event handling

A. b.addActionListener(this);

B. b.addItemListener(this);

C. b.addMouseListener(this);

D. b.addFocusListener(this);

Answer optiona

Marks: 2

659 Pick the correct abstract method which belongs to MouseMotionListener interface

A. mouseEntered()

B. mouseExited()

C. mouseReleased()
D. mouseDragged()

Answer optiond

Marks: 2

Socket connection = server.accept( );


660
In the above statement, server is an object of ___________class and accept() method throws ________exception.

A. Socket, SocketException

B. URL, IOException

C. ServerSocket, IOException

D. Socket, IOException

Answer optionc

Marks: 2

What does "msbte" indicate in the below code?


661 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:msbte");

A. It’s a table of the database

B. Data Source Name

C. Database name

D. driver name

Answer optionb

Marks: 2

In the below code, rs is an object of _________ interface of JDBC API


while (rs.next()) {
662 System.out.println(rs.getString(3));
}

A. RowSet

B. Statement

Connection
C.

D. ResultSet

Answer optiond

Marks: 2

In the below statement, which type of query can be used with executeUpdate() method
663 statement.executeUpdate(query);

A. INSERT, UPDATE, DELETE

B. INSERT, SELECT, DELETE

C. ONLY SELECT

D. any Query

Answer optiona

Marks: 2

For the below html code:


664 <input type="text" name="username�>
The servlet code to retrieve the value from the text box is:

String str=req.getValue("username");
A. where req is HttpServletRequest object

String str=req.getValue("username");
B. where req is HttpServletRequest object

String str=req.getParameter("username");
C. where req is HttpServletRequest object

String str=req.retrieveParameter("username");
D. where req is HttpServletRequest object
Answer optionc

Marks: 2

What does the below code do?


Cookie cookie = new Cookie("mycookie","msbte");
665 response.addCookie(cookie);

where response is object of HttpServletResponse

Creates a cookie with name as "mycookie" and


A. value as "msbte" and saves it in user's machine

Creates a cookie with name as "mycookie" and


B. value as "msbte" and saves it in server's machine

Creates a cookie with name as "msbte" and


C. value as "mycookie" and saves it in user's machine

Creates a cookie with name as "msbte" and


D. value as "mycookie" and saves it in server's machine

Answer optiona

Marks: 2

For the following output window, what type of Event Listener and abstract method implementation should be done for event handling on
666 the radiobutton?

A. ActionListener, actionPerformed(ActionEvent e)

B. ActionListener, actionChanged(ActionEvent e)

C. ItemListener,itemStateChanged(ItemEvent ie)

D. ItemListener,itemPerformed(ItemEvent ie)

Answer optiona

Marks: 2

For the following client side code of TCP implementation of sockets, what should be the server side code in order to establish
connection between both the machines?
import java.io.IOException;
import java.net.*;

667 public class Client {

public static void main(String[] args) throws UnknownHostException, IOException {


Socket sock=new Socket("127.0.0.1",2000);
}
}

import java.io.IOException;
import java.net.*;

public class Server {

A. public static void main(String[] args) throws IOException {


ServerSocket ss=new ServerSocket(2000);
Socket sock=ss.accept();
System.out.println("Connection Established");
}
}

import java.io.IOException;
import java.net.*;

public class Server {

B. public static void main(String[] args) throws IOException {


ServerSocket ss=new ServerSocket();
Socket sock=new Socket(2000);
System.out.println("Connection Established");
}
}

import java.io.IOException;
import java.net.*;

public class Server {

C. public static void main(String[] args) throws IOException {


ServerSocket ss=new ServerSocket(2000);
System.out.println("Connection Established");
}
}
import java.io.IOException;
import java.net.*;

public class Server {

D. public static void main(String[] args) throws IOException {


ServerSocket ss=new ServerSocket(2000);
Socket sock=ssop.accept();
System.out.println("Connection Established");
}
}

Answer optiona

Marks: 2

668 Which statements are needed to establish connection to database?

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
A. Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
B. Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();

C. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

D. c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");

Answer optiona

Marks: 2

Consider the following program. Which two exceptions are thrown?

package javaapplication21;

import java.sql.*;
public class db15
{
669 public static void main(String args[]) throws _____________________, __________________
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
System.out.println("Connection Established");
}
}

A. IOException, SQLException

B. MalformedURLException,IOException

C. ClassNotFoundException, SQLException

D. ClassNotFoundException, IOException

Answer optionc

Marks: 2

670 Which are the statements related to retrieving table names from a database?


Connection con = …. ;
MetaData dbmd = con.getMetaData();
String catalog = null;
String schema = null;
A. String table = “sys%”;
String[ ] types = null;
ResultSet rs =
dbmd.getTables(catalog , schema , table , types );


Connection con = …. ;
DatabaseMetaData dbmd = con.getMetaData();
String catalog = null;
String schema = null;
B. String table = “sys%”;
String[ ] types = null;
ResultSet rs =
dbmd.getTables(catalog , schema , table , types );


Connection con = …. ;
MetaData dbmd = con.getData();
String catalog = null;
String schema = null;
C.
String table = “sys%”;
String[ ] types = null;
ResultSet rs =
dbmd.retrieveTables(catalog , schema , table , types );


Connection con = …. ;
ResultSet dbmd = con.getData();
String catalog = null;
String schema = null;
D. String table = “sys%”;
String[ ] types = null;
ResultSet rs =
dbmd.retrieveTables(catalog , schema , table , types );

Answer optionb

Marks: 2

In the following code, what are the statements within doGet() method to display "Hello from Servlet" on the web browser.
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
671
public class NewServlet extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {

}
}

PrintWriter pr=response.getWriter();
A. System.out.println("Hello from Servlet");

PrintWriter pr=request.getWriter();
B. pr.println("Hello from Servlet");

PrintWriter pr=response.getWriter();
C. pr.println("Hello from Servlet");

D. None of the above

Answer optionc

Marks: 2

672 For the following output, what is the html <form> tag code?

A. <FORM METHOD="GET" ACTION="/Newservlet/Hello Inigo Montaya">

B. <FORM METHOD="POST" ACTION="/servlet/Hello">

C. <FORM METHOD="GET" ACTION="/servlet/Hello">

D. <FORM METHOD="POST" ACTION="/Newservlet/Hello Inigo Montaya">

Answer optionc

Marks: 2

How is the form data stored as a cookie on client machine? Pick out the correct servlet code for the below html code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Form</title>
</head>
673 <body>
<form method="get" action="CServlet">
Enter your name : <input type="text" name="myname">
<input type="submit" value="go">
</form>
</body>
</html>

String s=request.getParameter("myname");
A. response.addCookie("name",s);

String s=response.getParameter("myname");
B. Cookie c=new Cookie("n", s);
response.addCookie(c);

String s=request.getParameter("myname");
Cookie c=new Cookie("n", s);
C. request.addCookies(c);

String s=request.getParameter("myname");
D. Cookie c=new Cookie("name", s);
response.addCookie(c);

Answer optiond

Marks: 2

674 Panel is defined as


A. The Panel class is a concrete subclass of Container.

B. A Panel is a window that does not contain a title bar, menu bar, or border.

C. Panel is the superclass for Applet

D. All of above

Answer optiond

Marks: 1

675 Select the proper syntax to addcomponent in an applet

A. Component add(Component comoObj)

B. void add(Component comoObj)

C. Component add(String compj)

D. Public void t add(Component compobj)

Answer optiona

Marks: 1

676 Which of the method Choice class returns a string containing the name of the item.

A. String getSelectedItem()

B. int getSelectedIndex()

C. int getItemCount()

D. void select(int index)

Answer optiona

Marks: 1

677 Select the proper constructor of FileDialog

A. FileDialog(Frame parent, String boxName)

B. fileDialog((Frame parent, String boxName)

C. Filedialog(Frame parent, String boxName)

D. FileDialog(String boxName)

Answer optiona

Marks: 1

678 Which package we need to import while writng swing JRadioButton class

A. import java.awt.*;

B. import javax.swing.*;

C. import java.awt.event.*;

D. All of above

Answer optionb

Marks: 1

679 Select the proper constructor of EventObject class

A. EventObject(String src)

B. EventObject(Object src)

C. EventObject()

D. All of above

Answer optionb

Marks: 1
680 In which package class AWTEvent defined

A. java.awt package;

B. java.applet.*

C. java.net.*;

D. java.lang.*

Answer optiona

Marks: 1

681 Which method is used to return the IPAddress of local machine

A. static InetAddress getLocalHost( )

B. static InetAddress getHostName( )

C. static InetAddress getHost( )

D. static InetAddress getByName( )

Answer optiona

Marks: 1

682 The method int getPort( ) of Socket class returns____________

A. IP address of local machine

B. remote port to which this Socket object is connected.

C. host name of remote machine.

D. local port to which this Socket object is connected.

Answer optionb

Marks: 1

683 Advantage of JSP over Servlet is____________

A. . JSP is web page and servlets are Java programs

B. JSP is web page scripting language and servlets are Java programs

C. . JSP is web page scripting language and servlets are simple programs

D. JSP is program and servlets are scripting language

Answer optionb

Marks: 1

684 getWriter() method can be called by --------------------object

A. ServletResponse object

B. ServletRequest object

C. ServletConfig object

D. none of the above

Answer optiona

Marks: 1

685 Select the suitable statement for given output

A. TextField,BorderLaout

B. Label,FlowLayout.RIGHT

C. Buttons,FlowLayout.RIGHT

D. Label,flowLaout.Right

Answer optionc
Marks: 2

686 select the proper methods of mouse motion listener

A. void mouseClicked(MouseEvent me)

B. void mouseMoved(MouseEvent me)

C. void mouseExited(MouseEvent me)

D. void mouseReleased(MouseEvent me)

Answer optionb

Marks: 2

To get the following output complete the code given below.

import java.awt.*;
import javax.swing.*;
/*
<applet code="jscroll" width=300 height=250>
</applet>
*/
public class jscroll extends JApplet
{
public void init()
687 {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
}
}
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPanejsp = new JScrollPane(jp, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}

Container contentPane = getContentPane();


A. contentPane.setLayout(new GridLayout());

JPaneljp = new JPanel();


B. jp.setLayout(new GridLayout(20, 20));

int b = 0;
for(int i = 0; i < 20; i++) {
C. for(int j = 0; j < 20; j++) {
jp.add(new JButton("Button " + b));
++b;

JPaneljp = new JPanel();


jp.setLayout(new GridLayout(3,3));
int b = 0;
for(int i = 0; i <3; i++)
{
D. for(int j = 0; j <3; j++)
{
jp.add(new JButton("Button " + b));
++b;
}
}

Answer optiond

Marks: 2

select the missing statement from program given below


import java.sql.*;
class ps_insert
{
public static void main(String ar[])
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("driver loaded");
String url="jdbc:odbc:insert1";
Connection con=DriverManager.getConnection(url);
System.out.println("connection created");
int r1=11,r2=22;
String s1="madras",s2="delhi";
688 ps.setInt(1,r1);
ps.setString(2,s1);
int i1=ps.executeUpdate();
System.out.println("data inserted"+i1);
String str1="insert into if6g values(?,?)";
PreparedStatement ps1=con.prepareStatement(str1);
ps.setInt(1,r2);
ps.setString(2,s2);
int i2=ps1.executeUpdate();
System.out.println("data inserted"+i2);
con.close();
ps.close();
}
catch(Exception e)
{}}

String str="insert into if6g values(?,?)";


A. PreparedStatement ps=con.prepareStatement(str);
String str="insert into if6g values()";
B. PreparedStatement ps=con.prepareStatement(str);

String str="insert into if6g values(?,?)";


C. PreparedStatement ps=con.prepareStatement();

D. PreparedStatement ps=con.prepareStatement(str);

Answer optiona

Marks: 2

689 select the proper statement to establish the connection with database

A. Connection con=DriverManager.getConnection("Jdbc.odbc : DSN Name");

B. Connection con=DriverManager.getConnection();

C. Statement st= DriverManager.getConnection();

D. Connection con=DriverManager.getconnection("Jdbc.odbc : DSN Name");

Answer optiona

Marks: 2

690 select the proper syntax of doGet() method

A. void doGet(ServletRequest req,ServletResponse res)throws IOException, ServletException

B. void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException, ServletException

C. void doGet(HttpServletRequest req,HttpServletResponse res)

D. void doGet(HttpServletRequest req, ServletResponse res)throws IOException, ServletException

Answer optionb

Marks: 2

691 choose the classes of javax.servlet package

ServletConfig
A. ServletContext

ServletException
B. GenericServlet

GenericServlet
C. Servlet

ServletRequest and
D. ServletResponse

Answer optionb

Marks: 2
Select the missing statement in the program to get the following output

importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
/*
<applet code="combodemo" width=300 height=100>
</applet>
*/
public class combodemo extends JApplet
implementsItemListener
{
JLabeljl;
ImageIconfrance, germany, italy, japan;
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JComboBoxjc = new JComboBox();
692 jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");
jc.addItemListener(this);
contentPane.add(jc);
contentPane.add(jl);
}
public void _____________(ItemEvent ie)
{
String s = (String)ie.getItem();
jl = new JLabel("star.gif");
jl.setIcon(new ImageIcon(s + ".gif"));
}
}

C. jl = new JLabel( ImageIcon("star.gif"));


D. JLabel(new ImageIcon("star.gif"));

A. itemStateChanged(ActionEvent ie)

B. actionStateChanged(ItemEvent ie)

C. itemStateChanged(ItemEvent ie)

D. None of These

Answer optionc

Marks: 2

insert the missing statement ,rectify incorrect statement and choose the correct option for given program.

Import java.io.*;
public static void main(String args[])
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String s=�jdbc:odbc:dsn1�;
693 Connection con=DriverManager.getConnection(s);
System.out.println("connection established");
String s=�insert into student values (11,�ramesh�);
Statement st=con.createStatement(s);
st.executeUpdate();
System.out.println("data inserted ");
st.close();
con.close();
}

import java.sql.*;
A. con.createStatement(s)

import java.sql.*;
B. con.CreateStatement()

import java.sql.*;
C. con.createstatement()
st.executeUpdate(s)

import java.sql.*;
D. con.createStatement()
st.executeUpdate(s)

Answer optionc

Marks: 2

694 select correct statement to delete row from table employee where emp_id=?

String sql=”delete from table where emp_id=?”;


A. PreparedStatement st=con.prepareStatement(sql);
st.executeUpdate();

String sql=”delete from table where emp_id=?”;


B. PreparedStatement st=con.prepareStatement();
st.executeUpdate(sql);
String sql=”delete from table where emp_id=?”;
C. PreparedStatement st=con.prepareStatement(sql);
st.executeupdate()

String sql=”delete from table where emp_id=?”;


D. PreparedStatement st=con.prepareStatement(sql);
st.executeStatement();

Answer optiona

Marks: 2

695 public class MenuBar extends ____________________

A. MenuComponent

B. MenuContainer

C. ComponentMenu

D. MenuBar

Answer optiona

Marks: 1

The CardLayout class manages the components in such a manner that ____________component is visible at a time
696

A. multiple

B. HiddenComponent

C. Only one

D. noneof the above

Answer optionc

Marks: 1

697 ________________________ Constructs a new scroll bar with the specified orientation.

A. Scrollbar(int)

B. Scrollbar(int,int)

C. Scrollbar(char)

D. none of the above

Answer optiona

Marks: 1

698 For using Swing control one must import______________________________pacakge

A. import javax.swing.*

B. import awt.swing.*

C. import java.swing.*G7

D. none of the above

Answer optiona

Marks: 1

699 Internet protocol(IP) is a ____________ protocol

A. Low level routing

B. High level routing

C. medium level routing

D. none of the above.

Answer optiona

Marks: 1

700 Class URL represents __________________________________, a pointer to a "resource" on the World Wide Web
A. Uniform Resource Locator

B. Uniform Resource allocator

C. Unity Resource Locator

D. Uniform Respond Locator

Answer optiona

Marks: 1

701 The Type 3 architecture is _______________________

A. JDBC-Net pure Java

B. JDBC-Native API

C. JDBC-ODBC Bridge Driver

D. All of the above

Answer optionb

Marks: 1

702 In 2-tier architecture , the first tier is generally_________________________

A. GUI

B. Serverside

C. combination of GUI n Server

D. None of the above

Answer optiona

Marks: 1

703 The ResultSet __________________provides methods for retrieving and manipulating the results of executed queries.

A. interface

B. method()

C. Event

D. Pacakge

Answer optiona

Marks: 1

704 ______________Defines page-dependent attributes, such as scripting language, error page, and buffering requirements.

A. <%@ page ... %>

B. <%@ include ... %>

C. <%@ taglib ... %>

D. none of the above

Answer optiona

Marks: 1

705 A ___________________ is a small piece of information that is persisted between the multiple client requests.

A. cookie

B. url

C. parameter

D. JSP

Answer optiona

Marks: 1
706 TLDs are used by a ___________________ to validate the tags and by JSP page development tools

A. web container

B. web browser

C. World Wide Web

D. All of the above

Answer optiona

Marks: 1

707 To set new font object with size 48 , name: Serif , Style PLAIN, what will be the statement from the following

A. new Font("Serif", Font.PLAIN, 48)

B. new FonType("Serif", Font.PLAIN, 48)

C. new FonType("Serif", STYLE.PLAIN, 48)

D. new Font(Name."Serif", Font.PLAIN, 48)

Answer optiona

Marks: 2

In how many ways we can create URL


708 A)URL url = new URL("http://hostname:80/index.html");
B)URL url = new URL("http", "hostname", 80, "index.html");

A. A & B both

B. Only A

C. Only B

D. none of the above

Answer optiona

Marks: 2

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",12345);
709 B) ServerSocket s = new Socket("127.0.0.1",12345);
C) Socket s = new Socket("localhost", 12345);

A. A

B. B

C. C

D. none of the above

Answer optiona

Marks: 2

710 To Get All addresses by name of a URL - "www.google.com" following command is used

A. InetAddress[] addresses = InetAddress.getAllByName("www.google.com");

B. Address[] addresses = InetAddress.getName("www.google.com");

C. InetAddress[] addresses = ("www.google.com").getAllByName;

D. InetAddress addresses = ByName("www.google.com");

Answer optiona

Marks: 2

Identify the correct sequence of Steps for creation and execution of java and html file for servlet
A) Create a directory structure under Tomcat for your application. Write the servlet source code. You need to import the
B)Javax.servlet package and the javax.servlet.http package in your source file.
711 C)Compile your source code.
D)Create a deployment descriptor.
E)Run Tomcat.
F)Call your servlet from a web browser.

A. ABCDEF
B. ACBDEF

C. BCADEF

D. none of the above

Answer optiona

Marks: 2

712 Methods that set the maximum age of the cookie is : ____________________

A. public void setMaxAge(int secs)

B. public int getMaxAge()

C. A & B Both

D. none of the above

Answer optiona

Marks: 2

<HTML>
<BODY>
<FORM ACTION="someaction" METHOD="post">
<INPUT TYPE="hidden" NAME="tag1" VALUE="value1">
713 <INPUT TYPE="hidden" NAME="tag2" VALUE="value2">
<INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>

A. When you open this HTML document in a browser, the input types marked as hidden will not be visible.

B. When you open this HTML document in a browser, the input types marked as hidden will be visible.

C. When you open this HTML document in a browser, every and every page will be hidden on that browser

D. none of the above

Answer optiona

Marks: 2

Dectate Error in folloing code , Specify line number if any;


1. import java.applet.*;
2. import java.awt.*;
3. import java.swing.*;
4. public class S1Q
5. {
714 6. public static void main(String[] args)
7. {
8. JFrame frame = new JFrame("Hello Swing");
9. frame.setSize(200,200);
10. frame.setVisible();
11. }
12. }

A. Line number 3

B. Line number 10 and 3

C. Line number 10

D. none of the above

Answer optionb

Marks: 2

1.import java.awt.*;
2.import java.applet.*;
3.public class sample3 extends Applet
4.{
5.public void init()
6.{
7.Choice country=new Choice();
715 8.country.add("india");
9.country.add("america");
10.country.add("shrilanka",true);
11.country.add("japan");
12.add(country);
13.}
14.}

A. No Error

B. Runtime Error

C. Line number 10
D. none of the above

Answer optionc

Marks: 2

1.public class sample5 extends Applet


2.{
3.public void init()
4.{
5.//CheckboxGroup cg=new CheckboxGroup();
6.Checkbox c1,c2,c3,c4;
7.c1=new Checkbox("maths",true);
8.c2=new Checkbox("physics",false);
716 9.c3=new Checkbox("science",false);
10.c3=new Checkbox("computer",true);
11.add(c1);
12.add(c2);
13.add(c3);
14.add(c4);
15 .}
16. }

A. Line number 14

B. Line number 10 & 14

C. No Error at all

D. none of the above

Answer optiona

Marks: 2

717 To register a checkbox to event class following statement must get included in your program

A. checkBox.addActionListener(actionListener);

B. checkBox.addItemListener(itemListener);

C. contentPane.add(checkBox, BorderLayout.NORTH);

D. Both A & B

Answer optiond

Marks: 2

User clicks a button, presses Return while typing in a text field, or chooses a menu item will use the following Listener class /
718 classess

A. ActionListener

B. ActionListener and MouseMotionListener both

C. WindowListenerand MouseMotionListener both

D. actionPerformed()

Answer optiona

Marks: 2
To have the following output Insert proper commands in the given code at*__________________
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/*<applet code="SimpleKey1.class" width=400 height=400></applet>*/
public class SimpleKey1 extends *_________________________________________________
{
String msg="";
int x=10,y=20;
public void init()
{
addKeyListener(this);
requestFocus();
}
public void *___________________________________
719 {
showStatus("Key Down");
}
public void keyReleased(KeyEvent ke)
{
showStatus("Key Up");
}
public void keyTyped(KeyEvent ke)
{
msg +=ke.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,40,80);
}
}

A. JApplet implements KeyListener keyPressed(KeyEvent ke)

B. JApplet implements KeyListener keyTyped(KeyEvent ke)

C. JApplet implements MouseMotionListener keyTyped(KeyEvent ke)

D. JApplet keyPressed(KeyEvent ke)

Answer optiona

Marks: 2

What is the meaning of following code segment?


720
BufferedReader inFromServer =new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

A. new inFromServer object containing data from inputstream object of clientSocket

B. new clientSocket object containing data from inputstream inFromServer object

C. simply creates two new clientSocket object and inFromServer object

D. None of the above

Answer optiona

Marks: 2

Connection con=DriverManager.getConnection(url);
721 this command will create the following

A. new con object of connection class initiated with connection of content of url class

B. new url object of connection class initiated with connection of content of con class

C. new connection is established directly by con and urlobjects

D. None of the above

Answer optiona

Marks: 2

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Class.forName("oracle.jdbc.driver.OracleDriver");
722 }
catch(ClassNotFoundException cnfe)
{
System.err.println("Error loading driver: " + cnfe);
}

A. Will load two different drivers

B. Will load only one drivers

C. Will throw error object

D. None of the above


Answer optiona

Marks: 2

To to get the column names and row data from a table. Select the proper statement from the following AT *____________line
import java.sql.*;
public class SelDemo
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odb c: myDSN ");
Statement st = con.createStatement();
*_________________________________//(Choose correct option for this line)
723 while(sel.next())
{
String name = sel.getString(1);
String pass = sel.getString(2);
System.out.println(name+" "+pass);
}
}
catch(Exception e)
{
System.out.println("Errooorrrr"+e.getMessage());
}
}
}

ResultSet sel = st.executeQuery ("select * from Login");


A.

B. ResultSet sel = con.executeQuery ("select * from Login");

C. ResultSet con = sel.executeQuery ("select * from Login");

D. none of the above

Answer optiona

Marks: 2

724 Non-persistent cookie is valid for______________ session only

A. Single

B. two sessions

C. not applicable

D. none of the above

Answer optiona

Marks: 2

following is the code to get all the cookies . choose the proper option to fill the blank space in the code
Cookie ck[]=request.getCookies();
725 for(int i=0;i<ck.length;i++){
out.print("<br>"+ck[i].getName()+" "+_____________________________//printing name and value of cookie
}

A. ck[i].getValue());

B. cookiesk[i].getValue();

C. ck[i].getValues());

D. none of the above

Answer optiona

Marks: 2

726 int getServerPort() This method _________________________________

A. Returns the port number on which this request was received.

B. Returns the port name on which this request was received.

C. Returns the server number on which this request was received.

D. none of the above

Answer optiona

Marks: 2
Following is the jsp code to display the current date and time. Fill in the given blank with proper statement from given options.
<Html>
<Head>
<Title>JSP Expressions</Title>
</Head>
<Body>
<H2>JSP Expressions</H2>
<ul>
727 *__________________________
<li>Server: <%= application.getServerInfo() %>
<li>Session Id: <%= session.getId() %>
<li>The <code>test param</code> form parameter:
<%= request.getParameter("testParam")%>
</ul>
</Body>
</Html>

A. <li>Current time: <%= new java.util.Date() %>

B. <li>Current time: < new java.util.Date()>

C. <%= new java.util.Date() %>

D. none of the above

Answer optiona

Marks: 2

728 The concept of the menu bar can be implemented by using three java classes�

A. MenuBar

B. Menu

C. MenuItem

D. All of these

Answer optiond

Marks: 1

729 Which is the a constructor of JTabbed Pane

A. JTabbedPane(int tabPlacement, int tabLayoutPolicy)

B. JTabbedPane(int tabPlacement)

C. Both option A and B

D. None of the above

Answer optionc

Marks: 1

730 The constructor which the Text Event class defines.

A. TextEvent(Object source, int event_type)

B. textevent (Object source, intevent_type)

C. TextEvent (object Source, float event_type)

D. textevent (Object source, string event_type)

Answer optiona

Marks: 1

731 A source generates an event and sends it to ___________ listeners that can handle the event

A. One

B. Two

C. One or more

D. None of these

Answer optionc

Marks: 1

732 __________ is a factory method which returns an array of addresses.


A. getLocalhost.

B. getByName.

C. getAllByName.

D. getByAddress.

Answer optionc

Marks: 1

733 __________ is used to implement reliable, bidirectional, persistent point to point stream based connection.

A. TCP/IP client and server socket.

B. FTP/IP client socket.

C. TCP/IP server socket.

D. FTP client and server socket.

Answer optiona

Marks: 1

734 An API can be created for

A. applications

B. libraries

C. operating systems

D. All of these

Answer optiond

Marks: 1

735 What code would you use to construct a 24-point bold Calibri font?

A. new Font(Font.Calibri , 24,Font.BOLD);

B. new Font("Calibri", Font.BOLD,24);

C. new Font("BOLD ", 24,Font.Calibri);

D. new Font(Font.Calibri, "BOLD", 24);

Answer optionb

Marks: 2

736 Which constructor creates a TextArea with 10 rows and 20 columns?

A. new TextArea(10, 20);

B. new TextArea(200);

C. new TextArea(new Rows(10), new columns(20));

D. new TextArea(20, 10);

Answer optiona

Marks: 2

737 Which Componenets and layout manager are used in following output

A. Buttons,Borderlayout

B. Button,Textfield,Borderlayout

C. Button,Label,Borderlayout

D. Label,Applet,Borderlayout

Answer optiona

Marks: 2
find out missing statement in following code
import java.awt.*;
import javax.swing.*;
import java.applet.*;
public class ass1 extends JApplet implements ItemListener
{
JTextAreajtf;
JComboBoxjb;
public void init()
{
Container ContentPane=getContentPane();
ContentPane.setLayout(new FlowLayout());
String alpha[]={"A","B","C","D","E","F","G","H","I","J","K","L"};
JComboBox jb=new JComboBox(alpha);
738 ContentPane.add(jb);

jtf=new JTextArea(20,10);

public void itemStateChanged(ItemEvent IE)


{
String str=(String)IE.getItem();
jtf.append(str);
}
}
/*<applet code="ass1.class" width="400" height="500" ></applet>*/

A. jb.addItemListener(this);

B. import java.awt.event.*;

C. ContentPane.add(jtf);

D. All of these

Answer optiond

Marks: 2

739 Choose correct sequence of code for given output

import java.awt.*;
import java.applet.*;
/*<applet code="expe2.class" width=300 height=300>*/
public class expe2 extends Applet
{
Button lbl;
Button lbl1;
Button lbl2;
public void init()
A. {
setLayout(new FlowLayout(FlowLayout.RIGHT));
lbl=new Button("OK");
lbl1=new Button("Cancle");
lbl2=new Button("Exit");
add(lbl);
add(lbl1);
add(lbl2);
}
}

import java.awt.*;
import java.applet.*;
public class expe2 extends Applet
{
Button lbl;
Button lbl1;
Button lbl2;
public void init()
B. {
setLayout(new FlowLayout(FlowLayout.RIGHT));
add(lbl);
add(lbl1);
add(lbl2);
lbl=new Button("OK");
lbl1=n}
}

import java.awt.*;
import java.applet.*;
public class expe2 extends Applet
{
Button lbl;
Button lbl1;
Button lbl2;
C. public void init()
{
setLayout(new FlowLayout(FlowLayout.RIGHT));
lbl=new Button("OK");
lbl1=new Button("Cancle");
lbl2=new Button("Exit");
}
}
import java.awt.*;
import java.applet.*;
public class expe2 extends Applet
{
Button lbl;
Button lbl1;
Button lbl2;
public void init()
D. {
setLayout(new FlowLayout(FlowLayout.LEFT));
lbl=new Button("OK");
lbl2=new Button("Exit");
add(lbl);
add(lbl1);
add(lbl2);
}
}

Answer optiona

Marks: 2

What will be the output of given code


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
public class expt4 extends JApplet implements ActionListener
{
JComboBox cb;
public void init()
{
Container co=getContentPane();
co.setLayout(new FlowLayout());
JComboBoxcb=new JComboBox();
cb.addItem("Cricket");
cb.addItem("Football");
cb.addItem("Hockey");
cb.addActionListener(this);
co.add(cb);
}
740 public void actionPerformed(ActionEvent AE)
{
cb=(JComboBox)AE.getSource();
if("Cricket"==cb.getSelectedItem())
{
getContentPane().setBackground(Color.RED);
}
if("Football"==cb.getSelectedItem())
{
getContentPane().setBackground(Color.GREEN);
}
if("Hockey"==cb.getSelectedItem())
{
getContentPane().setBackground(Color.BLUE);
}

repaint();
}
}
/*<APPLET CODE="expt4.class" HEIGHT=200 WIDTH=200></APPLET>*/

A.

B.

C. Not Option A nor B

D. Both A and B

Answer optiond

Marks: 2

Consider the following code.What should be the correction done in the code to get correct output?
import java.sql.*;
class mytable
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = ("jdbc:odbc:mystudtable");
Connection con=DriverManager.getConnection(url);
System.out.println("ConnectionEstablished");
741 Statement studste = con.createStatement();
String studqry = "create table student(rno int,name char)";
studste .execute(qry);
}
catch(SQLException e)
{
System.out.println("databse Connection error.....");
}
catch(Exception e)
{
System.out.println("Other error.....");
}
}

A. replace statement studste.execute(qry) with studste.execute(studqry)

B. missing }
C. missing ;

D. Both option i and ii

Answer optiond

Marks: 2

Consider the following code.What will be student table data after executing this code as table was empty.

import java.sql.*;
public class mytableins
{
public static void main(String[] args) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String s = ("jdbc:odbc:mystudtable");
Connection con=DriverManager.getConnection(s);
System.out.println("Connection Established");
PreparedStatement studste = con.prepareStatement("insert into student values(2,'Rani')");
742 studste .executeUpdate();
Statement s1 = con.createStatement();
ResultSet Rset = s1.executeQuery( "select * from student");
System.out.println("Roll No ....Name");
while (Rset.next())
{
int studid = Rset.getInt("rno");
String studname = Rset.getString("name");
System.out.println(studid + " " +studname); }

}
}

A. two record will be inserted

B. only one record in table

C. table will be empty

D. error occurs

Answer optionb

Marks: 2

Consider the following code.Which statement need to update student table data by this code?

import java.sql.*;
public class mytableupdate
{
public static void main(String[] args) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String s = ("jdbc:odbc:mystudtable");
Connection con=DriverManager.getConnection(s);
System.out.println("Connection Established");
743 PreparedStatement studste = con.prepareStatement("update student set name='john' where rno=2");
Statement s1 = con.createStatement();
String studqry = "select * from student";
ResultSet Rset = stmt.executeQuery(studqry);
while (Rset.next()) {
int studid = Rset.getInt("rno");
String studname =Rset.getString("name");
System.out.println(studid + " " + studname); }

}
}

A. studste.executequery();

B. studste.execute();

C. studste.executeUpdate();

D. None of above

Answer optionc

Marks: 2
Consider the following code.find missing statement in code so that get desired output
import java.sql.*;
public class mytabledelete
{
public static void main(String[] args) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(s);
System.out.println("Connection Established");
PreparedStatement studste = con.prepareStatement("delete from student where rno=3");
studste.executeUpdate();
744 Statement s1 = con.createStatement();
String studqry = "select * from student";
ResultSet Rset = s1.executeQuery(studqry);
while (Rset.next())
{
int studid = Rset.getInt("rno");
String studname = Rset.getString("name");
System.out.println(studid + " " + studname); }

}
}

A. studste.execute();

B. missing }

C. String mystring= ("jdbc:odbc:mystudtable");

D. String s= ("jdbc:odbc:mystudtable");

Answer optiond

Marks: 2

Consider the following code.find error statement to execute the code

import java.sql.*;
public class JDBCExample
{
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"
static final String DB_URL = "jdbc:mysql://localhost/STUDENTS";
static final String USER = "username";
static final String PASS = "password";
public static void main(String[] args)
{
Connection conn = null;
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Connecting to a selected database...");
conn = DriverManager.getConnection(DB_URL, USER, PASS);
System.out.println("Connected database successfully...");
745 }catch(SQLException se)
{
se.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
finally{
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
} }
System.out.println("Goodbye!");
}

A. Missing semicolon

B. missing }

C. missing )

D. Both option i and ii

Answer optiond

Marks: 2
Consider the following code.Find missing statement
public class HelloForm extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
Cookie firstName = new Cookie("first_name",
request.getParameter("first_name"));
Cookie lastName = new Cookie("last_name",
request.getParameter("last_name"));

firstName.setMaxAge(60*60*24);
lastName.setMaxAge(60*60*24);

response.addCookie( firstName );
response.addCookie( lastName );

response.setContentType("text/html");

746 PrintWriter out = response.getWriter();


String title = "Setting Cookies Example";
String docType =
"<!doctype html public \"-//w3c//dtd html 4.0 " +
"transitional//en\">\n";
out.println(docType +
"<html>\n" +
"<head><title>" + title + "</title></head>\n" +
"<body bgcolor=\"#f0f0f0\">\n" +
"<h1 align=\"center\">" + title + "</h1>\n" +
"<ul>\n" +
" <li><b>First Name</b>: "
+ request.getParameter("first_name") + "\n" +
" <li><b>Last Name</b>: "
+ request.getParameter("last_name") + "\n" +
"</ul>\n" +
"</body></html>");
}
}

import java.awt.event.*;
A. import javax.swing.*;
import javax.servlet.http.*;

import java.awt.*
B. import javax.servlet.*;
import java.util.*;

import java.io.*;
C. import javax.servlet.*;
import javax.swing*;

import java.io.*;
D. import javax.servlet.*;
import javax.servlet.http.*;

Answer optiond

Marks: 2

Consider following code.find syntax error in code


import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class SessionExample extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)


throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();

HttpSession session = request.getSession(true);

Date created = new Date(session.getCreationTime());


Date accessed = new Date(session.getLastAccessedTime());
747 out.println("ID " + session.getId());
out.println("Created: " + created);
out.println("Last Accessed: " + accessed);

String dataName = request.getParameter("dataName");


if (dataName != null && dataName.length() > 0)
String dataValue = request.getParameter("dataValue");
session.setAttribute(dataName, dataValue);
}

Enumeration e = session.getAttributeNames();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
String value = session.getAttribute(name).toString();
out.println(name + " = " + value);
}
}
}

A. error in the if statement

B. missing }}

C. missig semicolon

D. All of these
Answer optiona

Marks: 2

Consider the following code.Find missing satement


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class RequestInfo extends HttpServlet {

public void doGet(HttpServletRequest request,__________________ response)


throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<head>");
748 out.println("<title>Request Information Example</title>");
out.println("</head>");
out.println("<body>");
out.println("<h3>Request Information Example</h3>");
out.println("Method: " + request.getMethod());
out.println("Request URI: " + request.getRequestURI());
out.println("Protocol: " + request.getProtocol());
out.println("PathInfo: " + request.getPathInfo());
out.println("Remote Address: " + request.getRemoteAddr());
out.println("</body>");
out.println("</html>");
}

A. HttpServletResponse

B. ServletResponse

C. ServletRequest

D. None of above

Answer optiona

Marks: 2

749 Which method is used to set the dimensions of the window.

A. void setSize(Dimension newSize newHeight,int newWidth)

B. void setSize(int newHeight,int newWidth)

C. void setSize(new (Dimension newSize))

D. void setSize(int newWidth, int newHeight)

Answer optiond

Marks: 1

750 Identify wrong constructor of Checkbox

A. Checkbox(String str, boolean on)

B. Checkbox(String str, boolean on, CheckboxGroup cbGroup)

C. Checkbox(String str, CheckboxGroup cbGroup, boolean on)

D. None of Above

Answer optiond

Marks: 1

751 ________dialog box is active input is directed to it until it is closed.

A. Model

B. Modeless

C. Save

D. Open

Answer optiona

Marks: 1

752 _______________contols are platform dependant


A. Swing

B. AWT

C. MVC

D. All above

Answer optionb

Marks: 1

753 Combobox is a combination of ________________________

A. Swing and AWT

B. TextField and List

C. TextField and Dropdown List

D. None of Above

Answer optionc

Marks: 1

754 _________________generates an event and sends it to one or more listeners.

A. Event

B. Event Source

C. Event Listener

D. Event Class

Answer optionb

Marks: 1

755 The MouseEvent class does not defines the _____________integer constant.

A. MOUSE_CLICKED

B. MOUSE_WHEEL

C. MOUSE_WHEELMOVE

D. MOUSE_DRAGGED

Answer optionc

Marks: 1

756 Which is not a method of URL Connection?

A. int getContentLength( )

B. long getDate( )

C. String getHeaderFieldKey(int idx)

D. Date getLastModified( )

Answer optiond

Marks: 1

757 Which is connection less protocol

A. TCP

B. DHCP

C. TCP/IP

D. UDP

Answer optiond

Marks: 1
758 Which is not a type of JDBC driver

A. 100% pure java

B. JDBC-Net pure java

C. JDBC-Native API

D. JDBC-Native pure java

Answer optiond

Marks: 1

759 Application Server used in ____________________

A. Three-Tier Mode

B. Two-Tier Mode

C. Driver Interface

D. Driver Manager

Answer optiona

Marks: 1

760 Identify correct servlet interface

A. Servlet

B. GenericServlet

C. ServletInputStream

D. ServletOutputStream

Answer optiona

Marks: 1

761 ________________method execute at end of servlet life cycle.

A. dispose()

B. setVisible(false)

C. service()

D. destroy()

Answer optiond

Marks: 1

762 ________________method is secure.

A. doGet()

B. doPost()

C. Service()

D. None of Above

Answer optionb

Marks: 1

763 Picture is a ________________

A. CheckboxMenuItem

B. Popup Menu

C. Both

D. None of Above

Answer optiona
Marks: 2

764 Identify controls used in following output

A. TextField,Button

B. TextField and List

C. TextField and Slider

D. TextFiled and Scrollbars

Answer optiond

Marks: 2

765 Identify wrong method of KeyListener

A. keyPressed(KeyEvent ke)

B. keyReleased(KeyEvent ke)

C. keyTyped(KeyEvent ke)

D. keyDragged(KeyEvent ke)

Answer optiond

Marks: 2

766 ________________ is a mediator used in between Web Server and Client

A. Proxy

B. Host

C. Server

D. HTTP

Answer optiona

Marks: 2

767 URL string encompasses four parts in sequence

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

1. Host name or address


2.Network Protocol
B. 3.File or resource location
4.port

1.Port
2. Host name or address
C. 3.File or resource location
4. Network Protocol

1. Network Protocol
D. 2.File or resource location
3. Host name or address

Answer optiona

Marks: 2

768 Identify wrong type of ResultSet

A. ResultSet.TYPE_FORWARD_ONLY

B. ResultSet.TYPE_BACKWORD_ONLY

C. ResultSet.TYPE_SCROLL_INSENSITIVE

D. ResultSet.TYPE_SCROLL_SENSITIVE

Answer optionb

Marks: 2

769 Steps in JSP Page execution

A. 1. Compilation 2. Initialization 3. Execution 4. Cleanup


B. 1. Compilation 2. Execution 3. Initialization 4. Cleanup

C. 1. Initialization 2. Compilation 3. Execution 4. Cleanup

D. None of Above

Answer optiona

Marks: 2

770 Identify components used

A. GridLayout

B. JButton

C. JButton,ScrollPane

D. JButton,ScrollBars

Answer optionc

Marks: 2

Which Statement is required to obtain given output by using following code


public class fldemo extends Frame{
fldemo()
{
Button b1=new Button("Save");
Label l1=new Label("Name");
TextField t1=new TextField(10);
add(l1);
add(t1);
add(b1);
771 //Statement required here
setSize(new Dimension(500,500));
setTitle("FlowLayout");
setVisible(true);
}
public static void main(String arg[])
{
fldemo f=new fldemo();
}
}

A. setLayout(new FlowLayout());

B. setLayout(new BorderLayout());

C. setLayout(new GridLayout());

D. setLayout(new CardLayout());

Answer optiona

Marks: 2

Identify default output for given code


import java.awt.event.*;
import java.applet.*;
public class FlowLayoutDemo extends Applet
implements ItemListener {
String msg = "";
Checkbox Win98, winNT, solaris, mac;
public void init() {
setLayout(new FlowLayout(FlowLayout.LEFT));
Win98 = new Checkbox("Windows 98/XP", null, true);
winNT = new Checkbox("Windows NT/2000");
solaris = new Checkbox("Solaris", null, true);
mac = new Checkbox("MacOS");
add(Win98);
add(winNT);
add(solaris);
add(mac);
Win98.addItemListener(this);
winNT.addItemListener(this);
772 solaris.addItemListener(this);
mac.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie) {
repaint();
}
public void paint(Graphics g) {
msg = "Current state: ";
g.drawString(msg, 6, 80);
msg = " Windows 98/XP: " + Win98.getState();
g.drawString(msg, 6, 100);
msg = " Windows NT/2000: " + winNT.getState();
g.drawString(msg, 6, 120);
msg = " Solaris: " + solaris.getState();
g.drawString(msg, 6, 140);
msg = " Mac: " + mac.getState();
g.drawString(msg, 6, 160);
}
}
A. S1Q45O1

B. S1Q45O2

C. S1Q45O3

D. S1Q45O4

Answer optiond

Marks: 2

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 ArrayIndexOutofBound
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
773 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();
}
}

A. main()

B. add try and catch block

C. Connection String

D. ResultSet Type

Answer optionb

Marks: 2

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.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=# where Roll_no=#");
Statement s=c.createStatement( );
s.setString(1,args[0]);
774 s.setString(2,args[1]);
s.setString(3,args[2]);
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.getDouble(3));
}
s.close();
c.close();
}
}

A. use ? in PreparedStatement

B. use values in PreparedStatement

C. use :? in PreparedStatement

D. None of Above

Answer optiona

Marks: 2
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
{

Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
Statement s=c.createStatement( );
775 s.setString(1,args[0]);
s.setString(2,args[1]);
s.setString(3,args[2]);
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.getDouble(3));
}
s.close();
c.close();
}
}

A. Currect PreparedStatement

B. use values in PreparedStatement

C. Use statement Class.forName("sun.odbc.jdbc.OdbcJdbcDriver");

D. Use satement Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Answer optiond

Marks: 2

In following Java program fill statement showing ***.Select any one option fro given options

import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends *********
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
776 String data = request.getParameter("data");
Cookie cookie = new Cookie("MyCookie", data);
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. GenericServlet

B. HttpServlet

C. FtpServlet

D. HTMLServlet

Answer optionb

Marks: 2

In following Java program fill statement showing @@@@@@@@@@@@@@@@.Select any one option fro given options

import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
777 String data = request.getParameter("@@@@@@@@@@@@@@@@");
Cookie cookie = new Cookie("MyCookie", data);
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. value

B. name

C. new data
D. data

Answer optiond

Marks: 2

778 Identify method used by following url http://localhost:8080/examples/servlet/test.html?uid=xyz?pass=vvpp?

A. get()

B. post()

C. service()

D. None of Above

Answer optiona

Marks: 2

Choose missing statements in following code from given options.

public class session1 extends HttpServlet


{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
HttpSession hs = request.getSession(true);

779 PrintWriter pw = response.getWriter();


pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. main()

B. service()

C. implements HTML

D. response.setContentType("text/html");

Answer optiond

Marks: 2

780 Which of the method can be used to output a string in an applet?

A. display()

B. print()

C. drawString()

D. transient()

Answer optionc

Marks: 1

781 what layout manager should you use so that every component occupies the same size in the container?

A. FlowLayout

B. GridLayout

C. BorderLayout

D. any Layout

Answer optionb

Marks: 1

782 Which of these event is generated when computer gains or loses input focus?

A. ComponentEvent

B. ContainerEvent
C. FocusEvent

D. InputEvent

Answer optionc

Marks: 1

783 Which of the following method use to get the text or caption of the button jbt?

A. jbt.text()

B. jbt.getText()

C. jbt.findText()

D. jbt.retrieveText()

Answer optionb

Marks: 2

784 Which of the following method use to check whether the JCheckBox jchk is selected?

A. jchk.getSelected()

B. jchk.selected()

C. jchk.isSelected()

D. jchk.select()

Answer optionc

Marks: 2

785 The __________object provides you with methods to access data from the table.

A. ResultSet

B. Parameterized

C. TableStatement

D. Condition

Answer optiona

Marks: 2

786 The parameters of the PreparedStatement object are _____when the user clicks on the Query button

A. initialized

B. stated

C. paused

D. stopped

Answer optiona

Marks: 2

787 In JSP,the classes that allow primitive types to be accessed as objects are known as

A. Boxing classes

B. Wrapped classes

C. Object classes

D. UnBoxing classes

Answer optionb

Marks: 2

788 MVC Architecture is

A. Modelling-Visual-Control
B. Model-View-Controller

C. Mode-Viewable-Control

D. Many-View-control

Answer optionb

Marks: 1

789 Border Layout is divided into_________regions

A. two

B. three

C. four

D. five

Answer optiond

Marks: 1

790 The default layout manager for the content pane of a swing based applet is

A. Flow-Layout

B. Border-Layout

C. Gridbag-Layout

D. Grid-Layout

Answer optionb

Marks: 1

791 You can obtain the server's hostname by invoking __________________on an applet.

A. getCodeBase().host()

B. getCodeBase().getHost()

C. getCodeBase().hostName()

D. getCodeBase().getHostName()

Answer optionb

Marks: 1

792 Which Interface is used to execute dynamic SQL statements?

A. Resultset

B. PreparedStatement

C. Statement

D. ResultSetMetaData

Answer optionb

Marks: 1

793 In JSP a Canvas object provides access to a Graphics object via one of its method called____________

A. getCanvas()

B. paint()

C. getPaint()

D. getGraphics()

Answer optionb

Marks: 1

794 ______moves the cursor to the specified row


A. public boolean absolute(int row)

B. public boolean relative(int row)

C. public boolean getRow(int row)

D. public void currentRow()

Answer optiona

Marks: 1

795 _____________________ is the default layout manager for APPLET.

A. GridLayout

B. BorderLayout

C. FlowLayout

D. CardLayout

Answer optionc

Marks: 1

796 When a component obtains keyboard focus, which method is invoked?

A. void focusGained(FocusEvent fe)

B. void focusLost(FocusEvent fe)

C. void keyPressed(KeyEvent ke)

D. The MouseMotionListener Interface

Answer optiona

Marks: 1

797 A ________________________ is generated when a component is added to or removed from a container.

A. Component Event class

B. ContainerEvent

C. Action Event class

D. Focus Event class

Answer optionb

Marks: 1

798 Which type of driver provides JDBC access one or more ODBC drivers?

A. Type 1 driver

B. Type 2 driver

C. Type 3 driver

D. Type 4 driver

Answer optiona

Marks: 1

799 What method is used to specify a container's layout in JSP?

A. setContainerLayout()

B. setLayout()

C. setConLayout()

D. layout()

Answer optionb

Marks: 1
800 Which method is used to specify before any lines that use the PrintWriter?

A. setPageType()

B. setContextType()

C. setContentType()

D. setResponseType()

Answer optionc

Marks: 1

Point out missing word in syntax in given code

import java.awt.*;
import java.awt.event.*;
public class demo extends Frame
{
public static void main(String args[])
{
Button b;
GridLayout cr= GridLayout(3,4,5,10);
Frame f=new Frame("GRIDLAYOUT EXAMPLE");
801 f.setLayout(cr);
f.add(new Button("1"));
f.add(new Button("2"));
f.add(new Button("3"));
f.add(new Button("4"));
f.add(new Button("5"));
f.add(new Button("7"));
f.setSize(300,400);
f.setVisible(true);
}
}

A. FlowLayout

B. new

C. {

D. Both

Answer optionb

Marks: 2

802 Which method Returns the output stream of the URL connection ?

A. getInputStream()

B. getOutputStream()

C. getInPutStream()

D. getOutPutStream()

Answer optionb

Marks: 2

803 URLConnection object is retrived using following method?

A. openConnection()

B. getConnection()

C. OnConnection()

D. All of Above

Answer optiona

Marks: 2

804 Microsoft Access data in a _________________file format.

A. .dat

B. .mdb

C. .mssql

D. .obj

Answer optionb
Marks: 2

//Select the correct option for the following code.


import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*<applet code=scrolldemo width=200 height=300>


</applet>*/

public class scrolldemo extends Applet implements AdjustmentListener


{
Scrollbar s1,s2,s3;
TextField r,g,b;
Color c;

public void init()


{
s1=new Scrollbar(Scrollbar.HORIZONTAL,0,0,0,256);
s2=new Scrollbar(Scrollbar.HORIZONTAL,0,0,0,256);
s3=new Scrollbar(Scrollbar.HORIZONTAL,0,0,0,256);
r=new TextField(5);
g=new TextField(5);
b=new TextField(5);
805
add(s1);
add(r);
add(s2);
add(g);
add(s3);
add(b);

s1.addAdjustmentListener(this);
s2.addAdjustmentListener(this);
s3.addAdjustmentListener(this);
}

public void adjustmentValueChanged(AdjustmentEvent ae)


{
r.setText(Integer.toString(s1.getValue()));
g.setText(Integer.toString(s2.getValue()));
b.setText(Integer.toString(s3.getValue()));

c=new Color(s1.getValue(),s2.getValue(),s3.getValue());
setBackground(c);
}
}

A. background with value of textfield in r only.

B. background with value of textfield in g only.

C. background with value of textfield in b only.

D. background with combination of r,g and b.

Answer optiond

Marks: 2
For the following code select the method that can be used to handle event.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*<applet code=exp.java width=400 height=400>


</applet>*/

public class exp extends Applet implements ItemListener


{
Choice c;
TextField t1,t2,t3;
Label l1,l2,l3;

public void init()


{
t1=new TextField(10);
t2=new TextField(10);
t3=new TextField(10);
l1=new Label("Enter num");
l2=new Label("Second num");
l3=new Label("Result");
c=new Choice();
c.add("addition");
c.add("subtraction");
add(l1);
add(t1);
add(l2);
806 add(t2);
add(l3);
add(t3);
add(c);
c.addItemListener(this);

}
public void __________(ItemEvent e)
{

String s=c.getSelectedItem();
if(s.equals("addition"))
{
int n1=Integer.parseInt(t1.getText());
int n2=Integer.parseInt(t2.getText());
int n3=n1+n2;
t3.setText(Integer.toString(n3));
}
if(s.equals("subtraction"))
{
int n1=Integer.parseInt(t1.getText());
int n2=Integer.parseInt(t2.getText());
int n3=n1-n2;
t3.setText(Integer.toString(n3));
}

}
}

A. itemChanged

B. actionPerformed

C. itemStateChanged

D. None of the Above

Answer optionc

Marks: 2
Select the proper command to run the following code
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class fact extends Frame implements ActionListener


{
TextField t1,t2;
Label l1,l2;
Button b1;
fact(String title)
{
super(title);
t1=new TextField(20);
t2=new TextField(20);
l1=new Label("ENTER NO");
l2=new Label("output");
b1=new Button("find factorial");
setLayout(new GridLayout(3,2));
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
b1.addActionListener(this);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
807 System.exit(0);
}
});

public static void main(String args[])


{
fact f=new fact("factorial example");
f.setVisible(true);
f.setSize(300,300);
}
public void actionPerformed(ActionEvent ae)
{
String s;
int n;
int fact=1;
String s1=ae.getActionCommand();
if(s1.equals("find factorial"))
{
s=t1.getText();
n=Integer.parseInt(s);
for(int i=1;i<=n;i++)
{
fact=fact*i;
s=""+fact;
t2.setText(s);
}
}
}
}

A. appletviewer fact.java

B. javac fact.java

C. java fact.java

D. java fact

Answer optiond

Marks: 2

Consider the following program. What should be the correction done in the program to get colored button output?.
import java.awt.*;
import java.applet.*;
public class colordemo extends Applet
{
Button b1;
Color c;
public void init()
{
808 c=new Color(255,0,0);
setBackground(c);
Button b1=new Button("Click");
b.setBackground(Color.yellow);
setForeground(Color.green);
add(b1);
}
}
/*<applet code="colordemo" height=150 width=150>
</applet>*/

A. b.setBackground(Color.yellow);

B. setBackground(Color.yellow);

C. b1.setBackground(Color.yellow);

D. b1.setBackGround(Color.yellow);

Answer optionc
Marks: 2

Consider the following program. What should be the correction done in the program to see output?.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class authenticateuser extends Applet implements ActionListener
{
Label lblname,lblpswd,lblmsg;
TextField txtname,txtpswd;
Button b1;
String msg="";
public void init()
{
lblname= new Label("Enter username:");
lblpswd= new Label("Enter pswd:");
lblmsg= new Label("");
txtname= new TextField(8);
txtpswd= new TextField(8);
b1=new Button("Submit");
809 setLayout(new GridLayout(3,2));
add(lblname);
add(txtname);
add(lblpswd);
add(b1);
add(lblmsg);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (txtpswd.getText().equals("1234"))
lblmsg.setText("Hello "+txtname.getText() );
else
lblmsg.setText("Invalid user");
}
}
/*<applet code = authenticateuser height=200 width=200>
</applet>*/

A. add(lblmsg);

B. Missing {

C. add(txtpswd);

D. Some other statement is Missing.

Answer optionc

Marks: 2

810 Which event is generated when the position of scrollbar is changed.Select the correct answer.

A. KeyEvent

B. MouseEvent

C. ItemEvent

D. AdjustmentEvent

Answer optiond

Marks: 2

Consider the following program. What should be the correction done in the program to get correct output?.
import java.sql.*;
public class createdemo
{
public static void main(String args[])throws Exception
{
try
{
Connection con;
Statement st;
ResultSet rs;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
st=con.createStatement();
rs=st.executeQuery("select * from studata");
System.out.println("Name"+"\t"+"RollNo"+"\t");
while(rs.next())
811
{
System.out.print(rs.getString("name")+"\t"+rs.getInt("rollno")+"\t");
System.out.println();
}
st.close();
rs.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}

}
}

A. IOException

B. Connection Statement missing


C. Missing }

D. Missing package

Answer optionb

Marks: 2

Consider the following program. What should be the correction done in the program to get correct output?.
import java.sql.*;
public class isert
{
public static void main(String args[])throws Exception
{
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:dsn10");
String r1=("insert into stt(name,rollno,city)values('RAJ',12,'THANE')");

Statement st=con.createStatement();
st.executeUpdate(r1);
st.execute("select * from stt");
812 ResultSet rs= st.getResultSet();
System.out.println("Name"+"\t"+"RollNo"+"\t"+"City");
while(st.next())
{
System.out.print(rs.getString("name")+"\t"+rs.getInt("rollno")+"\t"+rs.getString("city"));
System.out.println();
}
st.close();
rs.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}

}
}

A. con.next()

B. rs.next()

C. st.next()

D. none of the Above.

Answer optionb

Marks: 2

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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
813 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();
}
}

A. import java.io.*;

B. import java.net.*;

C. import java.sql.*;

D. All of Above

Answer optionc

Marks: 2
For the following code select the missing statement that can be used .
import java.io.*;
import java.net.*;
import javax.servlet.*;

public class Exp extends GenericServlet{


public void service(ServletRequest request, ServletResponse response)
814 throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<b>Values u entered are:</b>");


out.println("Hello "+name+"<br>");
out.close();
}
}

A. String name=request.getParameter("name");

B. response.setContenttype("text/html");

C. String name=request.getparameter("name");

D. None of the Above

Answer optiona

Marks: 2

Consider the following program. Identify the missing statement in the program.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Exp extends HttpServlet
{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
815 PrintWriter out = ___________________

out.println("the server name: "+request.getServerName()+"<br>");


out.println("the server port: "+request.getServerPort()+"<br>");
out.println("the server protocol: "+request.getProtocol()+"<br>");
out.println("the server scheme: "+request.getScheme()+"<br>");
out.close();
}
}

A. response.putWriter()

B. response.printwriter()

C. response.getWriter();

D. request.getWriter();

Answer optionc

Marks: 2

816 The ___________ interface is used to handle button events:

A. ContainerListener

B. ItemListener

C. ActionListener

D. WindowListener

Answer optionc

Marks: 1

817 Name the event that gets generated when a button is clicked.

A. KeyEvent

B. MouseEvent

C. ItemEvent

D. ActionEvent

Answer optiond

Marks: 1

818 What letter precedes Swing component names that have a corresponding AWT component?
A. A

B. S

C. C

D. J

Answer optiond

Marks: 1

819 What is the use of setEchoChar() method?

A. to set echo in symbol form

B. to set char in symbol form

C. Both a & b

D. to create password in symbol form

Answer optiond

Marks: 2

820 From following list Which is not Swing class?

A. JLabel

B. JButton

C. JImageIcon

D. JCheckBox

Answer optionc

Marks: 2

821 From given list which is not Listener Interface?

A. ActionListener

B. AdjustmentListener

C. ComponentListener

D. MousepressedListener

Answer optiond

Marks: 2

822 From given list which is not method of Mouse Listener?

A. mouseClicked()

B. mousePressed()

C. mouseDragged()

D. mouseEntered()

Answer optionc

Marks: 2

823 ServerSocket has a method called __________, which is a blocking call that will wait for a client to initiate communications,

A. wait()

B. accept()

C. waitclient()

D. None of the above

Answer optionb

Marks: 2
1.Which is missing statement in following program?
import java.awt.*;
import java.applet.*;
import java.util.*;
/*
<applet code="BorderLayoutDemo" width=400 height=200>
</applet>
*/
public class BorderLayoutDemo extends Applet
824 {
public void init() {
add(new Button("north."),BorderLayout.NORTH);
add(new Button("south"),BorderLayout.SOUTH);
add(new Button("Right"), BorderLayout.EAST);
add(new Button("Left"), BorderLayout.WEST);
String msg = "this is in center";
add(new TextArea(msg), BorderLayout.CENTER);
}
}

A. SetLayout(new BorderLayout())

B. setLayout(new BorderLayout()

C. setLayout(new Borderlayout())

D. setLayout(new borderLayout())

Answer optionb

Marks: 2

2.What should be written in blank space.


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="CBGroup" width=250 height=200>
</applet>
*/
public class CBGroup extends Applet
{
String msg = "";
Checkbox Win98, winNT;
825 CheckboxGroup cbg;
public void init()
{
cbg = new CheckboxGroup();
Win98 = new Checkbox("Windows 98/XP", , true);
winNT = new Checkbox("Windows NT/2000", , false);
add(Win98);
add(winNT);
Win98.addItemListener(this);
winNT.addItemListener(this);
}
}

A. Win98

B. winNT

C. cbg

D. this

Answer optionc

Marks: 2

Which statement should be added to display button.


import java.awt.*;
import javax.swing.*;
/*
<applet code="JButtonDemo" width=250 height=300>
</applet>
*/

public class JButtonDemo extends JApplet


826 {
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());

ImageIcon img= new ImageIcon("jpgIcon.jpg");


JButton jb = new JButton(img);
}
}

A. ContentPane.add(jb);

B. contentPane.add(jb);

C. contentPane.add();

D. contentPane.addButton(jb);

Answer optionb
Marks: 2

Select correct Adapter class from given option for ******.


import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code="adapterdemo" width=300 height=100>
</applet>
*/
public class adapterdemo extends Applet
{
public void init()
827 {
addMouseListener(new A());
}

class A extends *********


{
public void mousePressed(MouseEvent me)
{
showStatus("Mouse Pressed ");
}
}
}

A. MouseMotionAdapter

B. MouseAdapter

C. KeyListener

D. All

Answer optionb

Marks: 2

Which method is missing in following program.


import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code="MouseEventsapp" width=300 height=100>
</applet>
*/
public class MouseEventsapp extends Applet implements MouseMotionListener
{
String msg = "";
int mouseX = 0, mouseY = 0;

public void init()


{
828 addMouseMotionListener(this);
}

public void mouseDragged(MouseEvent me)


{
mouseX = me.getX();
mouseY = me.getY();
msg = "*";
showStatus("Dragging mouse at " + mouseX + ", " + mouseY);
repaint();
}

public void paint(Graphics g)


{
g.drawString(msg, mouseX, mouseY);
}
}

A. mouseClicked()

B. mouseMoved()

C. mousePressed()

D. mouseEntered()

Answer optionb

Marks: 2
Which method is missing in following program.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="MouseEventsapp" width=300 height=100>
</applet>
*/
public class MouseEventsapp extends Applet implements MouseListener
{
String msg = "";
int mouseX = 0, mouseY = 0; // coordinates of mouse

public void init()


{
addMouseListener(this);
}

public void mouseClicked(MouseEvent me)


{
mouseX = 0;
mouseY = 10;
msg = "Mouse clicked.";
repaint();
}

public void mouseEntered(MouseEvent me)


829 {
mouseX = 0;
mouseY = 10;
msg = "Mouse entered.";
repaint();
}

public void mouseExited(MouseEvent me)


{
// save coordinates
mouseX = 0;
mouseY = 10;
msg = "Mouse exited.";
repaint();
}

public void mousePressed(MouseEvent me)


{
msg = "Down";
repaint();
}

public void paint(Graphics g)


{
g.drawString(msg, mouseX, mouseY);
}
}

A. mouseReleased()

B. mouseDragged()

C. mouseMoved()

D. mousedragged()

Answer optiona

Marks: 2

Find error in following program.


import java.awt.*;
import java.applet.*;

/*<applet code="choicedemo" width=300 height=180>


</applet>
*/

public class ChoiceDemo extends Applet implements ItemListener


{
Choice os;
String msg = "";

public void init()


{
os = new Choice();

os.add("Windows 98/XP");
830 os.add("Windows NT/2000");
add(os);
add(browser);

// register to receive item events


os.addItemListener(this);
}

public void itemStateChanged(ItemEvent ie)


{
repaint();
}
public void paint(Graphics g)
{
msg = "Current OS: ";
msg += os.getSelectedItem();
g.drawString(msg, 6, 120);
}
}

A. package is missing
B. Error in html code

C. both A and B

D. none of the above

Answer optionc

Marks: 2

Find Error in following program.


import java.awt.*;

class URLDemo
{
public static void main(String args[]) throws urlexception
831 {
URL hp = new URL("http://www.Abc.com/downloads");
System.out.println("Protocol: " + hp.getProtocol());
System.out.println("Port: " + hp.getPort());
System.out.println("Host: " + hp.getHost());
}
}

A. Error in package

B. Error in Exception

C. both a and b

D. none of the above

Answer optionc

Marks: 2

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);
832 InputStream is=s1.getInputStream();

BufferedReader br=new BufferedReader(new InputStreamReader(is));


System.out.println(br.readLine());
br.close();
s1.close();
}
catch(Exception e)
{}
}
}

A. localhost address

B. port number

C. ip address

D. server address

Answer optionb

Marks: 2

What is x in following program:

import java.sql.*;
public class Selectdbase
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:x");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from emp");
while(rs.next())
833 {
System.out.println("id:"+rs.getInt("id"));
System.out.println("salary:"+rs.getString("salary"));
System.out.println("name:"+rs.getString("name1"));
}
con.close();
}
catch(SQLException e)
{}
catch(Exception e)
{
}
}
}
A. Driver name

B. database name

C. table name

D. data source name

Answer optionb

Marks: 2

Which is the correct method for updating table rows from given option.

import java.sql.*;
public class Updatedbase
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:data");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from emp");

St.********("Update emp set name1='jack' where id=2");


834 System.out.println("\n\nafter change");
rs=st.executeQuery("select * from emp");
while(rs.next())
{
System.out.println("id:"+rs.getInt("id"));
System.out.println("salary:"+rs.getString("salary"));
}
con.close();
}
catch(SQLException e){}
catch(Exception e)
{
}
}
}

A. executeUpdate()

B. executeQuery()

C. execute()

D. ExecuteUpdate()

Answer optiona

Marks: 2

1. Choose correct package ********* for following code from given options.
import java.io.*;
import javax.servlet.*;
public class HelloServlet extends ******* {
public void service(ServletRequest request,
ServletResponse response)
throws ServletException, IOException
835 {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

A. GenericServlet

B. genericServlet

C. HttpServlet

D. httpServlet

Answer optiona

Marks: 2
Consider the following program and identify the missing method attribute value ***** if you want to implement HTTP POST.

<html>
<body>
<center>
<form name="Form1"
method=*****
action="http://localhost:8080/examples/servlet/ColorPostServlet">
<B>Color:</B>
<select name="color" size="1">
836 <option value="Red">Red</option>
<option value="Green">Green</option>FTWARE DEVELOPMENT
USING JAVA
<option value="Blue">Blue</option>
</select>
<br><br>
<input type=submit value="Submit">
</form>
</body>
</html>

A. HTTP POST

B. HTTP GET

C. post

D. get

Answer optionc

Marks: 2

Consider the following program and identify the missing method name ****** if you want to implement HTTP POST.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ColorGetServlet extends HttpServlet {
public void ******(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
837 String color = request.getParameter("color");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>The selected color is: ");
pw.println(color);
pw.close();
}
}

A. doGet()

B. doPost()

C. HTTP GET()

D. HTTP POST()

Answer optionb

Marks: 2

838 Positions the componenets into five regions:east,west,north,south,center

A. CardLayout

B. BorderLayout

C. GridLayout

D. FlowLayout

Answer optionb

Marks: 1

839 The TextArea controls create a ________ respectively.

A. Single-line text

B. Multi-line text

C. Both a and b

D. None of these

Answer optionb

Marks: 1

840 Generated when a window is activated, de-activated, closed, de-activated,de-iconified, iconified, opened or quit
A. WindowEvent

B. ComponentEvent

C. ContainerEvent

D. InputEvent

Answer optiona

Marks: 1

841 EventObject contains two important methods:________ and___________

A. addTypeListener() and removeTypeListener()

B. getSource() and toString()

C. EventObject() and getID()

D. all of these

Answer optionb

Marks: 1

842 KeyEvent is a subclass of ________

A. MouseEvent

B. MouseMotionEvent

C. MouseClickEvent

D. InputEvent

Answer optiond

Marks: 1

843 The openConnection() is the method of which Class?

A. URL

B. URLConnection

C. Connection

D. InetAddress

Answer optionb

Marks: 1

The _____ package contains classes that help in connecting to a database, sending SQL statements to the database and processing the
844 query results.

A. connection.sql.*

B. db.sql.*

C. pkg.sql.*

D. java.sql.*

Answer optiond

Marks: 1

845 boolean isLast() method of ResultSet ____________ .

A. shifts the control of a ResultSet cursor to the last row of the ResultSet

B. determines whether the ResultSet cursor points to the last row of the ResultSet.

C. shifts the controls of a ResultSet cursor after the last row of the ResultSet

D. all of these

Answer optionb

Marks: 1
846 ____________ is used to read data from a client request.

A. ServletResponse

B. Servlet

C. ServletRequest

D. ServletConfig

Answer optionc

Marks: 1

847 Which method does not exist on HttpServlet class?

A. service()

B. init()

C. doGet()

D. doPost()

Answer optionb

Marks: 1

848 GenericServlet implements the _______ and _______.

A. Servlet, ServletConfig

B. ServletRequest, HttpServlet

C. HttServletRequest, Servlet

D. HttpResponse, Srvlet

Answer optiona

Marks: 1

849 Which components provide support for two-state buttons?

A. Button, Checkbox

B. JCheckBox, JRadioButton

C. Button, MenuItem

D. JCheckBox, TextField

Answer optionb

Marks: 2

850 __________ is a widget that displays progress of a lengthy task, for instance file download or transfer.

A. Scrollbar

B. ProgressBar

C. Menubar

D. Panel

Answer optionb

Marks: 2

851 Which component is display area for a short string of text, image or both?

A. Jtree

B. JTextField

C. Jlabel

D. JTextArea

Answer optionc
Marks: 2

852 Which option is correct to adding Jtree in an Applet?

A. Create a Jtree Object, Create a JScrollPane object, Add the tree to the scrollpane and Add the scroll pane to the content pane of the applet.

B. Create a Jtree object, Create a JScrollPane object, and Add the scrollpane to the content pane of the applet.

C. Create a JTree object,Add the tree to the scroll pane and Add the scroll pane to the content pane of the applet.

D. Create a Jscrollpane object, Add the tree the scrollpane and Add the scroll pane to the content pane of the applet.

Answer optiona

Marks: 2

If we create the datagram packet with following constructor:


853 DatagramPacket(byte data[],int offset, int size, InetAddress ipaddress, int port)
What "size" parameter specifies?

A. size of the packet

B. Maximum data to read

C. Minimum data to read

D. size of offset

Answer optiona

Marks: 2

854 What the index.html specifies in following URL? Http://www/rediff.com:80/index.html

A. port number

B. site number

C. Folder name/directory name

D. File name

Answer optiond

Marks: 2

855 Which of the following statement is false as Type 4 driver is concern:

A. Type 4 driver is " native protocol, pure java" driver

B. Type 4 driver are 100% java compatible.

C. Type 4 drivers uses Socket class to connect to the database

D. Type 4 drivers can not be used with NetScape.

Answer optiond

Marks: 2

856 Which method returns a servletConfig object that contains any initialization parameters?

A. servletConfig getServletConfig()

B. ServiceConfig getServlet()

C. ServiceConfig getServletConfig()

D. ServiceConfig getConfig()

Answer optiona

Marks: 2

857 identify the correct signature of setContextLenght() method of ServletResponse interface.

A. String setContextLength(int size)

B. void setContextLength(String type)

C. void setContextLength(int size)

D. void setContextLength()
Answer optionc

Marks: 2

858 Which of the following method is not supported by ServletRequest Interface?

A. String getAttributes(String str)

B. int getContentLength()

C. void setContextLength(int size)

D. String getParameter(String pname)

Answer optionc

Marks: 2

859 What will be the correct code for following output?

import java.awt.*;
import java.awt.event.*;
class ChoiceAction extends Frame
{
Choice c;
Label l;
public ChoiceAction()
{

// Set frame properties


setTitle("Choice with ItemListener Demo");
setSize(400,400);
setLayout(new FlowLayout());
setLocationRelativeTo(null);
setVisible(true);

// Create choice
c=new Choice();

// Create label
l=new Label();

// Add items
c.add("Window98");
A. c.add("Window NT");
c.add("Solari");
c.add("Maco");

// Add choice
add(c);

// Add label
add(l);

// Add item listener


c.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent ie)
{
l.setText("You selected "+c.getSelectedItem());
}
});

}
public static void main(String args[])
{
new ChoiceAction();
}
}
import java.awt.*;
import java.awt.event.*;
class ChoiceAction extends Frame
{
Choice c;
Label l;
public ChoiceAction()
{

// Set frame properties


setTitle("Choice with ItemListener Demo");
setSize(400,400);
setLayout(new FlowLayout());
setLocationRelativeTo(null);
setVisible(true);

// Create choice
c=new Choice();

// Create label
l=new Label();

B. // Add items
c.add("Window98");
c.add("Window NT");
c.add("Solari");
c.add("Maco");

// Add choice
add(c);

// Add label
add(l);

// A
}
});

}
public static void main(String args[])
{
new ChoiceAction();
}
}

import java.awt.*;
import java.awt.event.*;
class ChoiceAction extends Frame
{
Choice c;
Label l;
public ChoiceAction()
{

// Set frame properties


setTitle("Choice with ItemListener Demo");
setSize(400,400);
setLayout(new FlowLayout());
setLocationRelativeTo(null);
setVisible(true);

// Create choice
c=new Choice();

// Create label
l=new Label();
C.
// Add items
c.add("Window98");
c.add("Window NT");
c.add("Solari");
c.add("Maco");

// Add choice
add(c);

// Add label
add(l);

// Add item listener


c.addItemListener(new ItemListener(){

public static void main(String args[])


{
new ChoiceAction();
}
}
mport java.awt.*;
import java.awt.event.*;
class ChoiceAction extends Frame
{
Choice c;
Label l;
public ChoiceAction()
{

// Set frame properties


setTitle("Choice with ItemListener Demo");
setSize(400,400);
setLayout(new FlowLayout());
T");
c.add("Solari");
c.add("Maco");

// Add choice
add(c);
D.
// Add label
add(l);

// Add item listener


c.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent ie)
{
l.setText("You selected "+c.getSelectedItem());
}
});

}
public static void main(String args[])
{
new ChoiceAction();
}
}

Answer optiona

Marks: 2

Consider the following program. Find the error.


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=demo width=100 height=100>
</applet> */
public class demo extends Applet
{
public void init()
860 {
firstlabel =new Label("Label 1");
secondlabel =new Label("Label 2");
b1=new Button("Enter");
add(l1);
add(l2);
add(b1);
}
}

A. Firstlabel object is not declared

B. � � � Secondlabel object is not declared

C. b1 object is not declared

D. All of above

Answer optiond

Marks: 2

For the following code select correct statements to complete the code.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=demo width=100 height=100>
</applet> */
public class demo extends Applet implements ____________
{
Label l1,l2;
Button b1;
String msg="";
public void init()
{
l1=new Label("Label 1");
l2=new Label("Label 2");
b1=new Button("Enter");
861
add(l1);
add(l2);
add(b1);
b1.addActionListener(this);
}
public void ____________________________
{
msg="U Have Pressed Enter Button";
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,100,100);
}
}
A. AdjustmentEvent, adjustmentValueChanged(AdjustmentEvent ae)

B. ItemEvent, itemStateChanged(ItemEvent ie)

C. ActionListener , actionPerformed(ActionEvent ae)

D. none of these

Answer optionc

Marks: 2

What will be the output of following code?


import java.applet.*;
import java.awt.event.*;
/* <applet code="InnerClassDemo" width=200 height=100>
</applet> */
public class InnerClassDemo extends Applet
{
public void init()
{
862 addMouseListener(new MyMouseAdapter());
}
class MyMouseAdapter extends MouseAdapter
{
public void mousePressed(MouseEvent me)
{
showStatus("Mouse Pressed");
}
}
}

A. S15001

B. S15002

C. S15003

D. S15004

Answer optiond

Marks: 2

Consider the following database:


ID name Salary
1 ramesh 1200
2 ganesh 1111
6 sanjay 9500

What will be the correct output for following code:

import java.sql.*;
class SelectDemo
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String url="jdbc:odbc:mydsn";
Connection con=DriverManager.getConnection(url);
System.out.println(" Connection to DataBase created");
Statement stmt=con.createStatement();
String query="select * from emp";
863 ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{
System.out.println(" ID : "+ rs.getInt(1));
System.out.println(" name : "+ rs.getString(2));
System.out.println(" Salary : "+ rs.getInt(3));
System.out.println();
}

}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}

catch(SQLException e)
{
e.printStackTrace();
}

}
}

Driver Loaded
Connection to DataBase created
ID : 1
name : ramesh
Salary : 1200

A. ID : 2
name : ganesh
Salary : 1111

ID : 6
name : Sanjay
Salary : 9500
Driver Loaded
Connection to DataBase created
ID : 5
name : ramesh
Salary : 1200

B. ID : 4
name : ganesh
Salary : 1111

ID : 3
name : Sanjay
Salary : 9500

Driver Loaded
Connection to DataBase created
ID : 1
name : ramesh
Salary : 1200

C. ID : 2
name : ganesh
Salary : 1111

ID : 3
name : Sanjay
Salary : 9500

Driver Loaded
Connection to DataBase created
ID : 1
name : ramesh
Salary : 1200

D. ID : 2
name : sanjay
Salary : 1111

ID : 6
name : ganesh
Salary : 1111

Answer optiona

Marks: 2

Which class will use to create the ps object in the given code?
import java.sql.*;
public class create
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String url="jdbc:odbc:mydsn";
Connection con=DriverManager.getConnection(url);
864 System.out.println(" Connection to DataBase created");
Statement stmt=con.createStatement();
String query = "create table employee1(emp_id int,emp_name char)";
_________________ ps = con.prepareStatement(query);
ps.executeUpdate()
System.out.println("table created");
ps.close();
con.close();
}
catch(SQLException e) { e.printStackTrace(); }
catch(Exception e) { e.printStackTrace(); }
}
}

A. � � � � � Statement

B. � � � � � PreparedStatement

C. � � Connection

D. � Class

Answer optionb

Marks: 2
What will be the output for following code?
import java.sql.*;
class SelectD
{
public static void main(String a[])
{
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String url="jdbc:odbc:if";
Connection con=DriverManager.getConnection(url);
System.out.println(" Connection to DataBase created");
Statement stmt =con.createStatement();
String query ="select * from student where stud_marks>70";
ResultSet rs =stmt.executeQuery(query);
865
while(rs.next())
{
System.out.println(" Roll number : "+ rs.getInt(1));
System.out.println(" Student name : "+ rs.getString(2));
System.out.println(" Percentage : "+ rs.getInt(3));
System.out.println();

}
}
catch(ClassNotFoundException e)
{ e.printStackTrace(); }

catch(SQLException e)
{ e.printStackTrace(); }

} }

A. Display student’ roll number, student name and percentage.

B. Display student’ roll number, student name and percentage those having percentage greater than 70.

C. Display student’ roll number, student name and percentage those having percentage greater than and equal to 70.

D. Display student’ roll number, student name and percentage those having percentage less than 70.

Answer optionb

Marks: 2

Which statement is correct after firing delete statement of SQL?


import java.sql.*;
class DeleteD
{
public static void main(String a[])
{
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String url="jdbc:odbc:if";
Connection con=DriverManager.getConnection(url);
System.out.println(" Connection to DataBase created");
Statement stmt = con.createStatement();
String querySel = "Select * from student";
ResultSet rs = stmt.executeQuery(querySel);
System.out.println("Before Delete");
while(rs.next())
{
System.out.println(" Roll number : "+ rs.getInt(1));
System.out.println(" Student Name : "+ rs.getString(2));
System.out.println(" Student Marks : "+ rs.getInt(3));
System.out.println();
866
}
String querydel = "delete from student where stud_name='Sanjay'";
__________________________________________
rs = stmt.executeQuery(querySel);
System.out.println("After Delete");
while(rs.next())
{
System.out.println(" Roll no : "+ rs.getInt(1));
System.out.println(" Student Name : "+ rs.getString(2));
System.out.println(" Student marks : "+ rs.getInt(3));
System.out.println();
}
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}

}
}

A. stmt.executeUPDATE(querydel);

B. stmt.ExecuteUpDate(querydel);

C. stmt.Executeupdate(querydel);

D. stmt.executeUpdate(querydel);
Answer optiond

Marks: 2

In following Java program fill statement showing ******.Select any one option from given options.
import java.io.*;
import java.util.*;
import javax.servlet.*;

public class PostParametersServlet extends GenericServlet {


public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {

PrintWriter pw = response.getWriter();

867 Enumeration e = ******;


// Display parameter names and values.
while(e.hasMoreElements()) {
String pname = (String)e.nextElement();
pw.print(pname + " = ");
String pvalue = request.getParameter(pname);
pw.println(pvalue);
}
pw.close();
}
}

A. � � � request.getParameterNames();

B. � � � � request.getparameterNames();

C. � Request.getParameterNames();

D. � � request.getParameterName();

Answer optiona

Marks: 2

868 Which of these following is not a component of swing

A. Jbutton

B. List

C. Jlabel

D. JTextField

Answer optionb

Marks: 1

869 To create file dialog box ______________ class is used

A. ComboBox

B. FileDialog

C. DialogBox

D. Dialog

Answer optionb

Marks: 1

870 Change in the state of an object is known as __________

A. Applet

B. Event

C. Swing

D. State

Answer optionb

Marks: 1

871 What is event handling?

A. Controling Event

B. Blocking Event
C. Using Control

D. Setting Event

Answer optiona

Marks: 1

872 IP Stands for ________

A. Internet Principle

B. Internet Protocol

C. Internet Provider

D. Internet Proof

Answer optionb

Marks: 1

873 TCP Stands for ________

A. Transmission Control Protocol

B. Transport Control Protocol

C. Transmission Certified Protocol

D. Transfer Internet Protocol

Answer optiona

Marks: 1

874 UDP Stands for ________

A. User Data Port

B. User Datagram Protocol

C. User Data Provider

D. User Data Protocol

Answer optionb

Marks: 1

875 Which driver is needed to connect to Microsoft database?

A. JDBC-ODBC Bridge Driver

B. Native API Driver

C. Network Protocol

D. Native Protocol

Answer optiona

Marks: 1

876 __________ method of Connection interface is used to create statement

A. createStatement()

B. executeQuery()

C. Connection()

D. Class.forName()

Answer optiona

Marks: 1

877 CGI stands for ___________

A. Collect Get Intermediate


B. Common Gateway Interface

C. Common Gateway Internet

D. Common Get Inteface

Answer optionb

Marks: 1

878 In response to HTTP Request servlet sends ______________

A. HTTP Response

B. HTML Response

C. FTP Response

D. SMTP Response

Answer optiona

Marks: 1

879 The HTTPSErvlet class is defined in ___________ package

A. javax.swing

B. javax.servlet.http

C. java.awt

D. java.applet

Answer optionb

Marks: 1

880 When we invoke repaint() for a java.awt.Component object, the AWT invokes the method:

A. draw()

B. show()

C. update()

D. paint()

Answer optionc

Marks: 2

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

A. host()

B. getHost()

C. GetHost()

D. gethost()

Answer optionb

Marks: 2

public void actionPerformed(ActionEvent ae)


{
if(ae.getSource().equals(submit))
{
882 setBackground(Color.red);
}
}
For above code , state which of the following event listener interface must be imported?

A. MouseListener

B. ActionListener

C. ComponentListener

D. KeyListener

Answer optionb
Marks: 2

which statement is correct?


1)MouseClicked() is defined in MouseMotionListener
883 2)MouseEntered() is defined in MouseMotionListener
3)MouseMoved() is defined in MouseMotionListener
4)MouseReleased() is defined in MouseListener

A. 1,2

B. 2,3

C. 1,3

D. 3,4

Answer optiond

Marks: 2

1)For Key events, KeyEvent class is used


2)For Mouse motion events, MouseEvent class is used
884 3)For Component events, ComponentEvent class is used
4)For Window events, WindowEvent class is used

A. 1,2,3 are true

B. 1 & 4 are true

C. All are true

D. None of these are true

Answer optiona

Marks: 2

885 In Graphics class Which method is used to set the graphics current color to the specified color?

A. public abstract void setFont(Font font)

B. public abstract void setColor(Color c)

C. public abstract void drawString(String str, int x, int y)

D. None of the above

Answer optionb

Marks: 1

886 The __________ arranges components in rows and columns and makes all components the same size.

A. GridLayout manager

B. GridBaglayout manager

C. BorderLayout manager

D. FlowLayout manager

Answer optiona

Marks: 1

887 The string parameter to the JButton constructor

A. tells which region to put the button in

B. tells the color of the button

C. tells what text will appear on the button

D. tells what should happen when the button is pressed

Answer optionc

Marks: 1

888 __________ is a Swing class that allows the user to enter a single line of text.

A. TextField

B. JTextField
C. EditTextField

D. TextArea

Answer optionb

Marks: 1

889 What kind of event is fired when the user selects an item from a checkablemenu?

A. MenuEvent

B. CommandEvent

C. ItemEvent

D. UserActionEven

Answer optionc

Marks: 1

890 Which of these methods is used to know when was the URL last modified?

A. LastModified()

B. getLastModified()

C. GetLastModified()

D. getlastModified()()

Answer optionb

Marks: 1

Which of the following describes the correct sequence of the steps involved in making a connection with a database. 1. Loading the
891 driver 2. Process the results. 3. Making the connection with the database. 4. Executing the SQL statements.

A. 1,3,4,2

B. 1,2,3,4

C. 2,1,3,4

D. 4,1,2,3

Answer optiona

Marks: 1

892 Which one is the constructor of the Jtable?

A. JTable(Object data[ ][ ], Object colHeads[ ])

B. JTable(Hashtable ht)

C. JTable(Vector v)

D. None of the above

Answer optiona

Marks: 2

893 itemStateChanged() method take which form from the following?

A. int itemStateChanged(ItemEvent ie)

B. void itemStateChang(ItemEvent ie)

C. void itemStateChanged(ItemEvent ie)

D. void itemStateChanged(ItemEvent)

Answer optionc

Marks: 2

894 In this construtor ServerSocket(int port) creates Server Socket on the specified port with a queue length of _____.

A. 100
B. 50

C. 75

D. 80

Answer optionb

Marks: 2

import java.net.*;

public class URLDemo{

public static void main(String args[])throws MalformedURLException{


URL hp = new URL("http://www.msbte.com");
895 System.out.println("Protocal:" + 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());
}
} What will be the output of above code?

Protocal:http
Port:-1
A. Host:www.msbte.com
File:
Ext:http://www.msbte.com

Protocal:http
Port:-1
B. Host:www.javajazzup.com
File: msbte
Ext:http://www.msbte.com

Protocal:http
Port:80
C. Host:www.msbte.com
File:
Ext:http://www.msbte.com

Protocal:http
Port:-1
D. Host:www.msbte.com
File:
Ext://www.msbte.com

Answer optiona

Marks: 2

896 Which is the correct option from the following for JDBC driver types?

1 JDBC-ODBC bridge plus ODBC driver, also called Type 1.


2 Native-API, partly Java driver, also called Type 2.
A. 3 JDBC-Net, pure Java driver, also called Type 3.
4 Native-protocol, pure Java driver, also called Type 4.

1 JDBC-ODBC bridge plus ODBC driver, also called Type 1.


2 Native-protocol, pure Java driver, also called Type 2.
B. 3 JDBC-Net, pure Java driver, also called Type 3.
4 Native-API, partly Java driver, also called Type 4.

1 JDBC-Net, pure Java driver, also called Type 1.


2 Native-API, partly Java driver, also called Type 2.
C. 3 JDBC-ODBC bridge plus ODBC driver, also called Type 3.
4 Native-protocol, pure Java driver, also called Type 4.

D. None of these

Answer optiona

Marks: 2

897 What is the purpose of next() method?

A. next ( ) method is used to retain next elements in a series.

B. next ( ) method is used to retain next table

C. next () method is used to retain next record in a series.

D. None of the above

Answer optiona

Marks: 2

898 Which of the following piece of code shows how to retrieve the value of the Row Id for a particular Row?

String selectQuery = " select rowid from Employees where id ='123' ";
A. ResultSet resultSet = statement.executeQuery("selectQuery");
java.sql.Rowid rowId = resultSet.getRowId();
String selectQuery = " select rowid from Employees where id ='123' ";
B. ResultSet resultSet = statement.executeQuery("selectQuery");
java.sql.Rowid rowId = ResultSet.getRowId();

String selectQuery = " select rowid from Employees where id ='123' ";
C. ResultSet resultSet = Statement.ExecuteQuery("selectQuery");
java.sql.Rowid rowId = resultSet.getRowId();

D. None of the above

Answer optiona

Marks: 2

899 Syntax of Scriptlet Element

A. <% code %>

B. <@jsp code %>

C. <jsp: scriptlet code />

D. <%jsp code %>

Answer optiona

Marks: 2

900 How many Button objects are required to get the following output

A. 4

B. 2

C. 1

D. 3

Answer optiond

Marks: 2

The following step is for


stmt.executeUpdate(sql);
901 sql = "INSERT INTO Registration " +
"VALUES(103, 'Sumit', 'Mittal', 28)";
stmt.executeUpdate(sql);

Insert
A.

B. delete

C. update

D. Display

Answer optiona

Marks: 2

What will be the output of following code?


import java.sql.*;

public class JdbcGetConnection {

public static void main(String args[]) {

Connection con = null;


Statement st = null;
ResultSet rs = null;

try {
902 Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/komal", "root", "root");

System.out.println("Connection is closed : " + con.isClosed());


con.close();
System.out.println("Connection is closed : " + con.isClosed());

} catch (Exception e) {
System.out.println(e);
}
}
}

Connection is closed : false


A. Connection is closed : true

B. Connection is closed : true


Connection is closed : true
C. Connection is closed : true

Connection is closed : false


D. Connection is closed : false

Answer optiona

Marks: 2

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DateServlet extends HttpServlet {
public void doGet(HttpServletRequest request)
throws ServletException, IOException {
HttpSession hs = request.getSession(true);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
903 pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
Date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
} find the error in the above code.

A. Date = new Date();

B. public void doGet(HttpServletRequest request)

C. Both A and B

D. No error

Answer optionc

Marks: 2

904 How would you set the color of a graphics context called g to cyan?

A. g.setColor("cyan’);

B. g.setCurrentColor(cyan);

C. g.setColor("Color.cyan");

D. g.setColor(Color.cyan);

Answer optiond

Marks: 1

905 Which of the following are passed as an argument to the paint( ) method?

A. A Canvas object

B. A Graphics object

C. An Image object

D. A paint object

Answer optionb

Marks: 1

906 A GUI stands for _____________.

A. uses buttons, menus, and icons

B. should be easy for a user to manipulate

C. stands for Graphical User Interface

D. Both A) and B)

Answer optionc

Marks: 1

907 The constructor which is used to create client socket is ____________.

A. Socket(InetAddress IPAddress, int port).


B. ServerSocket(int port).

C. ServerSocket(int port, int maxQueue).

D. Socket(int port).

Answer optiona

Marks: 1

908 The constructor which is used in ServerSocket may be______________.

A. Socket (Inet Address, int port, IP Address).

B. ServerSocket (int port)

C. ServerSocket (int maxQueue, Inet Address).

D. ServerSocket(int maxQueue, Inet Address localAddress).

Answer optionb

Marks: 1

909 Calling ServerSocket() constructor with port value 'zero' means______________________.

A. use a port number zero that is automatically allocated.

B. use a port number zero that is automatically destroyed.

C. use a port number zero that is automatically connection created.

D. use a port number zero that is automatically stop.

Answer optiona

Marks: 1

Which datagram method returns the byte array of data contained in the datagram?
910

A. InetAddress getAddress()

B. int getPort().

C. byte[] getData()

D. byte[] getAddress().

Answer optionc

Marks: 1

911 During Initialization of Servlet, a servlet instance can throw ________.

A. An UnavailableException

B. A ServletException

C. Both A and B

D. None of these

Answer optionc

Marks: 1

importjava.awt.*;
importjava.applet.*;
public class list2 extends Applet
{ public void init()
{
912 List l= new List(2,true); l.add("java");
l.add("c++");
l.add("kkk"); add(l);
}
} /*<applet code=list2.class height=200 width=200>
</applet>*/

A.

B.

C.

D.
Answer optionc

Marks: 2

913 which Listeners are required for following output.

A. MouseMotionListener

B. MouseListener, MouseMotionListener

C. MouseListener

D. None of the Above

Answer optionb

Marks: 2

Which is mssing statement in the following code import java.awt.*;


import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
/*<applet code="JRadio1" width=300 height=100></applet>*/
public class JRadio1 extends JApplet implements ActionListener
{
Container ContentPane=getContentPane();
JTextField tf;
public void init()
{
ContentPane.setLayout(new FlowLayout());
JRadioButton r1=new JRadioButton("Red");
r1.addActionListener(this);
ContentPane.add(r1);
JRadioButton g1=new JRadioButton("Green");

ContentPane.add(g1);
JRadioButton b1=new JRadioButton("Blue");
b1.addActionListener(this);
914 ContentPane.add(b1);
ButtonGroup bg=new ButtonGroup();
bg.add(r1);
bg.add(g1);
bg.add(b1);
tf=new JTextField(5);
ContentPane.add(tf);
}
public void actionPerformed(ActionEvent ae)
{
String s;
s=ae.getActionCommand();
if(s=="Red")
ContentPane.setBackground(Color.red);
else if(s=="Green")
ContentPane.setBackground(Color.green);
else if(s=="Blue")
ContentPane.setBackground(Color.blue);
}
}

A. a1.additemListener(this);

B. g1.addActionListener(this);

C. r1.addEventListener(this);

D. None of the above

Answer optionb

Marks: 2

915 The Applet class is in ���..package

A. java.applet

B. java.io

C. java.awt

D. java.util

Answer optiona

Marks: 1

916 ODBC is not appropriate for direct use from java because it uses a ..............

A. C interface�

B. C# interface�
C. java interface�

D. Both A and C

Answer optiona

Marks: 1

917 which package contains color class?

A. java.awt

B. java.graphics

C. java.applet

D. java.frame

Answer optiona

Marks: 2

Select the proper command to run the following code

import java.awt.*;

import java.applet.*;

/*
<applet code="textdemo25" width=300 height=100>

</applet>
*/

public class textdemo25 extends Applet


918 {

public void init()


{

TextField jt=new TextField(30);

add(jt)
}

A. appletviewer textdemo25 .java

B. javac textdemo25.java

C. java textdemo25

D. All of the Above

Answer optiona

Marks: 2

What Component will be displayed in output of Following Code

import java.awt.*;
import java.applet.*;
/*
<applet code="Mydemo25" width=300 height=100>
</applet>
*/
919 public class Mydemo25 extends Applet
{
public void init()
{

TextField jt=new TextField(30);


add(jt);
add(new Button("OK"));
}
}

A. TextBox

B. Button

C. TextBox and Button

D. Depends on System

Answer optionc

Marks: 2
what will bw the output of the following program:
import java.awt.*;
import javax.swing.*;

public class MyFlowLayout{


JFrame f;
MyFlowLayout(){
f=new JFrame();

JButton b1=new JButton("1");


JButton b2=new JButton("2");
JButton b3=new JButton("3");
JButton b4=new JButton("4");
JButton b5=new JButton("5");

920 f.add(b5);
f.add(b4);
f.add(b3);
f.add(b2);
f.add(b1);

f.setLayout(new FlowLayout(FlowLayout.RIGHT));
//setting flow layout of right alignment

f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new MyFlowLayout();
}
}

The output will display buttons in a sequence


5
4
A. 3
2
1

The output will display buttons in a sequence;


1
2
B. 3
4
5

The output will display buttons in a sequence;


3
4
C. 5
2
1

The output will display buttons in a sequence;


5
3
D. 4
1
2

Answer optiona

Marks: 2

What will be the output of the following program:

import java.applet.Applet;
import java.awt.Button;

/*
<applet code="DisableButtonExample" width=100 height=200>
</applet>
*/

public class DisableButtonExample extends Applet{

921 public void init(){

Button Button1 = new Button("Ok");


Button Button2 = new Button("Cancel");

add(Button1);
add(Button2);

Button2.setEnabled(false);
}
}

The output will display Two buttons labelled "OK" and "Cancle";
A. The button with label "cancel" will be disabled

The output will display Two buttons labelled "OK" and "Cancle";
B. The button with label "OK" will be disabled

The output will display Two buttons labelled "OK" and "Cancle";
C. Both the button with label "ok" and "cancel" will be disabled

The output will display Two buttons labelled "OK" and "Cancle";
D. No button will be disabled

Answer optiona

Marks: 2
Observe the following program
import java.sql.*;
class TYIFCon{
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
922 Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
con.close();
}catch(Exception e){ System.out.println(e);}
}
}

A. This program will fetch all the records of emp table.

B. This program will not fetch all the records of emp table.

C. This program will fetch some the records of emp table.

D. none of the above

Answer optiona

Marks: 2

Observer the following program.


import java.sql.*;
class TYIFCon{
public static void main(String args[]){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:empdsn");
Statement stmt=con.createStatement();
923 ResultSet rs=stmt.executeUpdate("select * from emp");
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
con.close();
}catch(Exception e){ System.out.println(e);}
}
}

A. In This program executeUpdate() must be replaced by executeQuery()

B. In This program executeUpdate() must be replaced by executeQueryUpdate()

C. In This program executeUpdate() must be replaced by executeUpdateQuery()

D. none of the above

Answer optiona

Marks: 2

Observer the following program.


import java.sql.*;
class Test
{
public static void main(String ar[])
{
try
{
String url="jdbc:odbc:mydsn";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection(url);
924 Statement st=c.createStatement();
ResultSet rs=st.executeQuery("select * from login");

while(rs.next()){
System.out.println(rs.getString(1));
}

}
catch(Exception ee){System.out.println(ee);}

A. There is compiler error of missing a closing curly bracket

B. There is compiler error of missing a opening curly bracket

C. There is compiler error of extra a closing curly bracket

D. none of the above

Answer optiona

Marks: 2
Observer the following program.
import java.sql.*;
class Test{
public static void main(String ar[]){
try{
String url="jdbc:odbc:mydsn";

Connection c=DriverManager.getConnection(url);
Statement st=c.createStatement();
925 ResultSet rs=st.executeQuery("select * from login");

while(rs.next()){
System.out.println(rs.getString(1));
}

}catch(Exception ee){System.out.println(ee);}

Following statement is missing


A. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Following statement is missing


B. Connection c=DriverManager.getConnection(url);

C. No statement is missing

D. Both a and b

Answer optiona

Marks: 2

Observe the program and what will the output:


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloServelet extends HttpServlet {


protected void processRequest(HttpServletRequest request, HttpServletResponse response)
926 throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String name = request.getParameter("name");
int a = Integer.parseInt( request.getParameter("num1"));
int b = Integer.parseInt( request.getParameter("num2"));
sum = a + b;
out.println("Hi!" + name + "The sum is" + sum);
out.close();
}
}

A. This program will read user name and two values and display the sum of two values

B. This program will read only two values and display the sum of two values

C. This program will read user name and one value and display

D. This program will read user name and two values and display the sum of three values

Answer optiona

Marks: 2

Following Java program will throw exception ___________.Select any one option from given options
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class DemoServlet extends HttpServlet{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws
{
927 res.setContentType("text/html");
PrintWriter pw=req.getWriter();
pw.println("<html><body>");
pw.println("Welcome to servlet");
pw.println("</body></html>");
pw.close();
}}

A. throws ServletException,IOException

B. throws ServletException

C. throws IOException

D. throws ArrayIndexOutofBound

Answer optiona

Marks: 2

928 Which of the following is passive AWT control?


A. Label

B. Button

C. Checkbox

D. TextField

Answer optiona

Marks: 1

929 Which is the immediate super class of Applet?

A. Container

B. Component

C. Frame

D. Panel

Answer optiond

Marks: 1

930 FlowLayout does not support this value of alignment�

A. FlowLayout.LEFT

B. FlowLayout.CENTER

C. FlowLayout.RIGHT

D. FlowLayout.BASELINE

Answer optiond

Marks: 1

931 Permission class belongs to which package?

A. java.security

B. java.lang.object

C. java.permission.security

D. java.security.permission

Answer optiona

Marks: 1

932 Abbreviate the term DSN

A. Digital Source Name

B. Data Socket Name

C. Data String Name

D. Data Source Name

Answer optiond

Marks: 1

933 The default horizontal and vertical gap in FlowLayout is�..

A. 0 pixel

B. 1 Pixel

C. 5 Pixel

D. 10 Pixel

Answer optionc

Marks: 2
934 To construct a text area that is 80 character-widths wide and 10 character-heights tall, select appropriate code.

A. new TextArea(80, 10)

B. new TextArea(10, 80)

C. new TextArea(40, 80)

D. new TextArea(80, 40)

Answer optionb

Marks: 2

935 Is it possible to change display character of TextField?How?

A. Not possible.

B. Yes,by using setChar() method.

C. Yes,by using setEchoChar() method.

D. Yes,by using setDisplayChar() method.

Answer optionc

Marks: 2

What is correct code for the given problem statement:


936 Develop a program to send a message from client to server and server should send back any message to client.

import java.lang.*;
import java.io.*;
import java.net.*;

class Server {
public static void main(String args[]) {
String data = "Toobie ornaught toobie";
try {
ServerSocket srvr = new ServerSocket(1234);
Socket skt = srvr.accept();
System.out.print("Server has connected!\n");
A. PrintWriter out = new PrintWriter(skt.getOutputStream(), true);
System.out.print("Sending string: '" + data + "'\n");
out.print(data);
out.close();
skt.close();
srvr.close();
}
catch(Exception e) {
System.out.print("Whoops! It didn't work!\n");
}
}
}

import java.lang.*;
import java.io.*;
import java.net.*;

class Client {
public static void main(String args[]) {
try {
Socket skt = new Socket("localhost", 1234);
BufferedReader in = new BufferedReader(new
InputStreamReader(skt.getInputStream()));
System.out.print("Received string: '");
B.
while (!in.ready()) {}
System.out.println(in.readLine()); // Read one line and output it

System.out.print("'\n");
in.close();
}
catch(Exception e) {
System.out.print("Whoops! It didn't work!\n");
}
}
}

C. both A & B

D. None

Answer optionc

Marks: 2
This is an example of Statement interface that?

import java.sql.*;
class PreStat
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:student"," "," ");
Statement s=c.createStatement("select * from studTable");
937 ResultSet rs=s.executeQuery();
System .out.println("Name" + " \t " + "Roll_No");
while(rs.next())
{
System.out.println(rs.getInt(1)+" \t "+rs.getString(2));
}
s.close();
c.close();
}
}

A. deletes the record

B. retrieve the record

C. updates the record

D. inserts the record

Answer optionb

Marks: 2

Consider the following program.


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

class Demo1
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
938 int rs=s.executeQuery("select *from StudTable");
System .out.println("Name" + " \t " + "Roll_No" );
while(rs.next)
{
System.out.println(rs.getString(1)+" \t "+rs.getInt(2));
}
s.close();
c.close();
}
}

A. Missing Semicolon

B. Missing {

C. Missing }

D. Missing package

Answer optiond

Marks: 2

Consider the following program. Identify which statement contains error.

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class FactorialServlet extends HttpServlet
{
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
int fact=1;
939 int f1 = res.getParameter("number");
int num=Integer.parseInt(f1);
res.setContentType("text/html");
PrintWriter out = res.getWriter();
for(int i=1;i<=num;i++)
{
fact=fact*i;
}
out.println("The factorial of number is");
out.println(fact);
out.close();
}
}

A. Error in package

B. Error in doGet() method

C. Error in for loop

D. Error in getParameter() method return value of request parameter.


Answer optiond

Marks: 2

Consider the following program. Identify the missing statement to get correct output.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
940 {
String data = request.getParameter("data");
Cookie cookie = new Cookie("MyCookie", data);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. response.add(cookie);

B. response.addCookie(cookie);

C. request.addCookie(cookie);

D. request.add(cookie);

Answer optionb

Marks: 2

Assume that you need to write a JSP page that adds numbers from one to ten and then print the output.

<% int sum=0;


for(int i=1;i<=10;i++) { %>
941 <%sum=sum+i; %>
<% } %>
YYY
Which statement must be added at the location of YYY to print the sum of ten numbers.

A. <% sum %>

B. <% sum; %>

C. <%=sum %>

D. <%=sum; %>

Answer optionc

Marks: 2

942 Which are the subclasses of the container class?

A. Windows,Panel,ScrollPane.

B. ScrollPane,Vector,String.

C. Thread,Vector,String.

D. Applet,InetAddress,Vector.

Answer optiona

Marks: 1

943 2. What is the purpose of JTable?

A. JTable object displays rows of data.

B. JTable object displays columns of data.

C. JTable object displays rows and columns of data.

D. JTable object displays data in Tree form.

Answer optionc

Marks: 2

944 _____________ class is necessory to implements Datagram

A. DatagramPacket
B. DatagramSocket

C. None

D. both a and b

Answer optiond

Marks: 2

The program given below is for ______________

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();
945 PrintStream p = new PrintStream(so.getOutputStream());
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);
}
}
}

A. Server side

B. client side

C. both side

D. None of above

Answer optionb

Marks: 2

946 Where is Metadata stored in MYSQL?

A. In MYSQL database Metadata

B. In MYSQL database Metasql

C. In MYSQL database Mysql

D. None of above

Answer optionc

Marks: 2

select the missing statement in the following code


import java.awt.FlowLayout;

public class HelloWorldSwing1 extends JFrame {

public static void main(String[] args) {


JFrame frame = new JFrame("HelloWorldSwing");
JLabel label = new JLabel("Hello World");

JButton b1=new JButton("submit");


947 JTextField t1=new JTextField(10);

frame.getContentPane().add(label);
frame.getContentPane().add(t1);
frame.getContentPane().add(b1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
frame.getContentPane().setLayout(new FlowLayout());
}
}

A. import javax.swing.*;

B. import javax.Swing.io.*;

C. import javax.Swing.awt.*;

D. import java.Swing.*;
Answer optiona

Marks: 2

948 Which one is not the Layout Manager

A. GridLayout

B. FlowLayout

C. BorderLayout

D. setLayout

Answer optiond

Marks: 2

write the command to compile the following code

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Paneldemo extends Frame {

public void paneldemo()


{
Panel p=new Panel();
p.setBackground(Color.black);
add(p);
949

public static void main(String args[])


{
Paneldemo pd=new Paneldemo();
pd.setVisible(true);
pd.setSize(500,500);

javac Paneldemo.java
A.

B. java Paneldemo.java

C. java Paneldemo

D. javac Paneldemo

Answer optiona

Marks: 2
what will be the result of following code if value of no1=no2=no3=2 and Button pressed="ok";

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code "adddemo.class" height=400 width=400>
</applet code>
*/
public class adddemo extends Applet implements ActionListener{
String msg="";
Label l1,l2,l3,l4;
TextField t1,t2,t3,t4;
Button b1,b2;
FlowLayout f;
public void init()
{
f=new FlowLayout(FlowLayout.LEFT,10,10);
setLayout(f);
l1=new Label("enter no1");
add(l1);
t1=new TextField(5);
add(t1);
l2=new Label("enter no2");
add(l2);
t2=new TextField(5);
add(t2);
l3=new Label("Enter no3");
add(l3);
t3=new TextField(5);
add(t3);
l4=new Label("Result");
add(l4);
950 t4=new TextField(10);
add(t4);
b1=new Button("ok");
add(b1);
b2=new Button("not ok");
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}

public void actionPerformed(ActionEvent ae)


{
if(ae.getSource()==b1)
{
msg="Result is correct";
int n1=Integer.parseInt(t1.getText());
int n2=Integer.parseInt(t2.getText());
int n3=Integer.parseInt(t3.getText());
int n=n1+n2+n3;
t4.setText(Integer.toString(n));
}
else if(ae.getSource()==b2)
{
msg="Result is not correct";
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, 2, 200);
}
}

A. 2

B. 4

C. 6

D. 8

Answer optionc

Marks: 2

951 Which method is Applicable for ItemListener interface ?

A. actionPerformed(ActionEvent ae)

B. action(ActionEvent ae)

C. itemStatechanged(ItemEvent e)

D. itemStatechanged(EventItem e)

Answer optionc

Marks: 1

952 Event class is defined in which of these libraries?

A. java.io

B. java.lang

C. java.net
D. java.util

Answer optiond

Marks: 2

What is the ouput of following code?


import java.net.InetAddress;
import java.net.UnknownHostException;

class Inetadddemo {
public static void main(String args[])throws UnknownHostException
{
953
InetAddress address=InetAddress.getLocalHost();
System.out.println(address);

A. local m/c Address

B. Server Address

C. both I and ii

D. none of above

Answer optiona

Marks: 2

What is the ouput of following code?Assume suitable data


import java.sql.*;
class contest {
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("\n Drivers loaded properly");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
System.out.println("\n Conncted");
954
String sql="create table t1(empno Integer,empname varchar(20))";
PreparedStatement ps1=con.PrepareStatement(sql);
ps1.excuteUpdate();
System.out.println("\n Table created");
con.close();
}catch(SQLException e)
System.out.println("\n SQL Error");
}
catch(Exception e)
{
System.out.println("\n Other Error");
}

A. Sql error

B. Other error

C. Table created

D. table not created

Answer optionc

Marks: 2

import java.io.IOException;
import java.sql.*;

what is the correction in the following code to get the output

public class contest {

public void main(String args[])throws IOException


{
try
{
955 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("\n Drivers are properly Loded");
String url="jdbc:odbc:abc"
Connection con=DriverManager.getConnection(url);
System.out.println("connetion establised");
con.close();

}catch(SQLException e){} catch (ClassNotFoundException e) {


// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

A. Missing Semicolon
B. Missing {

C. Missing }

D. missing statement

Answer optiona

Marks: 2

956 Window, frame and dialog use ________ as their default layout.

A. BorderLayout

B. FlowLayout

C. GridLayout

D. GridBagLayout

Answer optiona

Marks: 1

957 A _______ is a component that appears as a group of folders in a file cabinet.

A. JTabbedPane

B. JTree

C. JTable

D. JProgressBar

Answer optiona

Marks: 1

958 The parameters of the PreparedStatement object are ...................... when the user clicks on the Query button.

A. initialized

B. stopped

C. paused

D. started

Answer optiona

Marks: 1

959 The ......................... method executes an SQL statement that may return multiple results.

A. executeUpdate()

B. executeQuery()

C. execute()

D. noexecute()

Answer optionc

Marks: 1

960 Give the examples of Application Server from the following?

A. JBoss

B. Weblogic

C. Java Application Server

D. All of the above

Answer optiond

Marks: 1

961 Which method of the component class is used to set the position and the size of a component?
A. setSize()

B. setEditable()

C. setBounds()

D. setVisible(100,200)

Answer optionc

Marks: 2

962 Which of the following MouseMotionListener interface methods?

A. mouseReleased(MouseEvent me),mouseMoved(MouseEvent me)

B. mouseExited(MouseEvent me), mousePressed(MouseEvent me),

C. mouseClicked(MouseEvent me), mouseEntered(MouseEvent me)

D. mouseDragged(MouseEvent me), mouseMoved(MouseEvent me)

Answer optiond

Marks: 2

963 Which is reserved port of HTTP & FTP

A. 80 & 21

B. 25 & 21

C. 80 & 79

D. 79 & 25

Answer optiona

Marks: 2

964 Which maintains a cursor pointing to a particular row of data,Initially, cursor points to before the first row?

A. Connection interface

B. Statement interface

C. ResultSet interface

D. PreparedStatement interface

Answer optionc

Marks: 2

What happens after executation of following code


import java.sql.*;
import java.io.*;
public class new
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers are loaded properly.");
String url = "jdbc:odbc:Demo";
Connection c1 = DriverManager.getConnection(url);
965 String sql="create table emp1(emp_id INTEGER,emp_name varchar(20))";
PreparedStatement ps = c1.prepareStatement(sql);
ps.executeUpdate();
c1.close();
}catch(SQLException se)
{
System.out.println("SQL Error.");
}catch(Exception e)
{
System.out.println("Other Error.");
}
}
}
}

A. SQL Error

B. Missing statement

C. Successfully Run and table is created.

D. Other Error.
Answer optionc

Marks: 2

Consider the following programe & find the error statement.

import java.sql.*;
class Test{
public static void main(String ar[]){
try{
String url="jdbc:odbc:mydsn";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection(url);
966
ResultSet rs=st.executeQuery("select * from login");

while(rs.next()){
System.out.println(rs.getString(1));
}
}catch(Exception ee){System.out.println(ee);}
}
}

A. Connecction not established.

B. Missing Statement st=c.createStatement();

C. Other Error

D. Successfully Run

Answer optionb

Marks: 2

What happens after execution of following code

import java.sql.*;
public class JdbcAccessConnectionDemo {
public static void main(String [] args) {
Connection con = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
967 con = DriverManager.getConnection("jdbc:odbc:database1");
System.out.println("Connection OK.");
con.close();
} catch (Exception e) {
System.err.println("Exception: "+e.getMessage());
}
}
}

A. Connecction not established.

B. Connecction OK.

C. Statement and Resultset Missing

D. Other Error.

Answer optionb

Marks: 2

What happens after executation of following code

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class cookiesDemo extends HttpServlet {


private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Cookie t=null;
response.setContentType("text/html");
968 PrintWriter out=response.getWriter();
out.println("<HTML><BODY>");
t=new Cookie("token", null);
Cookie token = null;
token.setMaxAge(6);
response.addCookie(token);
out.println("Information collected by the Cookies: ");
out.println("User Name:"+token.getValue());
out.println("</HTML></BODY>");
out.close();
}
}

A. Successfully run and display the user name.

B. Missing Service()

C. Error in programe

new Cookie("MyCookie", data);


D.

Answer optiona
Marks: 2

What happens after execution of following code

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class sessionDemo extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


response.setContentType("text/html");
PrintWriter pw=response.getWriter();
HttpSession session=request.getSession(true);
969 Integer count=(Integer)session.getValue("tracker.count");
if(count==null)
count=new Integer(1);
else
count= new Integer(count.intValue()+1);
session.putValue("tracker.count",count);
pw.println("<HTML><BODY><H2>SESSION TRACKING DEMO</H2>");
pw.println("You Have Visited This Page: "+count+"times");
pw.println("Session ID is :"+session.getId());
pw.println("</HTML></BODY>");
}
}

A. Missing session object

B. Successfully run and display visited page count , session ID.

C. Resource is not Found.

D. None of Above

Answer optionb

Marks: 2

970 The coordinate of the upper-left corner of a frame is ________.

A. (10, 10)

B. (100, 100)

C. (25, 25)

D. (0, 0)

Answer optiond

Marks: 1

971 Which of the follwing is constructor of Jtable?

A. JTable(Object data[][])

B. JTable(Object colHeads[])

C. JTable(Object colHeads[],Object data[][])

D. JTable(Object data[][], Object colHeads[])

Answer optiond

Marks: 1

972 The superclass of ContainerEvent, FocusEvent and WindowEvent is _______________ .

A. ActionEvent

B. ComponentEvent

C. InputEvent

D. None of the above

Answer optionb

Marks: 1

973 _____________ protocol supports fast point to point datagram oriented model.

A. TCP/IP

B. UDP

C. SNMP
D. FTP

Answer optionb

Marks: 1

974 The First task in JDBC is _________________ .

A. to establish a connection

B. register a driver

C. create a statement

D. collect the resultset

Answer optionb

Marks: 1

975 DELETE statement of an SQL is executed by ______________.

A. execute()

B. executeQuery()

C. executeUpdate()

D. executeDelete()

Answer optionc

Marks: 1

976 Which packages represent interfaces and classes for servlet API?

A. javax.servlet

B. javax.servlet.http

C. both a and b

D. None of the above

Answer optionc

Marks: 1

A Swing component can be viewed based on what state it�s in, how it looks, and what it does. This is
977 known as the model-view- __________ model.

A. Controller

B. Component

C. Content

D. None of the above

Answer optiona

Marks: 2

978 What method is used to handle item events from menus, checkboxes, and radio buttons?

A. itemStateChanged()

B. getItemEvent()

C. addItemListener()

D. None of the above

Answer optiona

Marks: 2

979 Which of the following does NOT generate GUI events?

A. Typing in a text field.

B. Selecting an item from a menu.


C. Displaying the text in a label.

D. Moving the mouse.

Answer optionc

Marks: 2

980 When a connection is created, by default it is in _____________

A. rollback mode

B. execute mode

C. select mode

D. auto commit mode

Answer optiond

Marks: 2

981 __________ uses doGet(),doPost(),doHead,doDelete(),doTrace().

A. GenericServlet

B. HttpServlet

C. both a and b

D. None of the above

Answer optionb

Marks: 2

Analyse the following code and Find out errors.


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code="Demo" width=200 height=80> </applet>*/
public class Demo extends Applet implements ItemListener
{
public void init()
{
Label jlb1=new Label(" Select Color:");
Choice ch=new Choice();
ch.addItem("Red");
ch.addItem("Green");
982 ch.addItem("Blue");
TextField jtf1=new TextField(12);
add(jlb1);
add(ch);
add(jtf1);
ch.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
String s=(String)ie.getItem();
jtf1.setText(s);
}
}

A. Error is in the statement String s=(String)ie.getItem();

B. Error is in package statement

C. Error is in the itemStateChanged() method

D. No error

Answer optiona

Marks: 2
Analyse the following code and select missing statement.
import java.awt.*;
import java.applet.*;
/*<applet code="Demo" width=200 height=80> </applet>*/
public class Demo extends Applet implements ItemListener
{
TextField jtf;
List city;
public void init()
{
city=new List(4);
city.addItem("Pune");
983 city.addItem("Mumbai");
city.addItem("Nagpur");
city.addItem("Kolhapur");
city.addItem("Solapur");
jtf=new TextField(12);
add(jtf);
}
public void itemStateChanged(ItemEvent ie)
{
String s=city.getSelectedItem();
jtf.setText(s);
}
}

A. import java.awt.event.*;

B. city.addItemListener(this);

C. add(city);

D. All of the above

Answer optiond

Marks: 2

What is the output of this program?


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code="Demo1" width=200 height=80> </applet>*/
public class Demo1 extends Applet implements MouseMotionListener
{
public void init()
{
addMouseMotionListener(this);
984 }
public void mouseMoved(MouseEvent me)
{
showStatus("Mouse Moved at "+me.getX()+" , "+me.getY());
}
public void mouseDragged(MouseEvent me)
{
showStatus("Mouse Dragged at "+me.getX()+" , "+me.getY());
}
}

A.

B.

C.

D.

Answer optiona

Marks: 2

Analyse the following code and find out missing statement.


import javax.swing.*;
import javax.swing.tree.*;
public class TreeDemo extends JFrame
{
public static void main(String args[])
{
TreeDemo frame = new TreeDemo();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
DefaultMutableTreeNode mercury = new DefaultMutableTreeNode("Mercury");
985 root.add(mercury);
DefaultMutableTreeNode venus = new DefaultMutableTreeNode("Venus");
root.add(venus);
DefaultMutableTreeNode mars = new DefaultMutableTreeNode("Mars");
root.add(mars);
JTree tree = new JTree(root);
JScrollPane scrollPane = new JScrollPane(tree);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
}
}

A. applet tag is missing

B. Jtree root node is missing

C. missing package statement


D. None of the above

Answer optionc

Marks: 2

What is the purpose of following code?

import java.sql.*;
class DeleteRecord
{
public static void main(String args[])throws Exception
{
986 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xyz");
Statement stmt=con.createStatement();
int result=stmt.executeUpdate("delete from emp");
con.close();
}
}

A. Deletes one record from emp

B. No record will be deleted

C. Deletes all the record from emp

D. Deletes emp table

Answer optionc

Marks: 2

Analyse the following code and find errors.


import java.sql.*;
class DisplayRecord
{
public static void main(String args[])throws Exception
{
987 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xyz");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeUpdate("select * from emp where id=101");
con.close();
}
}

A. Error is in package statement

B. Error is in Connection ststement

C. Error is in driver registering statement

D. Error is in query execution statement

Answer optiond

Marks: 2

Analyse the following code and find out missing statement.


import java.sql.*;
class Record
{
public static void main(String args[])throws Exception
{
Connection con=DriverManager.getConnection("jdbc:odbc:xyz");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp where id=101");
988 System.out.println("EmpName\tDesignation\tSalary");
where(rs.next())
{
System.out.println(rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getInt(4));

}
con.close();
}
}

A. Missing semicolon

B. Missing {

C. Missing driver registration statement

D. Missing }

Answer optionc

Marks: 2
Analyse the following code and find out errors
import java.sql.*;
class Record
{
public static void main(String args[])throws Exception
{
Class.forName("jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:mydsn");
Statement stmt=con.createStatement();
989 ResultSet rs=stmt.executeQuery("select * from emp where id=101");
System.out.println("EmpName\tDesignation\tSalary");
while(rs.next())
{
System.out.println(rs.getString(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3));
}
con.close();
}
}

A. Error is in statement in which connection is established

B. Error is in statement in which result is processed

C. Error is in statement in which driver is registerd

D. Error is in statement in which query is executed

Answer optionc

Marks: 2

Analyse the following code and fill the appropriate statement in the blanks
import java.sql.*;
class DB
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mydsn");
Statement stmt=con.createStatement();
990 ResultSet rs=stmt.________________("select * from emp where id=101");
System.out.println("EmpName\tDesignation\tSalary");
where(rs.next())
{
System.out.println(rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getInt(4));
}
con.close();
}
}

A. execute()

B. executeUpdate()

C. executeQuery()

D. executeSelect()

Answer optionc

Marks: 2

In following Java program fill statement showing __________.


import java.io.*;
import javax.servlet.*;
public class HelloServlet extends GenericServlet
{
public void __________(ServletRequest request,ServletResponse response)
991 throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1> Welcome to Servlet</h1>");
}
}

A. doGet

B. service

C. doPost

D. doDelete

Answer optionb

Marks: 2

What contents are displayed by following JSP program in browser window ?


<html>
<head><title>Hello World</title></head>
<body>
Hello World!<br/>
992 <%
out.println("Value="+(2*5));
%>
</body>
</html>
A. Value=10

B. Hello World! Value=100

Hello World!
C. Value=10

Hello World!
D. Value=(2*5)

Answer optionc

Marks: 2

993 Which is various methods of TextField control from following?

A. getIcon(),setText(),getText()

B. getText(),setText(),setEchoChar()

C. getTextField(),setTextField()

D. textfield(),setTextfield()

Answer optionb

Marks: 1

994 ______________is the constructor of List control.

A. list(int col,int row)

B. List(int numRows, boolean multipleSelect)

C. List(int numRows, boolean col)

D. List(int numRows, boolean multipleSelect,int rows)

Answer optionb

Marks: 1

995 Which are various methods of WindowListener interface from following?

A. void windowOpened(WindowEvent we), void windowIconified(WindowEvent we)

B. void windowDeiconified(WindowEvent we), void windowDeactivated(WindowEvent we)

C. void windowClosing(WindowEvent we), void windowClosed(WindowEvent we),

D. All above

Answer optiond

Marks: 1

996 Which of these is an adapter class?

A. ItemAdapter

B. ActionAdapter

C. ListAdapter

D. MouseAdapter

Answer optiond

Marks: 1

997 Which is not valid method of URL class?

A. getPort()

B. getHost()

C. getProtocol()

D. getUrl()

Answer optiond

Marks: 1
Select the missing statement in given code
import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class table extends JApplet
{
public void init()
{
String s[]={"srno","name","rollno"};
998 Object data[][]={{"1","abc","01"},{"2","xyz","0"}};
int v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane p=new JScrollPane(it,v,h);
Container co=getContentPane();
co.add(p,BorderLayout.CENTER);
}
}
/*<applet code=table width=300 height=300></applet>*/

JTable it=new JTable(data,s);


int v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
A. int h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane p=new JScrollPane(it,v,h);

JTable it=new JTable(data,s);


B. int v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;

JTable it=new JTable(data,s);


int v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
C. JScrollPane p=new JScrollPane(it,v,h);
addWindowListener(new MyAdapter());
addMpouseListener(new MyAdapter());

D. JTable it=new JTable(data,s);

Answer optiond

Marks: 2

Find the error of following code


import java.sql.*;

public class dbAccess


{
public static void main(String[] args)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:ab", "", "");
999 Statement s = conn.createStatement();
String s1="insert into Table1 values('akash','201')";
s.executeUpdate(s1);

s.close();
conn.close();

}
}

A. line no4 JDBC driver not loaded properly

B. no error data inser into database

C. Try and catch block missing

D. sql package not imported properly

Answer optionc

Marks: 2
Consider the following output. Find the missing statement in the program.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="SimpleKey" width=300 height=100>
</applet>
*/
public class SimpleKey extends Applet
implements KeyListener
{
String msg = "";
int X = 10, Y = 20; // output coordinates
public void init()
{

}
public void keyPressed(KeyEvent ke)
1000 {
showStatus("Key Down");
}
public void keyReleased(KeyEvent ke)
{
showStatus("Key Up");
}
public void keyTyped(KeyEvent ke)
{
msg += ke.getKeyChar();
repaint();
}
// Display keystrokes.
public void paint(Graphics g)
{
g.drawString(msg, X, Y);
}
}

A. addKeyListener();

B. addListener();

C. addKeyListener(this);

D. None of the above

Answer optionc

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;

public class dbAccess


{
public static void main(String[] args)throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
1001 Connection conn = DriverManager.getConnection("jdbc:odbc:ab", "", "");
Statement s = conn.createStatement();
String s1="update Table1 set name1='akash' where rollno='1'";
s.executeQuery(s1);

s.close();
conn.close();

}
}

try{ }
A. catch(Exception e){}

B. s.executeQuery(s1);

C. s.executeUpdate(s1)

D. s.execute(s1)

Answer optionc

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;

public class dbAccess


{
public static void main(String[] args)throws Exception
{
1002 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:ab", "", "");
String s1="update Table1 set name1='akash' where rollno='1'";
s.executeUpdate(s1);
s.close();
conn.close();

}
}

A. Missing semicolon
B. missing package

C. mssing try and catch block

D. All above

Answer optionc

Marks: 2

Consider the following program.Find error in the program.

import java.sql.*;

public class dbAccess


{
public static void main(String[] args)throws Exception
{
Class.forName("sun:jdbc:odbc:JdbcOdbcDriver");
1003 Connection conn = DriverManager.getConnection("jdbc:odbc:ab", "", "");
Statement s = conn.createStatement();
String s1="update Table1 set name1='akash' where rollno='1'";
s.executeUpdate(s1);
s.close();
conn.close();

}
}

A. Missing semicolon

B. exception in main class notfound sun:jdbc:odbc:JdbcOdbcDriver

C. Missing }

D. program is correct

Answer optionb

Marks: 2

1004 In java an event is an _________ which specifies the change of state in the source.

A. Class

B. Object

C. Int

D. String

Answer optionb

Marks: 1

1005 which of these method of DatagramPacket is used to find the length of byte Array

A. getnumber( )

B. length( )

C. getLength()

D. Length( )

Answer optionc

Marks: 1

1006 Which interface provides methods to execute queries with the database?

A. Connection interface

B. Statement interface

C. ResultSet interface

D. ResultSetMetaData interface

Answer optionb

Marks: 1

1007 Name the location of compiled class files within a jar file?

A. /META-INF/classes
B. /classes

C. /WEB-INF/classes

D. /root/classes

Answer optionc

Marks: 1

Select the missing statement in the program to get the following output
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/* <applet code="ChoiceDemo" width=300 height=180> </applet> */
public class ChoiceDemo extends Applet implements ItemListener
{ Choice city;
public void init() {
city.add("Nagpur");
city.add("Mumbai");
city.add("Pune");
city.add("Nashik");
1008 add(city);
city.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie) {
repaint();
}
public void paint(Graphics g) {
String msg = "Select city: ";
msg += city.getSelectedItem();
g.drawString(msg, 6, 120);
}
}

A. new Choice();

B. city = new Choice();

C. city = Choice();

D. c= new choice( )

Answer optionb

Marks: 2

1009 To establish the connection with the specified url?

A. public static void registerDriver(Driver driver)

B. public static void deregisterDriver(Driver driver)

C. public static Connection getConnection(String url)

D. public static Connection getConnection(String url,String userName,String password)

Answer optionc

Marks: 2

Consider the following program What should be the correction done in the program to get the correct output?
import java.sql.*
class ExecuteQueryTest
{
public static void main(String args[])
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded");
String url="jdbc:odbc:xyz";
Connection con = DriverManager.getConnection(url);
Statement state =con.createStatement();
System.out.println("Statement object created");
1010 String sql= "select Name,Age from student";
ResultSet rs =state.executeQuery(sql);
String text = " ";
while (rs.next())
{
text+= rs.getString(1) + " " + rs .getInt (2) + '\n' ;
}
System.out.println(text);
}
catch(Exception e)
{ System.out.println(�error�); }
}
}

A. missing JDBC driver

B. missing semicolon

C. missing statement

D. missing prepareStatement
Answer optionb

Marks: 2

1011 select correct code for display given output

public class FlowTest extends Applet {


public void init() {
setLayout(new FlowLayout());
for(int i=1; i<6; i++) {
A. add(new Button("Button " + i));
}
}
}

public class FlowTest extends Applet {


public void init() {
setLayout(new GridLayout(2,4));
for(int i=1; i<6; i++) {
B. add(new Button("Button " + i));
}
}
}

import java.awt.*;
imort java.applet.*;
/*<applet code="FlowTest.class" width=200 height=300></applet>*/

public class FlowTest extends Applet {


C. public void init() {
// setLayout(new FlowLayout()); Default
for(int i=1; i<6; i++) {
add(new Button("Button " + i));
}
}
}

public class FlowTest extends Applet {


public void init() {
setLayout(new BoxLayout());
for(int i=1; i<6; i++) {
D. add(new Button("Button " + i));
}
}
}

Answer optionc

Marks: 2

1012 select the correct code for display the given output

import javax.swing.*;
import java.awt.*;

public class ShowLayout extends JFrame


{
public ShowLayout (String s)
{
Container c = f.getContentPane();
c.setLayout (new FlowLayout());

c.add (new Button("NO");


c.add (new Button("Batter");
A.
c.add(new Label("Swing"));
}
public static void main (String args[])
{
JFrame f = new ShowLayout("JFrame Example");
f.setVisible(true);
}
}

import javax.swing.*;
import java.awt.*;

public class ShowLayout extends JFrame


{
public ShowLayout (String s)
{
Container c = f.getContentPane();
c.setLayout (new FlowLayout());
for (int i = 0; i < 5; i++)
{
c.add (new Button("NO");
B. }
c.add (new Button("Batter");
c.add(new Label("Swing"));

}
public static void main (String args[])
{
JFrame f = new ShowLayout("JFrame Example");
f.setVisible(true);
}
}
import javax.swing.*;
import java.awt.*;

public class ShowLayout extends JFrame


{
public ShowLayout (String s)
{
Container c = f.getContentPane();
c.setLayout (new FlowLayout());
for (int i = 0; i < 5; i++)
{
c.add (new Button("NO");
C. c.add (new Button("Batter");
}
c.add(new Label("Swing"));

}
public static void main (String args[])
{
JFrame f = new ShowLayout("JFrame Example");
f.setVisible(true);
}
}

import javax.swing.*;
import java.awt.*;

public class ShowLayout extends JFrame


{
public ShowLayout (String s)
{
Container c = f.getContentPane();
c.setLayout (new FlowLayout());
for (int i = 0; i < 4; i++)
{
c.add (new Button("NO");
D. c.add (new Button("Batter");
}
c.add(new Label("Swing"));

}
public static void main (String args[])
{
JFrame f = new ShowLayout("JFrame Example");
f.setVisible(true);
}
}

Answer optionc

Marks: 2

select the proper output for the following code

import java.awt.event.*;
public class eh extends Applet implements ActionListener
{
TextField t1;
Button b1,b2;
public void init()
{
t1 = new TextField(20);
b1 = new Button("Click Here");
b2 = new Button("Exit");
b1.addActionListener(this);
b2.addActionListener(this);
add(t1);
add(b2);
1013 add(b1);
}
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource()==b1)
{
t1.setText("Welcome to PCTE");
}
if (ae.getSource()==b2)
{
t1.setText("BYE BYE");
}
}
}
/* <applet code = eh.class width=200 height=200>
</applet> */

A.

B.

C.

D.

Answer optionc

Marks: 2
consider the following program. Identify which are the event need to get the correct output
import java.awt.*;
import java.awt.event.*;
class AEvent extends Frame implements ____________
{
TextField tf;
AEvent(){
tf=new TextField();
tf.setBounds(60,50,170,20);
Button b=new Button("click me");
b.setBounds(100,120,80,30);
b._______________(this);
add(b);add(tf);
1014
setSize(300,300);
setLayout(null);
setVisible(true);
}
public void _________________(__________ e)
{
tf.setText("Welcome");
}
public static void main(String args[]){
new AEvent();
}
}

ActionListener, addActionListener,actionPerformed,
A. ActionEvent

B. TextListener, addTextListener,textValueChanged, TextEvent

ActionListener, addActionListener,
C. textValueChanged, TextEvent

TextListener, addTextListener,actionPerformed,
D. ActionEvent

Answer optiona

Marks: 2

find the missing method following given code

import java.awt.*;
import java.awt.event.*;
public class ButtonTest3
{
public static void main(String[] args) {
Frame f = new ButtonTestFrame("Button Test");
f.setSize(150, 100);
f.setVisible(true);
}
}
class ButtonTestFrame extends Frame
{
public ButtonTestFrame(String title) {
super(title);
setLayout(new FlowLayout());
1015 Button b = new Button("Close window");
add(b);
b.addActionListener(new ButtonListener());
addWindowListener(new WindowCloser());
}
}
class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent evt) {
System.exit(0);
}
}
class WindowCloser extends WindowAdapter
{
public void ____________(WindowEvent evt) {
}
}

A. windowClosing()

B. windowActivated()

C. windowOpened()

D. windowDeiconified()

Answer optiona

Marks: 2
what is the missing statement in following program to access the database using jdbcodbc connection
import java.util.*;
import java.sql.*;
public class JdbcDemo
{
public static void main(String args[])
{
String query = "SELECT Name,Description,Qty,Cost FROM Stock";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection ("jdbc:odbc:Inventory");
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String name = rs.getString("Name");
1016 String desc = rs.getString("Description");
int qty = rs.getInt("Qty");
float cost = rs.getFloat("Cost");
System.out.println(name+", "+desc+"\t: "+qty+"\t@ $"+cost);
}
con.close();
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
}
}
}

A. Statement stmt = con.createStatement();

B. PreparedStatement ps=con.prepareStatement(query);

C. stmt = con.createStatement();

D. Statement stmt = createStatement();

Answer optiona

Marks: 2

Select the proper missing method for the following code


String queryLehigh = "select * from Lehigh";
ResultSet rs = Stmt.__________(queryLehigh);

1017 while (rs.next()) {


int ssn = rs.getInt("SSN");
String name = rs.getString("NAME");
int marks = rs.getInt("MARKS");
}

A. executeQuery()

B. executeUpdate()

C. execute( )

D. prepareStatement()

Answer optiona

Marks: 2

Which Exceptions are generated by following code

import java.sql.*;
class Test {
public static void main(String[] args) {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url=�jdbc:odbc:xyz�;
Connection con = DriverManager.getConnection(url);
Statement s = con.createStatement();
s.execute("create table TEST12345 ( firstcolumn integer )");
1018 s.execute("insert into TEST12345 values(1)");
s.execute("select firstcolumn from TEST12345");
ResultSet rs = s.getResultSet();
if (rs != null)
while ( rs.next() )
{ System.out.println("Data from column_name: " + rs.getString(1) );
}
s.close();
con.close();
}

A. ClassNotFoundException, SQLException

B. SQLException

C. ClassNotFoundException

D. MalformedException

Answer optiona
Marks: 2

What will be display in output using the following code.

import java.sql.*;
class Test
{
public static void main(String[] args)
{
try{
1019 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:naresh");
System.out.println("connection established");
con.close();
}
catch(Exception e){ }
}

A. Not display in output

B. connection established

C. display the error

D. connection not established

Answer optionb

Marks: 2

My application has a servlet, which do addition as shown on given values and sets the value in context scope.
It then prints the result.

PrintWriter out=response.getWriter();
int param_1 =Integer.parseInt(request.getParameter("Param1"));
1020 int param_2 = Integer.parseInt(request.getParameter("Param2"));
getServletContext.setAttribute("result",(param_1 + param_2));

out.print("Result =="+getServletContext.getAttribute("result"));

But sometimes I get wrong results. What do you think might be the reason?

A. The client must be disoperating the servlet call

B. The request attributes set are -ve numbers

C. Many clients must be accessing the servlet

D. The setAttribute method is not written properly.

Answer optionc

Marks: 2

1021 By default flowlayout uses __________justification.

A. Left

B. Right

C. Center

D. Top

Answer optionc

Marks: 1

1022 Which is true about swing?

A. Swing components are platform independent.

B. Swing is also called as JFC(Java Foundation Class)

C. Swing components are light weight.

D. All the above

Answer optiond

Marks: 1

1023 Control not support by awt are

A. Button,Label
B. Checkbox,Menu

C. TabbedPane,Table

D. TextField ,TextArea

Answer optionc

Marks: 1

1024 The delegation Event model is based on the concept of

A. source

B. listener

C. Both A and B

D. None of these

Answer optionc

Marks: 1

1025 ________________ is abstract class for representing access to a system resource.

A. Permission

B. Policy

C. Policyspi

D. Acess

Answer optiona

Marks: 1

1026 A socket is combination of

A. IP address

B. Port

C. Both A and B

D. None of above

Answer optionc

Marks: 1

1027 class.forName() method throws

A. IOException

B. ClassNotFoundException

C. SQLException

D. UnknownException

Answer optionb

Marks: 1

1028 Which method decides whether doGet() or doPost() method to call?

A. service

B. doOption

C. doMethod

D. init

Answer optiona

Marks: 1

1029 JSP implicit object associated with request is


A. HttpRequest

B. ServletRequest

C. Request

D. HttpServeletRequest

Answer optiond

Marks: 1

1030 Consider following output.Identify controls used.

A. Checkbox,TextField,Button,Choice

B. Checkbox,Label,TextField,Button

C. Checkbox,TextArea,Button,List

D. Checkbox,TextArea,Button,Label

Answer optiond

Marks: 2

Consider the folowing code.Select the proper scrollbar constant for blank line in code .
import javax.swing.*;
import java.applet.*;
import java.awt.*;

/* <applet code="ScrollDemo" width=300 height=100>


</applet>
*/

public class ScrollDemo extends JApplet


{
1031 public void init()
{
Container cp=getContentPane();
cp.setLayout(new BorderLayout());
JTextArea ja=new JTextArea();
int v=ScrollPaneConstants.____________________________ ;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
JScrollPane jsp=new JScrollPane(ja,v,h);
cp.add(jsp,BorderLayout.CENTER);
}
}

A. VERTICAL_SCROLLBAR_ALWAYS

B. VERTICAL_SCROLLBAR_AS_NEEDED

C. Both I and ii

D. VERTICAL_SCROLLBAR_NEEDED

Answer optionc

Marks: 2

1032 Identify layout used in the output given below.

A. BorderLayout

B. GridLayout

C. FlowLayout

D. CardLayout

Answer optionb

Marks: 2
Consider following output.
Find the missing statement in the following program to get above output.
import java.awt.*;
class AWTMenu extends Frame
{
public static void main(String args[])
{
AWTMenu m=new AWTMenu();
m.setVisible(true);
MenuBar mb=new MenuBar();
m.setMenuBar(mb);
1033 Menu hmenu= new Menu("Help");
Menu jmenu=new Menu("Justify");
mb.add(hmenu);
MenuItem center=new MenuItem("Center");
MenuItem left=new MenuItem("Left");
MenuItem right=new MenuItem("Right");
jmenu.add(center);
jmenu.add(left);
jmenu.add(right);
}
}

A. hmenu.add(jmenu);

B. mb.add(jmenu);

C. mbr.add(jmenu);

D. m.add(jmenu);

Answer optionb

Marks: 2

Consider the following code.Select proper method to handle event.


import java.applet.*;
import java.awt.*;
import java.awt.event.*;

/*
<applet code="AppletKeyListener.class" width="300" height="300">
</applet>
*/
public class AppletKeyListener extends Applet implements KeyListener
{
char ch;
String str;
public void init()
{
addKeyListener(this);
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
1034
}
public void ____________________________
{
ch = e.getKeyChar();
if(ch == 'm'|| ch == 'M')
str = "Good Morning";
else if(ch == 'a'||ch=='A')
str = "Good Afternoon";
else if(ch == 'e'||ch=='E')
str = "Good Evining";
else if(ch == 'n'||ch=='N')
str = "Good Night";
else str = "Type only other letter";
repaint();
}
public void paint(Graphics g)
{
g.drawString(str, 100, 150);
showStatus("You typed " + ch + " character");
}
}

A. keyActivated(KeyEvent e)

B. KeyActivated(KeyEvent e)

C. keyTyped(KeyEvent e)

D. KeyType(KeyEvent e)

Answer optionc

Marks: 2
Select the missing statement in the program to get correct output.
import java.awt.*;
import javax.swing.*;
/* <applet code="SqNoDemo" width=300 height=100>
</applet>
*/
public class SqNoDemo extends JApplet implements ActionListener
{
Button b1;
TextField t1,t2;
Label l1,l2;
public void init()
{
t1=new TextField(5);
t2=new TextField(5);
l1=new Label("Enter Number");
l2=new Label("Square of Number");
1035 b1=new Button("Submit");
add(l1);
add(t1);
add(l2);
add(t2);
}
public void actionPerformed(ActionEvent ie)
{

if(ie.getSource()==b1)
{
int no=Integer.parseInt(t1.getText());
int sq=no*no;
t2.setText(Integer.toString(sq));
}
}
}

A. import java.awt.event.*;

B. b1.addActionListener(this);

C. add(b1);

D. All the above

Answer optiond

Marks: 2

1036 Select the proper InetAddress factory method.

A. String InetAdress getHostAddress()

B. static InetAddress getHostName()

C. static InetAddress getLocalHost()

D. string getLocalHostName()

Answer optionc

Marks: 2

1037 Methods such as next(),previous(),last(),first() are of which interface?

A. ResultSet

B. ResultSetMetaData

C. ResultData

D. PreparedStatement

Answer optiona

Marks: 2

1038 Task performed by filter is

A. Logging and auditing.

B. Data compression.

C. Authentication and blocking of request.

D. All the above

Answer optiond

Marks: 2

1039 What is the difference between cookies and Httpsession?


A. Cookies works at clientside whereas HttpSession works at serverside.

B. Cookies works at serverside whereas HttpSession work at clientside.

C. Both are same

D. None of above

Answer optiona

Marks: 2

What will be the o/p of following jsp code?


<%= if (Math.random()<0.5)%>
1040 hello
<%=} else { %>
hi <%}%>

The browser will print either hello or hi based upon the return
A. value of random.

B. The string hi will always get printed.

C. The string hello will always get printed.

D. The JSP file will not compile.

Answer optiond

Marks: 2

Consider the following program


What will be displayed in the output?
import java.awt.*;
import javax.swing.*;
/* <applet code="JTabbedPaneDemo" width=300 height=100>
</applet>
*/
public class JTabbedPaneDemo extends JApplet
{
public void init()
{
JTabbedPane jtp=new JTabbedPane();
jtp.addTab("Fruit",new FruitPanel());
jtp.addTab("Color",new ColorPanel());
jtp.addTab("Vegitables",new VegitablePanel());
getContentPane().add(jtp);
jtp.removeAll();
}
}
class FruitPanel extends JPanel
{
public FruitPanel()
{
JButton b1=new JButton("Apple");
add(b1);
JButton b2=new JButton("Mango");
add(b2);
1041 JButton b3=new JButton("Banana");
add(b3);
}
}
class ColorPanel extends JPanel
{
public ColorPanel()
{
JButton b1=new JButton("Red");
add(b1);
JButton b2=new JButton("Blue");
add(b2);
JButton b3=new JButton("Green");
add(b3);
}
}
class VegitablePanel extends JPanel
{
public VegitablePanel()
{
JButton b1=new JButton("Potato");
add(b1);
JButton b2=new JButton("Brinjal");
add(b2);
JButton b3=new JButton("Tomato");
add(b3);
}
}

A. Applet containing fruit panel,color panel and vegitable panel.

B. Applet containing only color panel

C. Applet containing vegitable panel

D. Applet without any controls.

Answer optiond

Marks: 2
Consider the following program.Find the listener implemented by applet.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="Loan" width=200 height=300>
</applet>
*/
public class Loan extends Applet implements _________________________________
{
double p,r,n,total,i;
String param1;
boolean month;
Label l1,l2,l3,l4;
TextField t1,t2,t3,t4;
Button b1,b2;
CheckboxGroup cbg;
Checkbox c1,c2;
String str;
public void init()
{
l1=new Label("Balance Amount",Label.LEFT);
l2=new Label("Number of Months",Label.LEFT);
l3=new Label("Interest Rate",Label.LEFT);
l4=new Label("Total Payment",Label.LEFT);
t1=new TextField(5);
t2=new TextField(5);
t3=new TextField(15);
t4=new TextField(20);
b1=new Button("OK");
b2=new Button("Delete");
cbg=new CheckboxGroup();
c1=new Checkbox("Month Rate",cbg,true);
c2=new Checkbox("Annual Rate",cbg,true);
t1.addActionListener(this);
t2.addActionListener(this);
t3.addActionListener(this);
t4.addActionListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
c1.addItemListener(this);
1042 c2.addItemListener(this);
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(l4);
add(t4);
add(c1);
add(c2);
add(b1);
add(b2);
}
public void itemStateChanged(ItemEvent ie)
{
}
public void actionPerformed(ActionEvent ae)
{
str=ae.getActionCommand();
if(str.equals("OK"))
{
p=Double.parseDouble(t1.getText());
n=Double.parseDouble(t2.getText());
r=Double.parseDouble(t3.getText());
if(c2.getState())
{
n=n/12;
}
i=(p*n*r)/100;
total=p+i;
t4.setText(" "+total);
}
else if(str.equals("Delete"))
{
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
t4.setText(" ");
}
}
}

A. AdjustmentListener

B. ActionListener

C. ItemListener

D. Both B and C

Answer optiond

Marks: 2
Consider the following program
Find the error in program to get correct output.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/* <applet code = "MouseEvent" width = 400 height = 200> </applet> */
public class Mouseevent extends Applet
{
int x=0;
int y=0;
public void init()
{
addMouseListener(new mymouselistener());
}
public void start()
1043 {
}
public void paint(Graphics g)
{ g.drawString("www.msbte.com",x,y);
}
public class mymouselistener extends WindowAdapter
{
public void mouseClicked(MouseEvent e)
{
x = e.getX();
y = e.getY();
repaint();
}
}
}

A. Error in init() method

B. Error in start() method

C. Error in paint() method

D. Error in mymouselistener class

Answer optiond

Marks: 2

For the following code select the listener implemented by class


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/* <applet code="JRadioEvent" width=300 height=100>
</applet>
*/

public class JRadioEvent extends JApplet implements ______________


{
ButtonGroup grp;
JRadioButton red,pink,green;
JTextArea ta;
public void init()
{
setLayout(new FlowLayout());
ta=new JTextArea(5,10);
setupButtons();
addListeners();
add(red);
add(pink);
add(green);
add(ta);
}
public void setupButtons()
{
red=new JRadioButton("Red");
1044 pink=new JRadioButton("Pink");
green=new JRadioButton("Green");
grp=new ButtonGroup();
grp.add(red);
grp.add(pink);
grp.add(green);
}
public void addListeners()
{
red.addItemListener(this);
pink.addItemListener(this);
green.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
Object src=ie.getSource();
if(ie.getStateChange()==ItemEvent.SELECTED)
{
if(src==red)
ta.append("We like Red\n");
else if(src==pink)
ta.append("We like Pink \n");
else
ta.append("We like Green \n");
}
}
}

A. ActionListener

B. ComponentListener

C. ItemListener

D. MouseListener
Answer optiona

Marks: 2

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
{

1045 InetAddress ip=InetAddress.****************

System.out.println("Host Name: "+ip.getHostName());


System.out.println("IP Address: "+ip.getHostAddress());

}
catch(Exception e)
{
System.out.println(e);
}
}
}

A. getByName();

B. getByName("www.msbte.com");

C. getName( );

D. getName("www.msbte.com");

Answer optionb

Marks: 2

Consider the following program.What shoud be added to the program to get the correct output.
import java.sql.*;

public class Prepare_Demo


{
public static void main(String[] args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:DATA");
PreparedStatement ps = con.prepareStatement("insert into User (ID,Name1,City,Age)values(?,?,?,?)");
1046 ps.setInt(1,20);
ps.setString(2, "Abc");
ps.setInt(4,31);
ps.setString(3, "Pune");
System.out.println("inserted");
con.close();
}
catch (Exception e)
{
System.out.println(e);
}
}
}

A. ps.executeQuery();

B. ps.executeUpdate();

C. ps.execute();

D. ps.executeInsert();

Answer optionb

Marks: 2
Consider the following code, What should be the correction done in the program to get correct output.

import java.sql.*;

class CreateDemo
{
public static void main(String[] args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:DATA");
Statement st=con.createStatement();
String sql="create table Employee(Name char,Age int)";
1047 st.execute(sql);
System.out.println("created");

catch(SQLException e)
{
System.out.println(e);
}
catch(Exception e)
{
System.out.println(e);
}

}
}

A. Missing {

B. Missing semicolon

C. Missing Statement

D. Missing }

Answer optiond

Marks: 2

Consider the following code, Find the missing statement to get correct output.

public class DeleteRecords


{

public static void main(String[] args)


{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:DATA");
String query = "delete from tannis";
1048 PreparedStatement pstmt = con.prepareStatement(query);
pstmt.executeUpdate();
pstmt.close();
con.close();
}
catch (Exception e)
{
System.out.println(e);
}

}
}

A. Missing import java.sql.Connection;

B. Missing import java.sql.DriverManager;

C. Missing import java.sql.PreparedStatement;

D. All the above

Answer optiond

Marks: 2
Consider the given code.What should be the correction in the program to get correct output?
import java.sql.*;
public class SelectDemo
{
public static void main(String[] args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:DATA");
Statement s = con.createStatement();
s.execute(query);
ResultSet rs = s.getResultSet();
while(rs.next())
1049 {
System.out.print("Id : "+rs.getString(1));
System.out.print(" , Name : "+rs.getString(2));
System.out.print(" , City : "+rs.getString(3));
System.out.println(" and Age : "+rs.getString(4));
}
s.close();
con.close();
}
catch (Exception e)
{
System.out.println("Exception : "+e);
}
}
}

A. Type of exception not mentioned

B. Error in catch block

C. Error in close

D. Error in loop

Answer optiona

Marks: 2

Consider the following code.Select the missing statement to get proper output.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CookEx extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
1050 String name=req.getParameter("name");
String value=req.getParameter("age");
Cookie c=new Cookie(name,value);
String p1=c.getName();
String p2=c.getValue();
out.println("Name:" +p1);
out.println("Age:"+p2);
out.println(" ");
}

A. req.addCookie(c);

B. res.addCookie(c);

C. addCookie(c);

D. res.addCookie();

Answer optionb

Marks: 2

Consider the following code.What should be added to the program to get correct output..
<%@ page language="java"%>
<%@ page import="java.lang.*"%>
<html>
<body>
<H1><center>Result for <%=request.getParameter("a1")%></center></H1>
<%
int i=Integer.parseInt(request.getParameter("t1"));
int j=Integer.parseInt(request.getParameter("t2"));
int k=0;
String str=request.getParameter("a1");
1051
if(str.equals("add"))
k=i+j;
if(str.equals("mul"))
k=i*j;
if(str.equals("div"))
k=i/j;

Result is <%=k%>
</body>
</html>

A. <%

B. <
C. %>

D. >

Answer optionc

Marks: 2

1052 You Can set the alignment of the string within the label by calling _______________________

A. getAlignment()

B. setText()

C. setAlignment()

D. getText()

Answer optionc

Marks: 1

1053 A____________ is component that presents a rectangular area in which a component may be viewed

A. Tabbed Pane

B. Scroll Pane

C. Glass Pane

D. All of above

Answer optionb

Marks: 1

1054 To retrieve the current state of a check box,call ___________________

A. setState()

B. setLabel()

C. getState()

D. getLabel

Answer optionc

Marks: 1

1055 ________________ lays out components in a two dimensional grid

A. FlowLayout

B. GridLayout

C. CardLayout

D. BorderLayout

Answer optionb

Marks: 1

1056 windowEvent is a subclass of ________________________

A. component

B. EventObject

C. TextEvent

D. Jcomponent()

Answer optionb

Marks: 1

1057 Which class is used to designed to be a "listener" which waits for client to connect before doing anything.

A. Socket
B. Datagram

C. ServerSocket

D. Both A & C

Answer optionc

Marks: 1

1058 Every driver must provide a class that should implement the __________________

A. Driver interface

B. Device manager

C. connection

D. url

Answer optiona

Marks: 1

1059 Choose correct scopes into JSP

A. page,request,session,application

B. page,response,session,application

C. page,request,response,session

D. None of these

Answer optiona

Marks: 1

1060 ______________ class provides functionality that makes it easy to handle requests and responses.

A. ServetRequest

B. ServletResponse

C. GenericServlet

D. None of these

Answer optionc

Marks: 1

1061 The__________________package contains a number of interfaces and classes that are commonly used by servlet developers

A. javax.servelet.server

B. javax.servet.http

C. javax.servlet.session

D. javax.servlet.genericServlet

Answer optionb

Marks: 1
Select the missing statement in given code
import java.applet.*;
import java.awt.event.*;
import java.awt.*;
/*<applet code=event1.class width=250 height=250>
</applet>*/
public class event1 extends Applet implements ActionListener
{
TextField t1;
TextField t2;
TextField t3;
Button b;
public void init()
{
Label num1=new Label("enter number in textfield");
Label num2=new Label("enter number in textfield");
Label num3=new Label("addition of two number");
t1=new TextField();
t2=new TextField();
t3=new TextField();
b=new Button("add");
1062
setLayout(new GridLayout(4,2));
add(num1);
add(t1);
add(num2);
add(t2);
add(num3);
add(t3);
add(b);
b.addActionListener(this);
}
public void ___________
{
if(ae.getSource()==b)
{
int n1=Integer.parseInt(t1.getText());
int n2=Integer.parseInt(t2.getText());
int sum=n1+n2;
t3.setText(Integer.toString(sum));
}
}
}

A. actionPerformed(ActionEvent ae)

B. itemStateChanged(ActionEvent ae)

C. InputEvent(ActionEvent ae)

D. Both A&b

Answer optiona

Marks: 2

1063 which of the following is not type of keyEvent class

A. KEY_PRESSED

B. KEY_RELEASED

C. KEY_DOWN

D. KEY_TYPED

Answer optionc

Marks: 2

1064 Which of the follwing method is used for sending SQL statements

A. Statement

B. Callablestatement()

C. Preparedstament

D. Both C & B

Answer optiona

Marks: 2

1065 The difference between servelets and JSP is the

A. Translation

B. Compliation

Syntax
C.

D. Both A & B
Answer optionc

Marks: 2

Consider the following program. Find which statement contains error.


import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class choicedemo1 extends Applet implements ItemListener


{
Choice os,browser;
String msg="";

public void init()


{
os=new Choice();
browser =new Choice();

os.add("windows7");
os.add("windowsXP");
os.add("windows8");
os.add("windows98");

browser.add("netscape 3.x");
browser.add("netscape 4.x");
browser.add("netscape 5.x");
browser.add("netscape 6.x");
1066 browser.add("Internet Explorer 4.0");
browser.add("Internet Explorer 5.0");
browser.add("Internet Explorer 6.0");
browser.add("Lynx 2.4");
browser.select("Netscape 4.x");

add(os);
add(browser);

os.addItemListener(this);
browser.addItemListener(this);
}

public void itemStateChanged(ItemEvent ie)


{
repaint();
}
public void paint(Graphics g)
{
msg="Current os";
msg+=os.getSelectedItem();
g.drawString(msg,6,120);
msg="Current browser";
msg+=browser.getSelectedItem();
g.drawString(msg,6,140);
}
}

A. Exception type is wrong.

B. Applet Tag not decleared in code

C. Creation of object is not correct.

D. Use of created object not correct

Answer optionb

Marks: 2

Consider the following program


What will be displayed in the output?
import java.sql.*;
class ConnectionTest
{
public static void main(String srgs[])
{
try
{
Class.forname("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded");
1067 String url="jdbc:odbc:xyz";
Connection con=DriverManager.getConnection(url);
System.out.println("connection to database created");
}
catch(sQLException e)
{
System.out.pritln("SQL error");
}
catch(Exceptionn e)
{
System.out.println("error");
}

A. Driver loaded

B. Driver loaded Connection to database created

C. SQL error

D. SQLException

Answer optionb
Marks: 2

In following Java program fill statement showing _______________________.Select any one option from given options

import java.sql.*;
class Testdemo
{
public static void main(String srgs[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded");
String url="jdbc:odbc:info";
Connection con=DriverManager.getConnection(url);
System.out.println("connection to database created");
Statement smt=con.createStatement();
System.out.println("Statement object created");
1068 String sql="Select Name,Age from Amol";
ResultSet result=smt._______________________
String text="";
while(result.next());
{
text +result.getString(1)+""+results.getInt(2)+'\n';
}
System.out.println(text);
}
catch(sQLException e)
{
System.out.pritln("SQL error");
}
catch(Exceptionn e)
{
System.out.println("error");
}

A. createStatement();

B. executeQuery(sql);

C. getConnection()

D. None of theses

Answer optionb

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;
class Testdemo
{
public static void main(String srgs[])
{
try
{
Class.forname("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded");
String url="jdbc:odbc:info";
Connection con=DriverManager.getConnection(str);
System.out.println("connection to database created");
Statement smt=con.createStatement();
System.out.println("Statement object created");
1069 String sql="Select Name,Age from Amol";
ResultSet result=smt._______________________
String text="";
while(result.next())
{
text +result.getString(1)+""+results.getInt(2)+'\n';
}
System.out.println(text);
}
catch(sQLException e)
{
System.out.pritln("SQL error");
}
catch(Exceptionn e)
{
System.out.println("error");
}

A. Missing semicolon

B. Missing {

C. Missing } and Incomplete ResultSet Statement

D. Missing statement.

Answer optionc

Marks: 2
In following Java program which package is used

public class HellosServlet extends HttpSevlet


{
public void doPost(HttptReuest request,httpResponse response)
trows ServletException,IOException
{
string color=request.getParameter("color")
responce.setConteType("text/html");
PrintWriter pw=responce.getWriter();
pw.println("<B>The selected color is:");
pw.println(color);
pw.close();
}
1070 }
<html>
<body>
<form name="Form1"
method="post"
action:""http://localhost:8080/examples/servlet/HelloServlet">
<B>Color:</B>
<select name="color"size="1">
<option value="Red">Red</option>
</select>
<br><br>
<input type=submit value="submit">
</form>
</body>
</html>

import java.io.*;
A. import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
B. import javax.servlet.*;

import java.io.*;
C. import javax.servlet.*;
import javax.servlet.GenericServlet.*;

import java.io.*;
D. import java.servlet.*;
import java.servlet.http.*;

Answer optiona

Marks: 2

1071 Why we use Applet?

A. to display a GUI

B. to display a WINDOW

C. None of the above

D. Option A) and B) FROM this

Answer optiond

Marks: 1

1072 To draw a line in applet, we use following method

A. drawLine()

B. DRAWLINE()

C. DrawLine()

D. None of this

Answer optiona

Marks: 1

1073 For adding controls to a window, we use following method

A. remove()

B. ADD()

C. add()

D. REMOVE()

Answer optionc

Marks: 1

1074 The delegation model is used as a standard for


A. Event Listening

B. controlling an applet

C. to make GUI

D. To arrange componenets

Answer optiona

Marks: 1

1075 The MouseListener interface is used to make mouse handling

A. True

B. False

C. CAN'T PREDICT

D. NONE OF THESE

Answer optiona

Marks: 1

1076 To write event driven programs using AWT or Swings, Use?

A. Listener Interfaces

B. Adapter Classes

C. None of this

D. Option A and B

Answer optiond

Marks: 1

1077 A Java program cannot directly communicate with an ODBC driver because

A. ODBC written in C language

B. ODBC written in C++ language

C. ODBC written in C# language

D. ODBC written in Visual Basic language

Answer optiona

Marks: 1

1078 The -----------------method executes a simple query and returns a single Result Set object

A. executeUpdate()

B. executeQuery()

C. execute()

D. noexecute()

Answer optionb

Marks: 1

1079 To create group of check boxes ,Use?

A. CheckBox

B. CheckBoxGroup

C. Allof this

D. None of this

Answer optionb

Marks: 2
1080 To create a compact,multiple-choice,scrolling selection list,Use?

A. Choice

B. List

C. CheckBox

D. Scrollbar

Answer optionb

Marks: 2

1081 Select the one correct answer. The default alignment of buttons in Flow Layout is ...

A. LEFT

B. CENTRE

C. RIGHT

D. The alignment must be defined when using the FlowLayout Manager.

Answer optionb

Marks: 2

1082 To position components in an applet window? Use

A. Grid

B. Layout Mangager

C. Flow

D. Border

Answer optionb

Marks: 2

1083 JSP includes a mechanism for defining --------------- or custom tags.

A. static attributes

B. local attributes

C. global attributes

D. dynamic attributes

Answer optiond

Marks: 2

1084 To implement a single �line text area entry area, Use?

A. Choice

B. List

C. TextField

D. TextArea

Answer optionc

Marks: 2

1085 Button control implements following Listener interface?

A. ItemLIstener

B. ActionListener

C. FlowListener

D. Adapter

Answer optionb
Marks: 2

1086 ItemListener Interface is applicable to?

A. CheckBox

B. Choice

C. List

D. All of this

Answer optiond

Marks: 2

1087 KeyListener interface is applicable to keyboard only?

A. True

B. False

C. None of this

D. All of this

Answer optiona

Marks: 2

1088 Servlets play important role in MVC Architecture as -------------

A. Controller

B. None of the above

C. View

D. Model

Answer optiona

Marks: 2

1089 How many bits are in a single IPv4 address?

A. 8

B. 16

C. 32

D. 64

Answer optionc

Marks: 1

1090 What MySQL property is used to create a surrogate key in MySQL?

A. UNIQUE

B. SEQUENCE

C. AUTO_INCREMENT

D. None of the above -- Surrogate keys are not implemented in MySQL.

Answer optionc

Marks: 2

What is the length of the application box made by this program?

import java.awt.*;

import java.applet.*;

1091 public class myapplet extends Applet {

Graphic g;

g.drawString("A Simple Applet", 20, 20);

}
A. 20

B. Default value

C. Compilation Error

D. Runtime Error

Answer optionc

Marks: 2

1092 Which JDBC driver Types are for use over communications networks?

A. Type 3 only

B. Type 4 only

C. Both Type 3 and Type 4

D. Neither Type 3 nor Type 4

Answer optionc

Marks: 2

1093 Which JDBC driver Type(s) can be used in either applet or servlet code?

A. Both Type 1 and Type 2

B. Type 4 only

C. Both Type 1 and Type 3

D. Both Type 3 and Type 4

Answer optiond

Marks: 2

1094 Which of the following contain a Menubar?

A. A Panel

B. A Frame

C. An Applet

D. A Menubar

Answer optionb

Marks: 1

1095 In Swing, tables are implemented by the ______________ class

A. JPanel

B. JTable

C. JTree

D. JTooltip

Answer optionb

Marks: 1

1096 In which of the following model, java applet or application directly communicates with data source?

A. Three tier

B. N tier

C. Two tier

D. Four tier

Answer optionc

Marks: 1
1097 A servlet is an instance of___________.

A. the Object class

B. the Applet class

C. the HttpServlet class

D. Cookie class

Answer optionc

Marks: 1

1098 By default, how long does a cookie last?

A. 24 hours

B. 30 days

C. 365 days

D. By default, a newly created cookie persists until the browser exits.

Answer optiond

Marks: 1

1099 By default, Tomcat runs on port ___________.

A. 8080

B. 8050

C. 8000

D. 8888

Answer optiona

Marks: 1

1100 Different methods used by cookie class are

A. getName()

B. getPath()

C. getValue()

D. All of the above

Answer optiond

Marks: 1
Select the missing statement in given code
import java.awt.*;
import java.applet.*;
/*
<APPLET Code="ActionListenerTest" Width=300 Height=300>
</APPLET>
*/

public class ActionListenerTest extends Applet implements ActionListener


{
Button b1,b2,b3,b4;
public void init()
{
Font f=new Font("New Times Roman",Font.BOLD,14);

b1=new Button("RED");
b2=new Button("BLUE");
b3=new Button("GREEN");
b4=new Button("YELLOW");

b1.setFont(f);
b2.setFont(f);
b3.setFont(f);
b4.setFont(f);

add(b1,"North");
add(b2,"South");
add(b3,"East");
1101 add(b4,"West");

b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);

}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
b1.setBackground(Color.red);
}
if(ae.getSource()==b2)
{
b2.setBackground(Color.blue);
}
if(ae.getSource()==b3)
{
b3.setBackground(Color.green);
}
if(ae.getSource()==b4)
{
b4.setBackground(Color.yellow);
}

}
}

A. java.awt.event.*

B. setLayout(new BorderLayout());

C. b1.addActionListener(this);

D. All of the above

Answer optiond

Marks: 2

1102 The methods of Statement interface are

A. ResultSet executeQuery()

B. executeUpdate()

C. execute()

D. All of the above

Answer optiond

Marks: 2

1103 The __________ method can be used on a ___________ object to create its meta data object

A. getMetaData(),ResultSet

B. executeQuery(),ResultSet

C. executeUpdate(),ResultSet

D. execute(),ResultSet

Answer optiona

Marks: 2
1104 Which of the following query is used for SELECT query?

A. execute()

B. execute(String sql)

C. executeUpdate(String sql)

D. executeQuery(String sql)

Answer optiond

Marks: 2

1105 Which of the following is not a standard method called as part of JSP life cycle

A. jspInit()

B. jspService()

C. _jspService()

D. jspDestroy()

Answer optionb

Marks: 2

Find the statement missing in the below code


import java.io.*;
import javax.servlet.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
1106 throws ServletException, IOException {
PrintWriter out = response.
out.println("Hello World");
}
}

A. import javax.servlet.http.*;

B. getWriter()

C. None

D. both A and B

Answer optiond

Marks: 2

Observe the following code


import java.awt.*;
import java.applet.*;

/*
<APPLET Code="TextFieldPassword" Width=500 Height=200>
</APPLET>
*/

public class TextFieldPassword extends Applet


{
public void init()
{
1107 Label lblName = new Label("enter name");
Label lblPasswd = new Label("enter password");

TextField txtName = new TextField("your name here", 20);


TextField txtPasswd = new TextField(20);

add(lblName);
add(txtName);
add(lblPasswd);
txtPasswd.setEchoChar('*');
add(txtPasswd);
}
}

A. The output is obtained in Frame with two labels and two textfields

B. The output is obtained in Applet with two labels and two textfields

C. The output is obtained in Applet with card layout with two labels and two textfields

D. The output is obtained in Window with two labels and two textfields

Answer optionb

Marks: 2
Select the missing statement in the program at ----------------------------- to get the following output
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*
<APPLET Code="EventExample" Width=200 Height=250>
</APPLET>
*/

public class EventExample extends Applet implements ActionListener


{
Button b1;
TextField t1;
public void init()
1108 {
b1=new Button("Message");
t1=new TextField(35);
add(t1);
add(b1);
----------------------------------
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
t1.setText("Event Handling in Java");
}
}
}

A. b1.addActionListener(this)

B. b1.addMouseMotionlistner(this)

C. b1.addComponentListner(this)

D. b1.addTextListner(this)

Answer optiona

Marks: 2

For the following code select the method that can be used to handle event.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*
<APPLET Code="ActionListenerTest" Width=300 Height=300>
</APPLET>
*/

public class ActionListenerTest extends Applet implements ActionListener


{
Button b1,b2,b3,b4;
public void init()
{
Font f=new Font("New Times Roman",Font.BOLD,14);

b1=new Button("RED");
b2=new Button("BLUE");
b3=new Button("GREEN");
b4=new Button("YELLOW");

b1.setFont(f);
b2.setFont(f);
b3.setFont(f);
b4.setFont(f);

setLayout(new BorderLayout());

add(b1,"North");
add(b2,"South");
1109
add(b3,"East");
add(b4,"West");

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);

}
public void _____________(ActionEvent ae)
{
if(ae.getSource()==b1)
{
b1.setBackground(Color.red);
}
if(ae.getSource()==b2)
{
b2.setBackground(Color.blue);
}
if(ae.getSource()==b3)
{
b3.setBackground(Color.green);
}
if(ae.getSource()==b4)
{
b4.setBackground(Color.yellow);
}

}
}

A. actionPerformed(ActionEvent ae)
B. adjustmentPerformed(AdjustmentEvent ae)

C. itemStateChanged(ActionEvent ie)

D. itemStateChanged(ItemEvent ie)

Answer optiona

Marks: 2

Fill in the blank from the given option


import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class CircleListener extends MouseAdapter
{
private int radius = 25;
1110 public void __________________(MouseEvent event)
{
Applet app = (Applet)event.getSource();
Graphics g = app.getGraphics();
g.fillOval(event.getX()-radius,event.getY()-radius,2*radius,2*radius);
}
}

A. mousePressed()

B. mouseReleased()

C. mouseDragged()

D. mouseClick()

Answer optiona

Marks: 2

Consider the following program


What correction should be done in the program to get correct output?
import java.applet.*;
import java.awt.event.*;
/*
<APPLET Code="SimpleKey" Width=200 Height=250>
</APPLET>
*/
public class SimpleKey extends Applet implements KeyListener
{
String msg="";
int X=10,Y=20;
public void init()
{
addKeyListener(this);
requestFocus();
1111 }
public void keyPressed(KeyEvent ke)
{
showStatus("Key Down");
}
public void keyReleased(KeyEvent ke)
{
showStatus("Key Up");
}
public void keyTyped(KeyEvent ke)
{
msg +=ke.getKeyChar();
repaint();
}
public void paint (Graphics g)
{
}

A. Missing {

B. Missing }

C. Missing statement

D. Missing semicolon

Answer optionb

Marks: 2
Consider the following program
What correction should be done in the program to get correct output?

import java.sql.*;
import java.io.*;
class Create
{
public static void main(String[] args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
1112 Connection con = DriverManager.getConnection("jdbc:odbc:oraodbc","scott","tiger");
Statement stmt = con.createStatement();
stmt.executeUpdate("create table
customers(CUST_NUM int, COMPANYchar(20), CUST_REP int, CREDIT_LIMIT number(7,2))");
stmt.close();
con.close();
System.out.println("Table Successfully created");
}
catch(Exception e)
{
e.printStackTrace();
}
}

A. Missing statement

B. Missing semicolon

C. Missing {

D. Missing }

Answer optiond

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;
import java.io.*;
class SelectRow
{

{
ResultSet rs;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:oraodbc","scott","tiger");
Statement stmt = con.createStatement();
1113 rs = stmt.executeQuery("select * from CUSTOMERS");
System.out.println("CUST_NUM" + "\tCOMPANY" + "\t\tCUST_REP" + "\tCREDIT_LIMIT");
while(rs.next())
{
System.out.println(rs.getInt("CUST_NUM") + "\t\t" + rs.getString("COMPANY")+ "\t"+ rs.getInt("CUST_REP") + "\t" +
rs.getInt("CREDIT_LIMIT"));
}
stmt.close();
con.close();
System.out.println("Records successfully selected");
}catch(Exception e)
{
e.printStackTrace();
}
}

A. Missing semicolon

B. Missing main()

C. Missing }

D. Missing {

Answer optionb

Marks: 2
Consider the following program.
What should be the correction done in the program to get correct output?
import java.sql.*;
import java.io.*;
class Deleterecord
{
public static void main(String[] args)
{
ResultSet rs;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:oraodbc","scott","tiger");
Statement stmt = con.createStatement();
stmt.executeUpdate("delete from CUSTOMERS where CUST_NUM = 101");
rs = stmt.executeQuery("select * from customers");
1114 System.out.println("CUST_NUM" + "\tCOMPANY" + "\t\tCUST_REP" + "\tCREDIT_LIMIT");
while(rs.next())
{
int no=rs.getInt(1);
String company=rs.getString(2);
int rep=rs.getInt(3);
double credit=rs.getDouble(4);
System.out.println( no + "\t\t"+company + "\t" + rep + "\t\t" + credit);
}
stmt.close();
System.out.println("Record Successfully deleted");
}catch(Exception e)
{
e.printStackTrace();
}
}
}

A. Error in main()

B. Erron in connection statement

C. Missing close statement

D. Missing loop

Answer optionc

Marks: 2

Consider the following program.Select the statement that should be added to the program to get correct output.

import java.sql.*;
import java.io.*;
class Drop
{
public static void main(String[] args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:oraodbc","scott","tiger");
Statement stmt = con.createStatement();
stmt.executeUpdate("drop table CUSTOMERS");
ResultSet rs = stmt.executeQuery("select * from tab");
1115 System.out.println("TNAME" + "\t\tTABTYPE" + "\tCLUSTERID");
while(rs.next())
{
String name = rs.getString(1);
String type = rs.getString(2);
String clus = rs.getString(3);
System.out.println( name + "\t\t" + type + "\t" + clus);
}
con.close();
System.out.println("Customer Table successfully dropped");
} catch(Exception e)
{
e.printStackTrace();
}
}
}

A. stmt.close()

B. stmt.executeUpdate()

C. con.close()

D. rs.getString()

Answer optiona

Marks: 2
Consider the following program.
What should be the correction done in the program to get correct output?
class PrepareSt
{
public static void main(String[] args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:oraodbc","scott","tiger");
PreparedStatement ps = con.prepareStatement("Select * from CUSTOMERS where CREDIT_LIMIT >= ?");
ps.setInt(1,50000);
ResultSet rs=ps.executeQuery();
System.out.println("CUST_NUM" + "\tCOMPANY" +"\t\tCUST_REP" + "\tCREDIT_LIMIT");
while(rs.next())
1116 {
int no=rs.getInt(1);
String company=rs.getString(2);
int rep=rs.getInt(3);
double credit=rs.getDouble(4);
System.out.println(no+"\t\t"+company+"\t"+rep+"\t\t"+credit);
}
rs.close();
ps.close();
con.close();
}catch(Exception e)
{
e.printStackTrace();
}
}
}

A. Missing semicolon

B. Missing }

C. Missing {

D. Missing Package statement

Answer optiond

Marks: 2

Consider the following program. Identify the exception that might be thrown
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class GetCookiesServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)throws __________________{
Cookie[] cookies =request.getCookies();
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
1117 pw.println("<B>");
for(int i=0;i<cookies.length;i++)
{
String name=cookies[i].getValue();
pw.println("name=" + name +"; value = "+ value);
}
pw.close();
}
}

A. ServletException,MalformedURLException

B. ServletException,Arithmetic Exception

C. ServletException,UnknownHostException

D. ServletException,IOException

Answer optiond

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DateServlet extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException ,IOException {
HttpSession hs=request.getSession(true);
1118 response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.print("<B>";
Date date=(Date)hs.getAttribute("date");
if(date!=null) {
pw.print("Last access: " + date +"<br>");
}
date=new Date();
hs.setAttribute("date", date);
pw.println("Current date:" + date);
}

A. Missing statement

B. Missing semicolon
C. Missing packages

D. Missing }

Answer optiond

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
<%@ page import="hello.NameHandler" %>
<jsp:useBean id="mybean" scope="page"
class="hello.NameHandler" />
<jsp:setProperty name="mybean" property="*" />
<html>
<head><title>Hello, User</title></head>
<body bgcolor="#ffffff" background="background.gif">
<%@ include file="dukebanner.html" %>
<table border="0" width="700">
<tr>
<td width="150"> </td>
<td width="550">
<h1>My name is Duke. What�s yours?</h1>
</td>
</tr>
<tr>
1119 <td width="150" </td>
<td width="550">
<form method="get">
<input type="text" name="username" size="25">
<br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</td>
</tr>
</form>
<%
if ( request.getParameter("username") != null ) {
%>
<%@ include file="response.jsp" %>
<%
}
%>
</body>
</html>

A. Opening form tag is missing

B. Closing Table tag is missing

C. Closing body tag is missing

D. Closing Form tag is missing

Answer optionb

Marks: 2

1120 If _____________is manipulated AdjustmentEvent event will be notified .

A. CheckBox

B. ScrollBar

C. TextBox

D. Button

Answer optionb

Marks: 1

1121 Which of these is super class of WindowEvent class?

A. WindowEvent

B. ComponentEvent

C. ItemEvent

D. InputEvent

Answer optionb

Marks: 1

1122 Port Number for FTP is

A. 21

B. 23
C. 25

D. 80

Answer optiona

Marks: 1

1123 ODBC Drivers are platform _______________

A. Dependent

B. Indepndent

C. Dependent,Independent

D. All of above

Answer optiona

Marks: 1

1124 The ______________driver resolves JDBC call and makes equivalent ODBC Call

A. JDBC Native API

B. JDBC-Net pure java

C. 100% pure java

D. JDBC-ODBC bridge

Answer optiond

Marks: 1

1125 CGI was expensive in terms of ___________and _________to create separate process for each client reqest

A. Process ,time

B. Memory, Resource ,action

C. Process,Memory, Resource

D. None of the above

Answer optionc

Marks: 1

1126 Servlet are webpages generated by the web server In response to the requests send by the

A. server

B. client

C. DNS Server

D. http

Answer optionb

Marks: 1

1127 What is the purpose of ToggleButton?

A. On or Off Switch

B. To on switch

C. To off Switch

D. None Of This

Answer optiona

Marks: 2
Select the proper output for following code
import java.applet.Applet;

import java.awt.*;
import java.applet.*;
public class xyz extends Applet
{
public void init()
{
1128 Button b1= new Button("Yes");
add(b1);

Button b2= new Button("No");


add(b2);

}
}
/*<applet code=button.class height=200 width=200>
</applet>*/

A. A

B. B

C. C

D. D

Answer optiona

Marks: 2

1129 Http is which type of Protocol

A. Stateless

B. Network

C. Stateful

D. None Of this

Answer optiona

Marks: 2

1130 The Constructor of URL can throws an Exception called

A. MalFormedURLException

B. URLnotFound

C. URLException

D. URLSourceNotFound

Answer optiona

Marks: 2

1131 ResultSet is __________________Which Represents a data from database

A. Table of Data

B. function

C. database

D. Query

Answer optiona

Marks: 1

1132 getSessioin() is a method of __________ class.

A. HttpServletRequest

B. HttpSession

C. HttpServlet

D. None

Answer optiona

Marks: 2
Consider the following program Which statemnet is prepare for blank space
import java.applet.*;
import java.awt.*;

public class gridlayout extends Applet


{
int n=1;
public void init()
{

setFont(new Font("SansSerif",Font.BOLD,24));
1133 for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
______________________

n++;
}
}

}
}

A. add(new Button(""+n));

B. add(new Label());

C. add(button)

D. None of this

Answer optiona

Marks: 2

Select the missing in the program


import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class textfield extends Applet implements ActionListener


{
TextField nm,psw;
public void init()
{
Label nml=new Label("username:",Label.RIGHT);
Label pswl=new Label("password:",Label.RIGHT);
nm=new TextField(12);
1134 psw=new TextField(8);
Button b=new Button("submit");

add(nml);
add(nm);
add(psw);
add(b);
nm.addActionListener(this);
psw.addActionListener(this);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
repaint();
}
}

A. Missing in import classes

B. Method missing for password echo charachter

C. Missing ActionListener class

D. Method missing for password

Answer optionb

Marks: 2
Select the method used for Event Handle
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class no extends Applet implements ActionListener
{
String msg="";
Button b1,b2,b3;
public void init()
{
b1=new Button("Yes");
add(b1);
b2=new Button("No");
add(b2);
b3=new Button("Exit");
add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
}
1135 public void _______________
{
String str=ae.getActionCommand();
if(str.equals("Yes"))
{
msg="You pressed Yes.";
}
else if(str.equals("No"))
{
msg="You pressed No.";
}
if(str.equals("Exit"))
{
msg="You pressed Exit.";
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,6,100);}
}

A. actionPerformed(ActionEvent ae)

B. itemStateChanged(ActionEvent ie)

C. itemStateChanged(ItemEvent ie)

D. adjustmentPerformed(AdjustmentEvent ae)

Answer optiona

Marks: 2

Where to write query to delete records in the following program


import java.sql.*;
public class DeleteRecords
{
public static void main(String args[])
{
String s1;
int cnt=0;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers are properly loaded");
String url="jdbc:odbc:abcd";
Connection con=DriverManager.getConnection(url);
System.out.println("Connection Established");
1136 Statement st=con.createStatement();
st.executeUpdate();
con.close();
}
catch(SQLException e)
{
System.out.println("SQL Error Has Occured");

}
catch(Exception e)
{
System.out.println("Erroe");
}
}
}

A. As the parameter to create statement query

B. As a parameter to ExecuteUpdate Query

C. just to write the delete from table_name anywhere in program

D. None of above

Answer optionb

Marks: 2
What is missing in the following program?
import java.sql.*;
public class execute
{
public static void main(String args[])
{
try
{
String url="jdbc:odbc:abcd";
Connection con=DriverManager.getConnection(url);
System.out.println("Connection Established");
String sql="insert into student values(11,'Ramesh')";
Statement st=con.createStatement();
st.executeUpdate(sql);

1137 System.out.println("Data Inserted");

con.close();
}
catch(SQLException e)
{
System.out.println("SQL Error Has Occured");

}
catch(Exception e)
{
System.out.println("Error");
}
}
}

A. to register the driver

B. to create the connection with database

C. to close the connection

D. None of above

Answer optiona

Marks: 2

Consider the following program and identify the class at bank space
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Ser extends __________________


{
public void doGet(HttpServletRequest rq,HttpServletResponse res)
1138 throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<h1> hello </h1>");
out.println("hello");
out.close();
}
}

A. HttpServletRequest

B. HttpServlet

C. GenericServlet

D. Servlet

Answer optionb

Marks: 2

Which wrong method is used in following code


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class s extends HttpServlet {
protected void GenericServlet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException {
1139 response.setContentType("text/html");
PrintWriter pw=response.getWriter();
HttpSession session=request.getSession();
String id=session.getId();
pw.println("Session Id is: "+id);
}
}

A. GenericServlet(HttpServletRequest request,HttpServletResponse response)

B. .getId()

C. .getWriter();

D. UnknownHostException

Answer optiona
Marks: 2

1140 Which method is used to set label for Button B ?

A. B.setText(String s)

B. B.setLabel(String s)

C. B.getLabel()

D. B.getText()

Answer optionb

Marks: 1

1141 Which of the following control is not contained in AWT Package?

A. Label

B. Button

C. Checkbox

D. Scrollpane

Answer optiond

Marks: 1

1142 Program which executes applet is known as________

A. JVM

B. Virtual machine

C. Appletviewer

D. None of above

Answer optionc

Marks: 1

1143 Which of the following is used to interpret and execute Java Applet Classes hosted by HTML ?

A. Appletviewer

B. Appletscreen

C. Appletwatcher

D. Appletshow

Answer optiona

Marks: 1

1144 which of the following function is used to find the column count of the particular ResultSet ?

A. getMetaData()

B. MetaData()

C. getColumnCount()

D. getCount()

Answer optionc

Marks: 1

State true or false for the following statements in Java.


1145 i) Java beans slow down software development process.
ii) Java Servlets do not have built in multithreading feature.

A. i-false, ii-false

B. i-false, ii-true

C. i-true, ii-false

D. i-true, ii-true
Answer optiona

Marks: 1

1146 Why we need to write static keyword to main method ?

A. It gives access to other methods

B. It is in syntax

C. To create single copy

D. None of above

Answer optionc

Marks: 2

What will be the output of this program?

import java.net.*;

class networking {
1147
public static void main(String[] args) throws MalformedURLException {

URL obj = new URL("http://www.msbte.com/javamcq");

System.out.print(obj.toExternalForm()); } }

A. msbte

B. msbte.com

C. www.msbte.com

D. http://www.msbte.com/javamcq

Answer optiond

Marks: 2

import java.net.*;
class networking {
public static void main(String[] args) throws Exception {
URL obj = new URL("http://www.sanfoundry.com/javamcq");
1148 URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType());
} }
Note: Host URL is written in html and simple text.

A. html

B. text

C. none

D. text/html

Answer optiond

Marks: 2

1149 The client request a connection to a server using the following statement.

A. Socket s=new Socket(ServerName,port);

B. Socket s=serverSocket.accept();

C. Socket s=serverSocket.getSocket();

D. Socket s=new Socket(ServerName);

Answer optiona

Marks: 2
Output of the following program
import java.sql.*;
Class ExecuteUpdateTest
{
public static void main(String argu[])
{
try
{
int I;
Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver�);
System.out.println(�Driver Loaded�);
String url=�jdbc:odbc:xyz�;
Connection con=DriverManager.getConnection(url);
System.out.println(�Connection to database created�);
Statement state=con.createStatement();
System.out.println(�Statement object created�);
String sql=�Insert into tanni values(�Tanmy�,2)�;
1150 I=state.executeUpdate(sql);
System.out.println(�Record inserted �+i);
String sql1=�Insert into tanni values(�Raddhi�,2)�;
I=state.executeUpdate(sql1);
System.out.println(�Record inserted�+i);
String sql2=�Insert into tanni values(�Siddi�,2)�;
I=state.executeUpdate(sql2);
System.out.println(�Record inserted�+i);
}
catch(SQLException e)
{
System.out.println(�SQL error�);
}
catch(Exception e){
System.out.println(�SQL error�);
}
}
}

Driver loaded
Connection to database created
Statement object created
A. Record inserted 1
Record Inserted 2
Record Inserted 3

Driver loaded
Record inserted 1
Record Inserted 2
B. Connection to database created
Statement object created
Record Inserted 3

Record inserted 1
Record Inserted 2
Connection to database created
C. Driver loaded
Statement object created
Record Inserted 3

Connection to database created


Driver loaded
Record inserted 1
D. Record Inserted 2
Statement object created
Record Inserted 3

Answer optiona

Marks: 2

1151 What is use of second parameter in given constructor Label(String,int)

A. specifies height of label

B. specifies width of label in terms of pixel

C. specifies the alignment of text in label

D. specifies width of label

Answer optionc

Marks: 1

1152 What is use of 3rd parameter in given constructor Scrollbar(int,int,int,int,int)

A. Thumbsize

B. Scrollbar orientation

C. initial value

D. minimum value

Answer optiona

Marks: 1

1153 Items are added in JComboBox using method��?


A. add()

B. insert()

C. insertItem()

D. addItem()

Answer optiond

Marks: 1

1154 _________returns the string equivalent to the event.

A. toString()

B. getID()

C. getSource()

D. getObject()

Answer optiona

Marks: 1

1155 When list item is double clicked, which event is generated?

A. ActionEvent

B. ItemEvent

C. ListEvent

D. AdjustmentEvent

Answer optiona

Marks: 1

1156 ___________method returns a value that indicates which modifier keys were pressed when the event was generated.

A. getModifiers()

B. setModifiers()

C. getActionCommand()

D. none of the above

Answer optiona

Marks: 1

1157 What is return type of getAddress() method of InetAddress class?

A. String

B. byte[]

C. String[]

D. InetAddress

Answer optionb

Marks: 1

1158 Which method of URL class is used to create object of URLConnection?

A. getConnection

B. openConnection

C. connection

D. getURLConnection

Answer optionb

Marks: 1
1159 Which package is used for handling security related issue?

A. java.security

B. java.lang.security

C. java.io.security

D. java.awt.image

Answer optiona

Marks: 1

1160 Which interface declares life cycle method of servet?

A. Servlet

B. GenericServlet

C. ServletConfig

D. ServletContext

Answer optiona

Marks: 1

What are the minimum pakages required for executing the bellow program?
class MyDemo extends Frame
{
Button b;
MyDemo()
{

setLayout(new FlowLayout());
setSize(500,500);
b=new Button("OK");
add(b);
b.addActionListener(this);
1161 setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent ae)
{
System.out.println("Button is Pressed");
}
public static void main(String args[])
{
new MyDemo().setVisible(true);
}

A. java.awt.* and java.awt.event.*

B. java.awt.* , java.awt.event.* and javax.swing

C. java.awt.*

D. java.applet.*, java.awt.event.

Answer optiona

Marks: 2

1162 Given Statement may throws which exception? InetAddress address =InetAddress.getByName("www.xyz.com");

A. HostException

B. openConnection

C. UnknownHostException

D. UnavailableDomainException

Answer optionc

Marks: 2

1163 Which object provides DatabaseMetaData object?

A. PreparedStatement

B. Statement

C. ResultSet

D. Connection
Answer optiond

Marks: 2

1164 Which object provides ResultSetMetaData object?

A. PreparedStatement

B. Statement

C. ResultSet

D. Connection

Answer optionc

Marks: 2

1165 Which classes are present in javax.servlet.http package?

ServletInputStream
A. ServletOutputStream
GenericServlet

Servlet
B. HttpServletRequest
HttpServletResponse

ServletRequest
C. ServletResponse

HttpServlet
D. Cookie

Answer optiond

Marks: 2

1166 Which method is used to get HttpSession object and it belongs to which object?

A. getSession method and HttpServletRequest

B. getSession method and HttpServletResponse

C. getHttpSession and HttpServletResponse

D. getHttpSession and HttpServletRequest

Answer optiona

Marks: 2

1167 For producing following outputs which program code is correct

import java.awt.*;
class Demo3 extends Frame
{
Button b;
Demo3()
{
setLayout(new GridLayout(5,3));
for(int i=0;i<15;i++)
{
A. add(new Button(String.valueOf(i)));
}
setSize(800,600);
}

public static void main(String args[]) throws Exception


{
new Demo3().setVisible(true);
}
}

import java.awt.*; class Demo3 extends Frame


{
Button b;
Demo3()
{
setLayout(new FlowLayout());
for(int i=0;i<15;i++)
B. {
add(new Button(String.valueOf(i)));
}
setSize(800,600);
}

pub
import java.awt.*; class Demo3 extends Frame
{
Button b;
Demo3()
{
setLayout(new BorderLayout());
for(int i=0;i<15;i++)
C. {
add(new Button(String.valueOf(i)));
}
setSize(800,600);
}

public static void mai

D. not from any given option

Answer optiona

Marks: 2

To produce following output in given program which statement should be placed to change the background color of applet
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code=JRadioButtonDemo.class
width=500 height=500>
</applet>
*/
public class JRadioButtonDemo extends JApplet implements ItemListener
{
JRadioButton r,g,b;
ButtonGroup bg;
Container cp;
public void init()
{
r=new JRadioButton("RED");
g=new JRadioButton("GREEN");
b=new JRadioButton("BLUE");
1168 cp= getContentPane();
cp.setLayout(new FlowLayout());
cp.add(r);
cp.add(g);
cp.add(b);
bg=new ButtonGroup();
bg.add(r);
bg.add(g);
bg.add(b);
r.addItemListener(this);
g.addItemListener(this);
b.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
...........................................................................
..........................................................................
.......................................................................
}
}

if(ie.getSource()==r)
cp.setBackground(Color.RED);
if(ie.getSource()==g)
A. cp.setBackground(Color.GREEN);
if(ie.getSource()==b)
cp.setBackground(Color.BLUE);

if(ie.getItemSelectable()==r)
cp.setBackground(Color.RED);
if(ie.getItemSelectable()==g)
B. cp.setBackground(Color.GREEN);
if(ie.getItemSelectable()==b)
cp.setBackground(Color.BLUE);

if(ie.getItem()==r)
cp.setBackground(Color.RED);
if(ie.getItem()==g)
C. cp.setBackground(Color.GREEN);
if(ie.getItem()==b)
cp.setBackground(Color.BLUE);

if(ie.getId()==r)
cp.setBackground(Color.RED);
if(ie.getId()==g)
D. cp.setBackground(Color.GREEN);
if(ie.getId==b)
cp.setBackground(Color.BLUE);

Answer optionb

Marks: 2
After inserting which statement in following program, output window will be closed when close button is clicked
import java.awt.event.*;
import java.awt.*;
class Demo extends Frame
{
Demo()
{
setSize(500,500);
setVisible(true);
setTitle("My Window");
}
public static void main(String args[])
{
new Demo();
1169 }
}
class AdapterDemo extends WindowAdapter
{
Demo d1;
AdapterDemo(Demo d)
{
d1=d;
}
public void windowClosing(WindowEvent we)
{
d1.dispose();
}
}

A. addWindowListener();

B. addWindowListener(this);

C. addWindowListener(AdapterDemo());

D. addWindowListener(AdapterDemo(this));

Answer optiond

Marks: 2

What is error in following program?


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code=ScrollDemo.class width=500 height=500>
</applet>
*/
public class ScrollDemo extends Applet implements AdjustmentListener
{
Scrollbar s1,s2,s3;
public void init()
{
s1=new Scrollbar(Scrollbar.VERTICAL,0,1,0,255);
1170 s2=new Scrollbar(Scrollbar.VERTICAL,0,1,0,255);
s3=new Scrollbar(Scrollbar.VERTICAL,0,1,0,255);
add(s1);
add(s2);
add(s3);
s1.addAdjustmentListener(this);
s2.addAdjustmentListener(this);
s3.addAdjustmentListener(this);
}
public void adjustmentChange(AdjustmentEvent ae)
{
setBackground(new Color(s1.getValue(),s2.getValue(),s3.getValue()));
}
}

ScrollDemo is not abstract


and does not override abstract method
A. adjustmentValueChange(AdjustmentEvent) in
AdjustmentListener public class ScrollDemo extends
Applet implements AdjustmentListener

ScrollDemo is not abstract


and does not override abstract method
B. adjustmentValueChanged(AdjustmentEvent) in
AdjustmentListener public class ScrollDemo extends
Applet implements AdjustmentListener

ScrollDemo is not abstract


and does not override abstract method
C. actionPerformed(ActiontEvent) in
AdjustmentListener public class ScrollDemo extends
Applet implements AdjustmentListener

D. No Error

Answer optionb

Marks: 2
For displaying coordinates of moving mouse pointer on status bar of applet, in following programs which statements should be
included?
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code="MouseDemo" width=500 height=500>
</applet>
*/

public class MouseDemo extends Applet


{
String msg1="";

int x,y;
public void init()
{
addMouseMotionListener(new AdapterDemo());
addMouseListener(new AdapterDemo1());
}
public void paint(Graphics g)
1171 {
showStatus("Mouse Moved at"+" "+x+" "+y);
g.drawString(msg1,50,50);
}

class AdapterDemo extends MouseMotionAdapter


{
public void mouseMoved(MouseEvent me)
{
x=me.getX();
y=me.getY();
}
}

class AdapterDemo1 extends MouseAdapter


{
public void mouseEntered(MouseEvent me)
{
msg1="Mouse Entered";
}
}
}

A. No any statement is requred

B. repaint() in init()

C. repaint() in public void mouseMoved(MouseEvent me){}

D. repaint() in public void mouseEntered(MouseEvent me){}

Answer optionc

Marks: 2

What is error in following program


import java.sql.*;
class PreparedStatementDemo
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection("jdbc:odbc:Samarth");
1172 PreparedStatement ps=con.prepareStatement("select * from student");
ResultSet rs=ps.executeQuery();
ResultSetMetaData rs1=con.getMetaData();
System.out.println(rs1.getColumnCount());
}
catch(Exception e)
{
System.out.println(e);
}
}
}

A. java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver

B. error: cannot find symbol "PreparedStatement ps"

C. No error

D. error:incompatible types: "ResultSetMetaData rs1=con.getMetaData();"

Answer optiond

Marks: 2
What is error in following program?
import java.sql.*;
class Demo3
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcodbcDriver");
Connection con= DriverManager.getConnection("jdbc:odbc:Samarth");
PreparedStatement ps=con.prepareStatement("select * from student");
ResultSet rs=ps.executeQuery();

while(rs.next())
1173 {
System.out.println(rs.getInt(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
}

}
catch(Exception e)
{
System.out.println(e);
}
}
}

A. java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcodbcDriver

B. java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression

C. java.sql.SQLException: No suitable driver found for jdbc.odbc.Samarth

D. java.sql.SQLException: No ResultSet was produced

Answer optiona

Marks: 2

What is error in following program?


import java.sql.*;
class PreparedStatementDemo
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection("jdbc:odbc:Samarth");
PreparedStatement ps1=con.prepareStatement("update student set Name=?,City=?,ID=? where ID=?");
ps1.setString(1,"tttt");
1174 ps1.setString(2,"Belhe");
ps1.setInt(3,777);
ps1.executeUpdate();
ps1.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

A. java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect

java.sql.SQLException: [Microsoft]
[ODBC Microsoft Access Driver] Syntax error
B. (missing operator) in query expression 'Pa_RaM000
City=Pa_RaM001 ID=Pa_RaM002'

C. actual argument int cannot be converted to String by method invocation conversion

D. java.sql.SQLException: No ResultSet was produced

Answer optiona

Marks: 2

For Displaying Session ID which statement/statements are missing?


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionExample1 extends HttpServlet
{ public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
1175 HttpSession session = request.getSession(true);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
-------------------------------------------
out.println("ID="+id);
}

A. String id=request.getId();

B. String id=request.getID();
C. String id=session.getId();

D. String id=session.getID();

Answer optionc

Marks: 2

Which statements should be written in the place of dotted lines to display output "Hello World" on web browser
import javax.servlet.*;
import java.io.*;
public class ServletDemo extends GenericServlet
{
public void service(ServletRequest request,ServletResponse response)
{
try
{
1176 ................................
................................
}
catch(Exception e)
{
System.out.println(e);
}
}
}

PrintWriter pw=response.getWriter();
A. pw.println("Hello World");

PrintWriter pw=request.getWriter();
B. pw.println("Hello World");

PrintWriter pw=new PrintWriter();


C. pw.println("Hello World");

D. out.println("Hello World");

Answer optiona

Marks: 2

Which minimum packages are required to execute this Program?

public class RequestHeaderExample extends HttpServlet


{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
1177 PrintWriter out = response.getWriter();
Enumeration e = request.getHeaderNames();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
String value = request.getHeader(name);
out.println(name + " = " + value);
}
}

import java.io.*;
A. import javax.servlet.*;
import javax.servlet.http.*;

import javax.servlet.*;
B. import javax.servlet.http.*;

C. import javax.servlet.http.*;

import java.io.*;
import javax.servlet.*;
D. import javax.servlet.http.*;
import java.util.*;

Answer optiond

Marks: 2

1178 Current text of label can be obtained using ___________________.

A. SetAlignment ()

B. getAlignment ()

C. getText ()

D. setText ()

Answer optionc

Marks: 1

1179 ___________________________ method is used to append the string str to end of the current text.

A. add ()
B. select ()

C. insert ()

D. append ()

Answer optiond

Marks: 1

1180 AWTEvent Class is define in following package

A. Java .io

B. java.util

C. java.awt.event

D. java .net

Answer optionc

Marks: 1

1181 The method that is used for registering keyboard event is knows as ____________________.

A. addKeymotionListener ()

B. add actionListener ()

C. addKeyListener ()

D. addmouseMotionListener ()

Answer optionc

Marks: 1

1182 The Following are event classes

A. Window , Frame,Panel

B. Button,Checkbox, Listbox

C. Menu, Menubar ,Text Area

D. Action Event,FocusEvent ,Container Event

Answer optiond

Marks: 1

1183 Which is the method of mouse event class?

A. getClickCount ( )

B. getkeycode( )

C. getkeychar ( )

D. getitem ( )

Answer optiona

Marks: 1

1184 textChanged (TextEvent te ) method is used for______.

A. when changes occurs in the text area or text field.

B. when keypressed occurs

C. when mousemotion occurs

D. when enter key is get pressed

Answer optiona

Marks: 1

1185 Java.net package include following classes.


A. URLConnection,Button,Socket

B. Socket,Datagramsocket,Checkbox

C. URLConnection, Socket, InetAddress

D. ListBox,Datagramsocket,Datagrampacket

Answer optionc

Marks: 1

1186 In the three tier model the middle tier of the services acts as a mediator between ________________________ and _________________.

A. Java applet and DBMS

B. Java application and databases

C. Data source and Application server

D. DBMS and user

Answer optionb

Marks: 1

1187 __________ interface is used to know the capabilities or information about a database Management system DBMS with JDBC Driver.

A. DatabaseMetadata

B. prepared statement

C. Result set

D. statement

Answer optiona

Marks: 1

1188 HTTP servlet uses methods like__________________.

A. doPost(),doGet()

B. doText(),destroy()

C. service(),init()

D. init(),paint()

Answer optiona

Marks: 1

1189 Cookie is the piece of information which stores the session related data like_______________.

A. Server_name,data,time,cookie_name

B. Time,date,cookie_name,password

C. username,password,time,date

D. Password,time,date,client_name

Answer optionc

Marks: 1

1190 Life cycle of a JSP page consist of following steps.

A. compilation,Loading and initialization,Request Handling,Destroy,Translation

B. Translation of JSP to servlet code, compilation, loading, creating servlet instance, initiallization, request processing, distroying.

C. compilation,Translation,Loading and initialization,Request Handling,Destroy

D. Translation,,Loading and initialization,compilation,Request Handling,Destroy

Answer optionb

Marks: 1
1191 The following constructors are required in the program to get output

A. Cellphones=new List(4,true) Companies=new List(4,false)

B. Cellphones=new checkbox(4,true) Companies=new List(4,false)

C. Cellphones=new List(4,true) Companies=new label(4,false)

D. Cellphones=new List(4,false)

Answer optiona

Marks: 2

1192 What is the purpose of TextArea

A. To handle image as input

B. To handle multiline text input

C. To handle single line text input

D. To handle video and audio input

Answer optionb

Marks: 2

1193 Which of the following code is required to display output in table format.

A. Container c1=getContentPane(); c1.setLayout(new BorderLayout c1));

B. Container c1=getContentPane(); c1.setLayout(new Gridlayout());

C. Container c1=getContentPane(); c1.setLayout(new Flowlayout c1));

D. Container c1=getContentPane(); c1.setLayout(new Mouse Layout c1));

Answer optionb

Marks: 2

Which import statement is used for following program.


/*
<applet code=exp1.class width=200 height=200>
</applet>
*/

public class exp1 extends Applet


{
1194 public void init()
{
setLayout(new BorderLayout());
add(new Button("TOP"),BorderLayout.NORTH);
add(new Button("BOTTOM"),BorderLayout.SOUTH);
add(new Button("RIGHT"),BorderLayout.EAST);
add(new Button("LEFT"),BorderLayout.WEST);
}
}

A. import java.Japplet.*;

import java.awt.event.*;
B. import java.awt.*;
import java.applet.*;

C. import java.applet.*;

D. import java.awt.event.*;

Answer optionb

Marks: 2
State listener with its method used in following program
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/* <applet code=exp2.class width=200 height=200 >
</applet>*/
public class exp2 extends Applet implements ActionListener
{
TextField t1,t2;
Button b1;
Label l1,l2;
public void init()
{
t1=new TextField(5);
t2=new TextField(5);
b1=new Button("Factorial");
l1=new Label("Enter no");
1195 l2=new Label("Factorial is :");
add(l1); add(t1); add(b1); add(l2); add(t2);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
int n1=Integer.parseInt(t1.getText());
int fact=1,i;

for(i=1;i<=n1;i++)
{
fact=fact*i;
}
t2.setText(Integer.toString(fact));
} } }

A. ActionListener,int actionperfomed()

B. ItemListener,actionperfomed()

C. AdjustmentListener,actionperfomed()

D. ActionListener,actionperfomed()

Answer optiond

Marks: 2

Consider following code and state missing code ?


import java.sql.*;
class exp2
{
public static void main(String args[])throws Exception
{
try
{
Class.forName("_________________________________________");
Connection con=DriverManager.getConnection("Jdbc:Odbc:demo1dsn");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from Table1");
System.out.println("After insertion of new record");
while(rs.next())
{
System.out.println(rs.getString(1));
1196 System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
}
st.executeUpdate("insert into Table1 values('jasmine',10,'banglore')");
ResultSet rs1=st.executeQuery("select * from Table1 ");
while(rs1.next())
{
System.out.println(rs1.getString(1));
System.out.println(rs1.getString(2));
System.out.println(rs1.getString(3));
}

}
catch(Exception e)
{}
}
}

A. sun.jdbc.odbc.JdbcOdbcDriver

B. sun.jdbc.odbc.JdbcDriver

C. sun.jdbc.odbc.JdbcOdbc

D. sun.jdbc.Jdbcodbc.JdbcOdbcDriver

Answer optiona

Marks: 2

1197 The method ______________ sets the foreground color to yellow in Jframe

A. f.setForeground (Color.yellow)

B. f.setForeground (color.YELLOW)

C. f.setForeground (color.yellow)
D. f.setForeground (Color.YELLOW)

Answer optiond

Marks: 1

1198 The method ____________________gets the text (or caption) of the label jlbl

A. jlbl.text()

B. jlbl.getText()

C. jlbl.findText()

D. .retrieveText()

Answer optionb

Marks: 1

1199 The ____________________models an IP address,which can be used to find the host name IP address of the client

A. ServerSocket class

B. Socket class

C. InetAddress class

D. Connection interface

Answer optionc

Marks: 2

1200 Package of drawString() method of Graphics class

A. java.applet

B. java.io

C. javax.swing

D. java.awt

Answer optiond

Marks: 1

1201 What method is used to prevent a user from changing the size of a Frame() object?

A. setResizable( true )

B. setResizable( false )

C. setExactSize( true )

D. setEditable( false )

Answer optionb

Marks: 1

1202 The CardLayout class defines the following constructors:

CardLayout() // First
A. CardLayout(int hor, int ver) //second

Cardlayout() // First
B. CardLayout(int hour, int ver) //second

CardLayout() // First
C. Cardlayout(int hor, int var) //second

CardLayout() // First
D. Cardlayout(int hour, int ver) //second

Answer optiona

Marks: 1

1203 Which of the following JSP variables are not available within a JSP expression. Select the one correct answer.

A. out
B. httpsession

C. session

D. request

Answer optionb

Marks: 1

1204 Which of the following is legal JSP syntax to print the value of i. Select the one correct answer

A. <%= i %>

B. <%int i = 1;%>

C. <%int i = 1; i; %>

D. <%int i = 1%>

Answer optiona

Marks: 1

1205 What pattern does the FlowLayout layout manager use to add components to container?

A. Left to right, top to bottom

B. bottom to top, right to left

C. top to bottom, centered in each row

D. any old order

Answer optiona

Marks: 2

1206 Say that a Frame contains three Panels. Could each Panel have a different layout manager?

A. No---they must all use the default layout manager

B. No---they must all use the same layout manager

C. Yes---each one must be different

D. Yes---each one can use setLayout() with any layout manager

Answer optiond

Marks: 2

1207 _______________ method can be used to know the degree of adjustment made by user with ScrollBar?

A. getValue()

B. getAdjustmentType()

C. getAdjustmentValue()

D. getAdjustmentLocation()

Answer optiona

Marks: 2

Given an HttpServletRequest request and HttpServletResponse response, which sets a cookie "username" with the value "joe" in a
1208 servlet?

A. request.addCookie(new Cookie("username", "joe"));

B. response.addCookie(new Cookie("username", "joe"));

C. response.addCookie("username", "joe");

D. request.addCookie("username", "joe");

Answer optionb

Marks: 2

1209 Components in the frame is add at appropriate place using


A. setSize(int, int)

B. setForLocation(int,int)

C. setBounds(int,int,int,int)

D. setProperPlace(int,int,int,int)

Answer optionc

Marks: 2

1210 ______________ displays a message that alerts the user and waits for the user to click the OK button to close the dialog.

A. Input dialog box

B. Message dialog box

C. Confirmation dialog box

D. Option dialog box

Answer optionb

Marks: 2

1211 The method __________ separates menu items in a menu mu.

A. mu.add('-')

B. mu.setSeparator()

C. mu.addSeparator()

D. mu.insertSeparator()

Answer optionc

Marks: 2

1212 ___________ is a Swing layout manager that arranges components on top of each other in a deck.

A. BorderLayout

B. GridLayout

C. CardLayout

D. OverlayLayout

Answer optionc

Marks: 2

1213 The value typed in TextArea is notified by________________Listener.

A. TextTypedListener

B. TextComponentListener

C. TextListener

D. ItemListener

Answer optionc

Marks: 2

1214 The signature for the registration method for an ActionEvent should be __________.

A. public void addActionListener(ActionEvent l)

B. public void setAction(ActionListener l)

C. public void setActionListener(ActionListener l)

D. public void addActionListener(ActionListener l)

Answer optiona

Marks: 2
1215 what is Native Protocol, Pure Java Driver?

A. This type of driver, written entirely in Java, communicates directly with the database.

B. This type of driver communicates using a network protocol to a middle-tier server.

C. These drivers take JDBC requests and translate them into a network protocol that is not database specific.

D. This type of driver wraps a native API with Java classes.

Answer optiona

Marks: 2

1216 Which of the following is true

A. The two tiers are often called as Network layer includes JDBC drivers only

B. The two tiers are often called as Application layer includes JDBC drivers, business logic and user interfaces whereas second layer.

C. The two tiers are often called as Application layer includes client is only application and server is JDBC drivers, business logic and user interfaces wher

D. The two tiers are the same as that of three tier architecture.

Answer optionb

Marks: 2

You are creating a servlet that generates stock market graphs. You want to provide the web browser with precise information about the
1217 amount of data being sent in the response stream.
Which HttpServletResponse methods will you use to provide this information?

A. response.setLength(numberOfBytes);

B. response.setContentLength(numberOfBytes);

C. response.setHeader("Length", numberOfBytes);

D. response.setIntHeader("Length", numberOfBytes);

Answer optionb

Marks: 2

What gets printed when the following is compiled. Select the one correct answer.
<% int y = 0; %>
<% int z = 0; %>
<% for(int x=0;x<3;x++) { %>
<% z++;++y;%>
1218 <% }%>
<% if(z<y) {%>
<%= z%>
<% } else {%>
<%= z - 1%>
<% }%>

A. 1

B. 2

C. 3

D. The program generates compilation error.

Answer optionc

Marks: 2

Given:
1. public void service(ServletRequest request,
2. ServletResponse response) {
1219 3. ServletInputStream sis =
4. // insert code here
5. }
Which retrieves the binary input stream on line 4 ?

A. request.getReader();

B. request.getWriter();

C. request.getResourceAsStream();

D. request.getInputStream();

Answer optiond

Marks: 2
These four methods commonly used in?
1)public void add(Component c)
1220 2)public void setSize(int width,int height)
3)public void setLayout(LayoutManager m)
4)public void setVisible(boolean)

A. Graphics class

B. Component class

C. Both A & B

D. None of the above

Answer optionb

Marks: 1

1221 JRadioButton is a subclass of ________.

A. JMenuItem

B. AbstractButton

C. JMenu

D. JCheckBoxGroup

Answer optionb

Marks: 1

1222 To get the servlet environment information

A. ServletConfig object is used

B. ServletException object is used

C. ServletContext object is used

D. ServletContainer object is used

Answer optionc

Marks: 1

Select sequence of the missing statements in the following program


import java.awt.*;
import java.awt.event.*;
public class MenuDemo extends Frame implements ___________________
{
MenuDemo()
{

MenuBar mbr = new MenuBar();


Menu filemenu = new Menu("File");
Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
MenuItem new1 = new MenuItem("New");
MenuItem open1 = new MenuItem("Open");
filemenu.add(new1);
filemenu.add(open1);
new1.__________________;
open1._________________;
}
1223 public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setSize(200,200);
m.setTitle("Menu Demo Program");
m.setVisible(true);

}
public void ________________________
{
if(new1=ae.getsource())
{
System.out.println("You Pressed New menu Item");
}
else if(ae.getSource()==open1)
{
System.out.println("You Pressed Open menu Item");
}

}
}

ItemListener
A. addItemListener(this)
itemStateChanged(ItemEvent ae)

ActionListener
B. addActionListener(this)
actionPerformed(ItemEvent ae)
ActionListener
C. addActionListener(this)
actionPerformed(ActionEvent ae)

ItemListener
D. addItemListener(this)
itemStateChanged(ActionEvent ae)

Answer optionc

Marks: 2

1224 An event adapter can be implemented using ___________.

A. standard adapter

B. inner class adapter

C. anonymous inner class adapter

D. All of Above

Answer optiond

Marks: 2

Identify the Error Statement in the Following Program


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class ChangeBackClr extends JFrame
{
ChangeBackClr()
{
final Container oPane=getContainer();
addMouseListener(new MouseAdapter()
1225 {
public void mouseClicked(MouseEvent me)
{
int iR=(int)(Math.random()*255);
int iG=(int)(Math.random()*255);
int iB=(int)(Math.random()*255);
oPane.setBackcolor(new Color(iR,iG,iB));
}
});
}
}

A. final

B. getContentPane()

C. seBackGround

D. All of the above.

Answer optiond

Marks: 2

1226 DatabaseMetaData are retrieved through ____________.

A. Connection object

B. PreparedStatement object

C. Statement object

D. ResultSet Object

Answer optiona

Marks: 1

Assume that you need to write a JSP page that adds numbers from one to ten, and then print the output.
<% int sum = 0;
for(j = 0; j < 10; j++) { %>
1227 // XXX --- Add j to sum
<% } %>
// YYY --- Display ths sum
Which statement when placed at the location XXX can be used to compute the sum. Select the one correct statement

A. <% sum = sum + j %>

B. <% sum = sum + j; %>

C. <%= sum = sum + j %>

D. <%= sum = sum + j; %>


Answer optionb

Marks: 2

___________________is a superclass of TextField and TextArea classes that is used to create single-line or multiline textfields
1228 respectively:

A. TextBox

B. CheckBox

C. TextComponent

D. Choice

Answer optionc

Marks: 2

What is the missing Exception in following program


/*
<applet code="TestMouse.class" width=300 height=100>
</applet>
*/
importjava.awt.*;
importjava.awt.event.*;
importjava.applet.*;
public class TestMouse extends Applet implements_____________________
{
String msg = "";
intmouseX = 0, mouseY = 0
public void init()
{
addMouseListener(this);
addMouseMotionListener(this);
}
public void mouseClicked(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "Mouse clicked.";
repaint();
}
public void mouseEntered(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "Mouse entered.";
repaint();
}
public void mouseExited(MouseEvent me)
{
mouseX = 0;
1229 mouseY = 10;
msg = "Mouse exited.";
repaint();
}
public void mousePressed(MouseEvent me)
{
mouseX = me.getX();
mouseY = me.getY();
msg = "Down";
repaint();
}
public void mouseReleased(MouseEvent me)
{
mouseX = me.getX();
mouseY = me.getY();
msg = "Up";
repaint();
}
public void mouseDragged(MouseEvent me)
{
mouseX = me.getX();
mouseY = me.getY();
msg = "*";
showStatus("Dragging mouse at " + mouseX + ", " + mouseY);
repaint();
}
public void mouseMoved(MouseEvent me)
{
showStatus("Moving mouse at " + me.getX() + ", " + me.getY());
}
public void paint(Graphics g)
{
g.drawString(msg, mouseX, mouseY);
}
}

A. MouseMotionListener

B. MouseListener

C. both A & B

D. None of Above

Answer optionc

Marks: 2

1230 In the following JDBC drivers which are known as fully java driver?
A. Native-API driver

B. Network Protocol driver

C. Thin driver

D. Both B & C

Answer optiond

Marks: 2

1231 ResultSetMetadata are retrieved through ____________.

A. Connection object

B. PreparedStatement object

C. Statement object

D. None of Above

Answer optiond

Marks: 2

What should be the correction done in the program to get correct output?
import java.sql.*;
class TestData
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:StudDSN);
Statement s=c.prepareStatement();
1232 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();
}
}

A. Error in main()

B. Error in loop

C. Error in connection statement

D. Error in close()

Answer optionc

Marks: 2

Modified the stament from following program to get correct output.

import java.sql.*;
public class TestStudData
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
s.setString(1,args[0]);
s.setString(2,Integer.parseInt(args[1]));
1233 int iNo=s.executeQuery();
if(iNo>0)
{
System.out.println("Record is Updated");
}
else
{
System.out.println("Record not Found");
}
s.close();
c.close();
}
}

A. int iNo=s.executeUpdate()

B. int iNo=c.createStatement( )

C. int iNo=s.execute()

D. int iNo=s.executeQuery(sqlQuery)

Answer optiona
Marks: 2

1234 Java servlets are an efficient and powerful solution for creating ����.. for the web.

A. Dynamic content

B. Both a and b

C. Hardware

D. Static content

Answer optiona

Marks: 1

1235 Which of these methods can be used to obtain the coordinates of a mouse?

A. getMouseCordinates()

B. getMouseXY()

C. getPoint()

D. getCoordinates()

Answer optionc

Marks: 2

1236 The User Datagram Protocol (UDP) is

A. connectionless

B. powerless

C. unreliable

D. All of them

Answer optiond

Marks: 2

Fill in the blanks so that this program displays a Frame:

import java.awt.*;

public class microGUI


{
1237 public static void main ( String[] args )
{
Frame frm = new ___________();
frm.___________( 150, 100 );
frm.___________( true );
}
}

A. Form, setVisible, setOn

B. Frame, setSize, setVisible

C. Frame, setVisible, setSize

D. Window, setSize, paint

Answer optionb

Marks: 2

Fill in the blanks so that the following draws a Frame containing "Hello".

import java.awt.*;

class HelloFrame ___________ Frame


{
public void ___________( Graphics g )
{
g.___________("Hello", 10, 50 );
}
}
1238
public class Tester
{
public static void main ( String[] args )
{
helloFrame frm = new helloFrame();
frm.setSize( 150, 100 );
frm.setVisible( true );
}
}
A. import, drawString, paint

B. extends, paint, drawString

C. extends, draw, paint

D. include, drawString, paint

Answer optionb

Marks: 2

Consider the following output. Find the missing statement in the program.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/*
<applet code="SimpleKey1" width=300 height=100>
</applet>
*/
public class SimpleKey1 extends JApplet implements KeyListener
1239 {
String msg = "";
int X = 10, Y = 20; public void init()
{
addKeyListener(this);
requestFocus();
}
public void paint(Graphics g)
{
g.drawString(msg, X, Y);
}
}

public void keyReleased(KeyEvent ke)


{
A. showStatus("Key Up");
}

public void keyPressed(KeyEvent ke)


{
B. showStatus("Key Down");
}

public void keyTyped(KeyEvent ke)


{
C. msg += ke.getKeyChar();
repaint();
}

D. All of the Above

Answer optiond

Marks: 2

import java.awt.*;

import java.applet.*;

public class myapplet extends Applet {

1240 public void paint(Graphics g) {

g.drawString("A Simple Applet", 20, 20);

A. A Simple Applet

B. Runtime Error

C. Compilation Error

D. A Simple Applet 20 20

Answer optiona

Marks: 2

Connection con = DriverManager.getConnection ("jdbc:odbc:wombat", "login", "password");


Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");
while (rs.next())
{
Integer x = rs.getInt("c");
1241 String s = rs.getString("a");
Float f = rs.getFloat("b");
}

What is WRONG with the code above?


A. Retrieval of the fields is in the wrong order.

B. The password must be encrypted before being sent to the DriverManager.

C. The Driver's URL is in the wrong format.

D. The ResultSet class returns primitive types for integers and floats.

Answer optiona

Marks: 2

1242 In which technology, we mix our business logic with the presentation logic?

A. Servlet

B. JSP

C. Both A & B

D. None of the above

Answer optiona

Marks: 2

1243 In JSP Action tags which is used to include the content of another resource it may be jsp, html or servlet?

A. jsp:include

B. jsp:papam

C. jsp:plugin

D. jsp:forward

Answer optiona

Marks: 2

1244 Seperation of business logic from JSP this is the advantage of?

A. Custom Tags in JSP

B. JSP Standard Tag Library

C. Both A & B

D. None of the above

Answer optiona

Marks: 2

1245 In HTTP Request Which Asks for the loopback of the request message, for testing or troubleshooting?

A. OPTIONS

B. PUT

C. TRACE

D. DELETE

Answer optionc

Marks: 2

1246 In which group one button may be selected at one time?

A. CheckboxGroup

B. Checkbox

C. MenuItem

D. Panel

Answer optiona

Marks: 1
1247 Name the class which is used to create a port where the server will listen?

A. Server

B. Socket

C. ServerSocket

D. SocketServer

Answer optionc

Marks: 1

1248 TCP/IP reserves the ____________ ports for specific protocols

A. above 1024

B. lower 1024

C. 2048

D. 5654

Answer optionb

Marks: 1

1249 Identify proper syntax from following options of TextArea constructor

A. TextArea(int numlines, int numChars)

B. TextArea(int numChars, int numlines)

C. TextArea(int numlines, int numlines)

D. Textarea(int numlines, float numChar)

Answer optiona

Marks: 2

1250 The ______________ class has two methods, mouseDragged() and mouseMoved()

A. MouseListener

B. MouseMovedListener

C. MouseActiveListener

D. MouseMotionListener

Answer optiond

Marks: 2

1251 Name the components of the URL in order of their appearance

A. Protocol,Hostname,Port Number, File Name

B. Hostname,Port Number, File Name, Protocol

C. File Name, Protocol,Hostname,Port Number

D. Download,Hostname,Port Number, File Name

Answer optiona

Marks: 2

1252 Identify proper syntax of doGet()

A. void doGet(HttpResponse res, HttpRequest req) throws IOExpection, ServletException

B. void doGet(HttpServletRequest req, HttpServletResponse res) throws IOExpection, ServletException

C. void doGet(HttpRequest req) throws IOExpection, ServletException

D. void doGet(HttpResponse res) throws IOExpection, ServletException

Answer optionb
Marks: 2

Find error from following code


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
/*
<applet code="JTreeEvents" width=400 height=200>
</applet>
*/
public class JTreeEvents extends JApplet {
JTree tree;
JTextField jtf;
public void init() {
// Get content pane
Contain contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Options");
DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
top.add(a);
DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("A1");
1253 a.add(a1);
DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("A2");
a.add(a2);
DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
top.add(b);
DefaultMutableTreeNode b1 = new DefaultMutableTreeNode("B1");
b.add(b1);
DefaultMutableTreeNode b2 = new DefaultMutableTreeNode("B2");
b.add(b2);
DefaultMutableTreeNode b3 = new DefaultMutableTreeNode("B3");
b.add(b3);
tree = new JTree(top);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(tree, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
jtf = new JTextField("", 20);
contentPane.add(jtf, BorderLayout.SOUTH);
}}

A. contentPane must be object of Container class

B. contentPane must be object of Connection class

C. contentPane must be object of GlassPane class

D. contentPane must be object of Cont class

Answer optiona

Marks: 2

Observe the following code


importjava.awt.*;
importjava.applet.*;
public class LayoutDemo5 extends Applet
{
public void init()
{
inti,j,k,n=4;
setLayout(new BorderLayout());
Panel p1=new Panel();
Panel p2=new Panel();

p1.setLayout(new FlowLayout());
p1.add(new TextField(20));
1254 p1.add(new TextField(20));

p2.setLayout(new GridLayout(5,3));
p2.add(new Button("OK"));
p2.add(new Button("Submit"));

add(p1,BorderLayout.EAST);
add(p2,BorderLayout.WEST);
}
}
/*<applet code=LayoutDemo5.class width=300 height=400>
</applet>*/

What will be the output of the above program?

A. The output is obtained in Frame with two layouts: Frame layout and Flow Layout.

B. The output is obtained in Applet with two layouts: Frame layout and Flow Layout.

C. The output is obtained in Applet with two layouts: Frame layout and Border Layout.

D. The output is obtained in Applet with two layouts: Border layout and Flow Layout.

Answer optiond

Marks: 2

1255 Select proper sequence of following classes used for writing menudriven program 1.Menu 2. MenuBar 3. MenuItem

A. 2,1,3

B. 1,2,3
C. 3,2,1

D. None Of The Above

Answer optiona

Marks: 2

What is meaning of following code snippet


System.out.println("NAME\tAGE");
1256 String sql = "select Name, Age from StudInfo";
ResultSet results = state.executeQuery(sql);

A. NAME AGE

B. executeQuery() method will execute sql query and ouput is available is results object of ResultSet class

C. AGE NAME

D. executeQuery() will be executed and output is available in sql variable

Answer optionb

Marks: 2

Find correct output of following code


HTML FILE
<html>
<body>
<form action=�pass1�>
name:<input type=�text� name=�t1�>
password:<input type = �password� name=�t2�>
<input type=�submit� value=�login�>
</form>
</body>
</html>

// Servlet file
import java.io.*;
import javax.servlet.*;
public class pass1 extends GenericServlet
{
1257 public void service(ServletRequest req,ServletResponse res)throws ServletException, IOException
{
res.setContentType(�text/html�);
PrintWriter pw = res.getWriter();
String un=�abc�;
String pwd=�xyz�;
String p1=req.getParameter(�t1�);
String p2=req.getParameter(�t2�);
if((p1.equals(un)) && (p2.equals(pwd)))
{
pw.println(�<h1>welcome to home page</h>�);
}else{
pw.println(�invalid�);
}
pw.close();
}
}

A. Firstly it dispalys "welcome to home page" then asks for input name & password

B. Firstly input username & password then it displays "welcome to home page" or "invalid"

C. Firstly input username only

D. it dispalys "welcome to home page" only

Answer optionb

Marks: 2

Write the comments on following statements:


1258 1 res.setContentType(�text/html�);
2 PrintWriter pw = res.getWriter();

A. 1.Sets the content type 2.PrintWriter object that you can use to send character text to the client.

B. 1.Sets the content type 2.PrintWriter object that you can use to receive character text to the client.

C. 1.Sets the content type 2.PrintReader object is created

D. 1.Reads the content type 2.PrintWriter object is created

Answer optiona

Marks: 2

1259 A label is a simple control which is used to display _________________on the window

A. Text(non-editable)

B. Text(editable)
C. Both a & b

D. None of these

Answer optiona

Marks: 1

1260 A ____________________component is a display area for a short string of text, image or both.

A. Jtext

B. JTextField

C. Jfield

D. JLabel

Answer optiond

Marks: 1

1261 ____________arranges the component in rows and columns

A. BorderLayout

B. CardLayout

C. GridLayout

D. FlowLayout

Answer optionc

Marks: 1

1262 In Swing ____________is a component that displays rows and columns of data.

A. card

B. tree

C. table

D. tabbed Pane

Answer optionc

Marks: 1

1263 The __________________interface handles choice events.

A. ContainerListener

B. ItemListener

C. ActionListener

D. WindowListener

Answer optionb

Marks: 1

1264 _____________method returns a Point object that contains both X and Y coordinates.

A. getLocationOnScreen()

B. getXOnScreen()

C. getYOnScreen()

D. None of the above

Answer optiona

Marks: 1

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

A. InetAddress
B. DatagramPackets

C. DatagramSockets

D. All of the mentioned

Answer optiond

Marks: 1

1266 Which driver is called as a thin driver in JDBC?

A. Type-1 Driver

B. Type-2 Driver

C. Type-3 Driver

D. Type-4 Driver

Answer optiond

Marks: 1

1267 How many copies of a JSP page can be in memory at a time?

A. one

B. two

C. Three

D. Unlimited

Answer optiona

Marks: 1

1268 Which of these is NOT a constructor of the FileDialog?

A. FileDialog(Frame parent,String boxName)

B. FileDialog(Frame parent,String boxName,int how)

C. FileDialog(Frame parent)

D. FileDialog(Frame parent,int how)

Answer optiond

Marks: 2

1269 which class provides method for accessing a font's properties?

A. getFont

B. Jfont

C. FontMetrices

D. GraphicsEnvironment

Answer optionc

Marks: 2

1270 Which values are defined in InputEvent class to represent modifiers?

A. ALT_MASK

B. META_MASK

C. SHIFT_MASK

D. All the above

Answer optiond

Marks: 2

1271 Which class header would be used to create an applet that accepts a click on a button?
A. public class MyApplet extends Japplet implements Listener

B. public class MyApplet extends Japplet implements ActionListener

C. public class MyAppletextends Japplet implements ActionEvent

D. public class MyApplet extends Japplet implements Event

Answer optionb

Marks: 2

1272 JSP tags are divided into which types?

A. scriptlets

B. Expressions

C. Declarations

D. All the above

Answer optiond

Marks: 2

1273 Through which tag you can define servlet config in web.xml?

A. config-param

B. context-param

C. init-param

D. None of Above

Answer optionc

Marks: 2

What Correction should be done in the following program to get the proper output?
/*
<applet code="JTabbedPaneDemo" width=400 height=100>
</applet>
*/

public class JTabbedPaneDemo extends JApplet


{
public void init()
{
JTabbedPane jtp = new JTabbedPane();

jtp.addTab("Cities", new CitiesPanel());


jtp.addTab("Colors", new ColorsPanel());

getContentPane().add(jtp);
}
}

class CitiesPanel extends JPanel


1274 {
public CitiesPanel()
{
JButton b1 = new JButton("New York");
add(b1);
JButton b2 = new JButton("London");
add(b2);
}
}

class ColorsPanel extends JPanel


{
public ColorsPanel()
{
JCheckBox cb1 = new JCheckBox("Red");
add(cb1);
JCheckBox cb2 = new JCheckBox("Green");
add(cb2);
}
}

A. Missing semicolon

B. missing()

C. Missing package sentences

D. missing {

Answer optionc

Marks: 2
What is the output of the following code:
import java.awt.*;
import java.applet.*;
/*
<applet code="GridLayoutDemo" width=300 height=200>
</applet>
*/
public class GridLayoutDemo extends Applet
{
int n = 4;
public void init()
1275 {
setLayout(new GridLayout(n,n,10,10));

for(int i = 0; i <n; i++)


{
for(int j = 0; j <n; j++)
{
add(new Button("k"));
}
}
}
}

A. A

B. B

C. none of the above

D. all of these

Answer optiona

Marks: 2

Select Proper Command to run following program


import java.awt.*;
import java.awt.event.*;
class FrameDemo extends Frame
{
FrameDemo()
{
addWindowListener(new M());
}
public static void main(String args[])
{
FrameDemo f=new FrameDemo();
f.setSize(100,200);
f.setTitle("Frame window");
1276 f.setVisible(true);
}
public void paint(Graphics g)
{
g.drawString("this is a frame",100,200);
}

class M extends WindowAdapter


{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
}

A. java FrameDemo

B. appletviewer FrameDemo.java

C. All of the above

D. None of the above

Answer optiona

Marks: 2
Consider the following program.
What should be the correction done in the program to get correct output?
import java.sql.*;
class ConnectDB
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String url="jdbc:odbc:javadb";
Connection con=DriverManager.getConnection(url);
1277
System.out.println(" Connection to DataBase created")
}
catch(SQLException e)
{
System.out.println(" Error"+e);
}
catch(Exception e)
{
System.out.println(" Error"+e);
}
}
}

A. Missing Semicolon

B. Missing {

C. Missing }

D. Missing()

Answer optiona

Marks: 2

Consider the following program . Select the statement that should be added to the program to get correct output.

import java.sql.*;
class PreparedInsert
{
public static void main(String a[])
{
Try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:javadb");
System.out.println(" Connection to DataBase created");
String a1 = "Insert into employee(id,name,salary) values(?,?,?)";
PreparedStatement ps = con.prepareStatement(a1);
ps.execute(a1);
System.out.println("Record Inserted");
String querySel = "Select * from employee";
ResultSet rs = ps.executeQuery(querySel);
System.out.println("After Insertion");
1278 while(rs.next())
{
System.out.println(" ID : "+ rs.getInt(1));
System.out.println(" Name : "+ rs.getString(2));
System.out.println(" Salary : "+ rs.getInt(3));
System.out.println();
}
con.close();
}
catch(SQLException e)
{
System.out.println(�SQL Error�);
}
catch(Exception e)
{
System.out.println(�Error�);
}

}
}

A. ps.setInt(1,5);

B. ps.setString(2,"sahil");

C. ps.setInt(3,5000);

D. All the above

Answer optiond

Marks: 2
What should be at the place of ________ to get the correct output:
import java.sql.*;

public class Updatedbase


{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:data");

Statement st=con._______________;

ResultSet rs=st.executeQuery("select * from emp");

System.out.println("before change");
while(rs.next())
{
System.out.println("id:"+rs.getInt("id"));

System.out.println("salary:"+rs.getString("salary"));

System.out.println("name:"+rs.getString("name1"));
}
1279

int k=st.executeUpdate("Update emp set salary=1000 where id=3");


System.out.println("rows affected:"+k);
System.out.println("\n\nafter change");
rs=st.executeQuery("select * from emp");

while(rs.next())
{
System.out.println("id:"+rs.getInt("id"));

System.out.println("salary:"+rs.getString("salary"));

System.out.println("name1:"+rs.getString("name1"));
}

con.close();
}

catch(SQLException e)
{}
catch(Exception e)
{}

}
}

A. executeStatement()

B. createStatement()

C. executeQuery()

D. close()

Answer optionb

Marks: 2

import java.sql.*;
public class Pstatement
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:data");
Statement st=con.createStatement();

String a="Update emp set name1=_______ where id=____________";

PreparedStatement ps=con.prepareStatement(a);
ps.setString(1,"aaa");
ps.setInt(2,4);

ps.executeUpdate();

ResultSet rs=st.executeQuery("select * from emp");


1280

System.out.println(" id"+" salary"+" name");


while(rs.next())
{

System.out.println(" "+rs.getInt("id")+" "+rs.getString("salary")+


" "+rs.getString("name1"));
}

con.close();
}

catch(SQLException e)
{}
catch(Exception e)
{}

}}

A. *,*
B. $,$

C. ?,?

D. &,&

Answer optionc

Marks: 2

1281 Window is super class of ____________

A. Applet

B. Panel

C. Frame

D. Both Applet and Panel

Answer optionc

Marks: 1

1282 Methods of ResultSet() throws ____________

A. SQLException

B. ArithmeticException

C. IOException

D. SocketException

Answer optiona

Marks: 1

1283 HttpServlet is a subclass of ____________________.

A. Servlet

B. ServletConfig

C. GenericServlet

D. ServletRequest

Answer optionc

Marks: 1

1284 Cookie class consist __________________.

A. name and value

B. name only

C. value only

D. None of these

Answer optiona

Marks: 1
Select the missing statements in given code
import java.awt.*;
import java.applet.*;
/*
<applet code="mouse" width=300 height=100>
</applet>
*/
public class mouse extends Applet implements MouseMotionListener
{
String msg = "";
intmouseX = 0, mouseY = 0
public void init()
{
}
public void mouseDragged(MouseEvent me)
1285 {
mouseX = me.getX();
mouseY = me.getY();
msg = "*";
showStatus("Dragging mouse at " + mouseX + ", " + mouseY);
repaint();
}
public void mouseMoved(MouseEvent me)
{
showStatus("Moving mouse at " + me.getX() + ", " + me.getY());
}
public void paint(Graphics g)
{
g.drawString(msg, mouseX, mouseY);
}
}

A. import java.awt.event.*;

B. addMouseListener(this)

C. addActionListener(this)

D. import java.awt.event.*; addMouseMotionListener(this)

Answer optiond

Marks: 2

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

A. -1

B. 8080

C. 80

D. 25

Answer optiona

Marks: 2

1287 Identify correct syntax of doPost() method used in servlets.

A. void doPost(HttpServletRequest req,HttpSession s)

B. void doPost(HttpSession s, HttpServletRequest req)

C. void doPost(HttpServletRequest req,HttpServelet s)

D. void doPost(HttpServletRequest req,HttpServletResponse res)

Answer optiond

Marks: 2

1288 getWriter method is accessed as ___________

A. request.getWriter()

B. response.getWriter()

C. session.getWriter()

D. servlet.getWriter()

Answer optionb

Marks: 1

1289 Identify correct syntax of addCookie() method

A. void addCookie()

B. void addCookie(String cookiename)


C. void addCookie(Cookie cookie)

D. Cookie addCookie()

Answer optionc

Marks: 2

Select the missing statements in the following code


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class SquareDemo extends Applet implements ActionListener
{
Label l1,l2;
TextField t1,t2;
Button b1,b2;
public void init()
{
l1=new Label("Enter First NO.");
l2=new Label("Square");
------------------------------
t2=new TextField();
b1=new Button("Calculate");
b2=new Button("Clear");
l1.setBounds(50,50,100,40);
l2.setBounds(50,100,100,40);
t1.setBounds(170,50,100,30);
t2.setBounds(170,100,100,30);
b1.setBounds(100,200,100,40);
1290 b2.setBounds(210,200,100,40);
add(l1);add(l2);
add(t1);add(t2);
add(b1);add(b2);
------------------------------
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent a)
{
if(a.getSource()==b1)
{
int no=Integer.parseInt(t1.getText());
t2.setText(""+(no*no));
}
else
{
t1.setText("");
t2.setText("");
}
}
}
/*<applet code=SquareDemo.class width=500 height=500></applet>*/

t1=new Textfield();
A. b1.addActionListener(This);

t1=new TextField();
B. b1.addActionlistener(this);

t1=new TextField();
C. b1.addActionListener(this);

t1=new TextField();
D. b1.addactionListener(this);

Answer optionc

Marks: 2

Find out the missing statements shown by _____________in the following code.
import java.awt.*;
import java.awt.event.*;
class ClosableFrame extends _____________
{
ClosableFrame(String s)
{
super(s);
addWindowListener(new ______________()
{
public void windowClosing(___________ w)
{
System.exit(0);
}
1291
});
}
public void paint(Graphics g)
{
g.drawString("My Frame",200,200);
}
public static void main(String args[])
{
ClosableFrame f=new ClosableFrame("Hello");
f.setVisible(true);
f.setSize(400,400);
}
}

A. Frame, WindowAdapter,WindowEvent

B. Applet, WindowAdapter, WindowEvent

C. JFrame, WindowEvent, WindowAdapter


D. Frame, WindowAdapter, AcctionEvent

Answer optiona

Marks: 2

Select the proper method that can be used to handle the event
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JRadioDemo extends JApplet implements ActionListener
{
JRadioButton r1,r2,r3;
Container c;
public void init()
{
c=getContentPane();
c.setLayout(new FlowLayout());
r1=new JRadioButton("Red");
r2=new JRadioButton("Green");
r3=new JRadioButton("Blue");
ButtonGroup b=new ButtonGroup();
1292 b.add(r1);b.add(r2);b.add(r3);
c.add(r1);c.add(r2);c.add(r3);
r1.addActionListener(this);
r2.addActionListener(this);
r3.addActionListener(this);
}
public void _____________________________
{
if(a.getSource()==r1)
c.setBackground(Color.RED);
else if(a.getSource()==r2)
c.setBackground(Color.GREEN);
else
c.setBackground(Color.BLUE);
}
}
/*<applet code=JRadioDemo.class width=500 height=500></applet>*/

A. itemStateChanged(ActionEvent a)

B. actionPerformed(ItemEvent i)

C. actionPerformed(ActionEvent a)

D. itemStateChanged(ItemEvent a)

Answer optionc

Marks: 2

Consider the following output. Find the missing statement in the program shown by ____________.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/*
<applet code="SimpleKey1" width=300 height=100>
</applet>
*/
public class SimpleKey1 extends JApplet
implements KeyListener
{
String msg = "";
int X = 10, Y = 20; public void init()
{
addKeyListener(this);
requestFocus();
1293 }
___________________
{
showStatus("Key Down");
}
public void keyReleased(KeyEvent ke)
{
showStatus("Key Up");
public void keyTyped(KeyEvent ke)
{
msg += ke.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, X, Y);
}
}

A. public void keyPressed(KeyEvent ke)

B. public void keyPressed(MouseEvent m)

C. public void mousePressed(MouseEvent m)

D. public void mouseClicked(MouseEvent m)

Answer optiona

Marks: 2
What should be the correction done in the following program to get correct output?
import java.Sql.*;
import java.io.*;
class insertDemo
{
public static void main(String args[])
{
int c=0;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String myURL="jdbc:odbc:college";
1294
Connection con=DriverManager.getConnection(myURL);
Statement st=con.createStatement();
c=st.executeUpdate("insert into emp values(1,4000)");
if(c!=0)
System.out.println("Record inserted");
else
System.out.println("Record NOT inserted");
con.close();
}catch(Exception e){}
}
}

A. import java.SQL.*;

B. import java.sql.*;

C. Connection con=DriverManager.getConnection();

D. Class.Forname("sun.jdbc.odbc.JdbcOdbcDriver");

Answer optiona

Marks: 2

Find out the statement containing error.


import java.sql.*;
import java.io.*;
class DisTable1
{
public static void main(String args[])
{
int id=0;
String name="",addr="",check="";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:mydsn");
1295 Preparedstatement pst=cn.preparestatement("select * from emp");
ResultSet rs=pst.executeQuery();
System.out.println("EmpId\t"+"Name\t"+"Address");
while(rs.next())
{
System.out.print(rs.getInt(1)+"\t");
System.out.print(rs.getString(2)+"\t");
System.out.print(rs.getString(3)+"\n");
}
cn.close();
}catch(Exception e){}
}
}

A. Statement where Connection is created

B. Statement where prepared statement is created

C. Statement where package is imported

D. statement where result set is created

Answer optionb

Marks: 2

find out the error in the following program to get correct output?
import java.sql.*;
import java.io.*;
class InsertDemo
{
public Static void Main(String args[])
{
int c=0;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
1296 String myURL="jdbc:odbc:college";
Connection con=DriverManager.getConnection(myURL);
Statement st=con.createStatement();
c=st.executeUpdate("insert into emp values(1,4000)")
if(c!=0)
System.out.println("Record inserted");
else
System.out.println("Record NOT inserted");
con.close();
}catch(Exception e){}
}
}

A. error in main()
B. error in if statement

C. error in catch statement

D. error in connection statement

Answer optiona

Marks: 2

Select the statement that should be added to the following program to get the correct output.
import java.sql.*;
import java.io.*;
class DisTable
{
public static void main(String args[])
{
int id=0;
String name="",br="";
try
{
Connection cn=DriverManager.getConnection("jdbc:odbc:MyDSN");
PreparedStatement pst=cn.prepareStatement("insert into stud values(?,?,?)");
DataInputStream d=new DataInputStream(System.in);
System.out.println("Enter roll no.");
id=Integer.parseInt(d.readLine());
1297 System.out.println("Enter name");
name=d.readLine();
System.out.println("Enter branch");
br=d.readLine();
pst.setInt(1,id);
pst.setString(2,name);
pst.setString(3,br);
int c=pst.executeUpdate();
if(c>=0)
System.out.println("Record Inserted");
else
System.out.println("Record not Inserted");
cn.close();
}catch(Exception e){}
}
}

A. Statement st=cn.createStatement()

B. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

C. PreparedStatement pst=cn.prepareStatement()

D. None of these

Answer optionb

Marks: 2

Choose missing statements in following code from given options.


import javax.servlet.*;
public class HelloServlet extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
1298 {
res.setContentType("text/html");
pw.println("Hello Servlet");
pw.close();
}
}

A. import javax.servlet.http.*;

B. import java.io.*; PrintWriter pw=res.getWriter();

C. import javax.servlet.http.*; import java.util.*;

D. None of these

Answer optionb

Marks: 2

Find out error in the following program


import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class SessionDemo extends HTTPservlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
1299 {
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
HttpSession hs=req.getSession(true);
//Print Session ID
pw.println("Session ID= "+hs.getId());
}
}

A. statement where javax.servlet package is imported

B. statement where doGet() is defined


C. statement where getWriter() method is invoked

D. statement where http servlet class is extended

Answer optiond

Marks: 2

In following Java program fill statement showing ______.Select any one option from given options
import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
1300 String data = ______.getParameter("data");
Cookie cookie = new Cookie("MyCookie,data);
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. response

B. request

C. cookie

D. context

Answer optionb

Marks: 2

What will be the ouput of the following code.


import javax.servlet.*;
public class HelloServlet extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
1301 {
res.setContentType("text/html");
pw.println("<b>Hello Servlet</b>");
pw.close();
}
}

A. display Hello Servlet with plain style

B. display Hello Servlet with italic style

C. display Hello Servlet with plain italic style

D. display Hello Servlet with bold style

Answer optiond

Marks: 2

1302 Which Component of AWT provides a compact, multichoice , scrolling selection?

A. List

B. Choice

C. Panel

D. TextArea

Answer optiona

Marks: 1

1303 Identify the correct constructor of Font class?

A. Font( int fontstyle,int pointsize,String name)

B. Font( String name, int fontstyle,int pointsize)

C. Font( int fontstyle,String name,int pointsize)

D. Font(char name, int fontstyle,int pointsize)

Answer optionb
Marks: 1

1304 Indentify which is a valid constructor of MenuItem class?

A. Menuitem( )

B. Menuitem(int itemname )

C. menuitem(String Itemname)

D. MenuItem(String Itemname)

Answer optiond

Marks: 1

1305 In Swing Buttons are the subclasses of which class?

A. AbstractButton

B. Jbutton

C. Button

D. JRadioButton

Answer optiona

Marks: 1

1306 getKeyChar( ) and getkeyCode( ) methods belongs to which event class?

A. ActionEvent

B. MouseEvent

C. ItemEvent

D. KeyEvent

Answer optiond

Marks: 1

1307 ___________class provides an empty implementation of all methods in an Event Listener interface?

A. EventObject

B. Adapter

C. Event

D. AWTEvent

Answer optionb

Marks: 1

1308 Which of these is a bundle of information passed between machines?

A. Mime

B. Cache

C. Datagram

D. Socket

Answer optionc

Marks: 1

1309 The return type of getHostAddress() method is_____________

A. InetAddress

B. string

C. boolean

D. byte[]
Answer optionb

Marks: 1

1310 Name the type number belongs to JDBC ODBC Bridge driver?

A. Type 1

B. Type 2

C. Type 3

D. Type 4

Answer optiona

Marks: 1

1311 ______is a small piece of Information that is passed back & forth in HTTP request & response

A. Servlet

B. Applet

C. Cookie

D. Session

Answer optionc

Marks: 1

___________is a technology for developing web pages that supports dynamic content which helps developer to insert java code in HTML
1312 pages by making use of special tages <% _________%>.

A. Applet

B. servlet

C. JSP

D. AWT

Answer optionc

Marks: 1

1313 What is purpose of default constructor of Scrollbar( ) class?

A. To create scrollbar

B. To create vertical Scrollbar

C. To create Horizontal Scrollbar

D. To create Horizontal & Vertical scrollbar

Answer optionb

Marks: 2

1314 Which Gridlayout class constructor creates single column grid Layout?

A. GridLayout(int numRows, int numCol)

B. GridLayout()

C. GridLayout(int numRows, int numCol,int horizontal_space, int vertical_space)

D. GridLayout(int numRows)

Answer optionb

Marks: 2

1315 Which method of Graphics class is to display "HelloWorld" on the Applet shown in figure.

A. drawText("HelloWorld",30,30)

B. drawString("HelloWorld")

C. addString("HelloWorld",30,30)
D. drawString("HelloWorld",30,30)

Answer optiond

Marks: 2

1316 Which package contains all classes & methods required for Event Handling in Java?

A. java.applet

B. java.awt

C. java.awt.event

D. java.event

Answer optionc

Marks: 2

1317 Identify the components required to design this applet window shown in image?

A. Label, Button, TextField, Checkbox, List

B. Label, Button, TextField, Checkbox, CheckboxGroup

C. Label, Button, TextField,TextArea, Checkbox, CheckboxGroup

D. Label, Button, TextField,TextArea, Checkbox, CheckboxGroup, Choice

Answer optionb

Marks: 2

What correction is required in the following program to get output?


import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
public class demo extends JApplet
{
public void init ()
{
1318 Container co=getContentPane();
co.setLayout(new FlowLayout());

jc. addItem("Apple");
jc. addItem("Banana");
jc. addItem("Mango");
co.add(jc);
}
}
}

A. JcomboBox jc=new JComboBox() ;

B. JComboBox jc=new JcomboBox() ;

C. JComboBox jc=new JCombobox() ;

D. JComboBox jc=new JComboBox() ;

Answer optiond

Marks: 2

Identify the missing statement in the program?


import java.awt.*;
import java.awt.event.*;
import java.applet.*; public class
eventdemo extends Applet implements ActionListener
{
public void init()
{
Button b1= new Button("Click");
TextField t1=new TextField();
1319 add(b1);
add(t1);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{ t1.setText(b1.getLabel());
}
}
}

A. in place of getSource() , getActionCommand( ) should be used

B. b1.addActionlistener(this) should required in program

C. Syntax of actionPerformed( ) method is wrong


D. in place of getLabel() , getText() method is required in the program

Answer optionb

Marks: 2

What is the correct syntax of method required in the given program given below.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class eventdemo extends Applet implements ItemEvent
{
public void init()
{
Choice c= new Choice();
TextField t1=new TextField();
1320 add(c);
c.addItemListener(this);
add(t1);
}
public void _______________________(___________)
{
{ t1.setText(c.getSelectedIteml());
}
}
}

A. void itemstatechanged(ItemEvent ie)

B. public void itemStateChanged(ItemEvent ie)

C. public void ItemStatechanged(itemEvent ie)

D. public void Itemstatechanged(itemEvent ie)

Answer optionb

Marks: 2

1321 Identify the correct code to retrieve values from database

Statement st=con.createStatement(); ResultSet rs=st.execute();


{
A. --
}

Statement st=con.createStatement(); ResultSet rs=st.executeQuery();


{
B. --
}

PreparedStatement ps=con.createStatement(); ResultSet rs=st.executeUpdate();


{
C. --
}

PreparedStatement ps=con.createStatement(); ResultSet rs=st.executeQuery();


{
D. --
}

Answer optionb

Marks: 2

1322 Which of these is a return type of getAddress method of DatagramPacket class?

A. DatagramPacket

B. DatagramSocket

C. InetAddress

D. ServerSocket

Answer optionc

Marks: 1

1323 the various Control Supported by AWT are

A. Labels,Push Button

B. CheckBox,Choice List

C. Scrollbars,text fields,text area

D. All of these

Answer optiond
Marks: 1

1324 JApplet class is Derived form

A. Jpanel

B. Jframe

C. Jwindow

D. Applet

Answer optiond

Marks: 1

1325 which is default layout Manager for Japplet?

A. BorderLayout

B. FlowLayout

C. CardLayout

D. GridLayout

Answer optiona

Marks: 1

1326 Which of the following are subclasses of Container Class?

A. Window,Panel,ScrollPane

B. ScrollPane,Vector,String

C. Thread,Vector,String

D. Applet,Thread,Vector

Answer optiona

Marks: 1

1327 There are ____________ types of adjustment events

A. 1

B. 3

C. 5

D. 4

Answer optionc

Marks: 1

What is Second part of URL address


1328

A. Hostname

B. port number

C. file path

D. protocol

Answer optiona

Marks: 1

1329 Which of these method does not belongs to DatagramPacket class

A. getData()

B. getPort()

C. getLength()

D. getAddress()
Answer optiond

Marks: 1

1330 Callable Statement used to --------

A. calling procedure

B. execute queries

C. execute precomplied statement

D. none of the mentioned

Answer optiona

Marks: 1

1331 Which of following is not true for servlet?

A. it is persitent

B. platform independence

C. high performance

D. it is single threaded

Answer optiond

Marks: 1

find out missing line in following code.


i
mport java.awt.*;
importjava.swing.*
public class demo2 extends JApplet
{ JRadioButton b1=new JRadioButton("Buuton1') ;
JRadioButton b2=new JRadioButton("Button2");
1332 public void init()
{ cp.add(b1);
cp.add(b2);
ButtonGroup bg=new ButtonGroup();
bg.add(b1);
bg.add(b2);
} }

A. Container cp=getContentPane()

B. setLayout(new FlowLayout( ))

C. bg.addItemListener(this)

D. none of the mentioned

Answer optiona

Marks: 2

1333 Which of these events are notified by List?

A. ActionEvent

B. ItemEvent

C. AdjustmentEvent

D. both a and b

Answer optiond

Marks: 2
select missing statement in following code
/*<applet code="demo.class" width="310" hieght="140"></applet>*/
import java.awt;
import java.awt.event;

public class demo extends Japplet implements ActionListner


{ JComboBox cb=new JComboBox();
public void init( )
{
1334 cb.addItem("List1");
cb.addItem("List 2");
cb.addItem("List 3");
Container cp=getContentPane();
}
public void ActionPerformed(ActionEvent)
{
showStatus(cb.getSelectedItem()+"is selected");
}
}

A. cb.addActionListener(this); and cp.add(cb);

B. b.addActionListener(); and cp.add(b)

C. cp.addActinListener(this) and cp.add(b)

D. b.addActionListener(); and cp.add(cb1);

Answer optiona

Marks: 2

1335 Select correct constructors of DatagramPacket class?

A. DatagramPacket(byte data[],int size) DatagramPacket(byte data[],int offset ,int size)

B. DatagramPacket(int size,offset size) DatagramPacket(byte data[],int size ,int offset)

C. DatagramPacket(byte data[],int offset) DatagramPacket(int size,byte data[] ,int size)

D. DatagramPacket(byte data[],int size) DatagramPacket(int size ,int offset, byte size)

Answer optiona

Marks: 2

1336 Which are methods belongs to DataBaseMetaData?

A. getUserName(). ,isReadonly()

B. getRow() ,getResultSet()

C. executeQuery(),executeUpdate()

D. none of the mentioned

Answer optiona

Marks: 2

1337 When to use doPost Method?

A. if data is sensetive

B. data is greter than 1024 character

C. if your application don't need book mark

D. all of the above

Answer optiond

Marks: 2

Select missing statement in following code


/*<applet code="demo.class" width=300 height=200></applet>*/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*
public class demo extends JApplet implements ActionListener
JMenuBar mb=new JMenuBar();
JMenu mn=new JMenu("Menu");
1338 JMenuItem m1=new JMenuItem("Add Item");
JMenuItem m2=new JMenuItem("new Item");
public void init()
{ mn.add(m1);
mb.add(mn);
}
public void actionPerformed(ActionEvent e)
{ mn.add(m2); } }
A. setJMenuBar(mb);

B. setJMenuBar();

C. setMenuBar(mb);

D. setJMenuBar(mb);

Answer optiond

Marks: 2

1339 which of the following statement is used to scroll databse forward and backward

A. Statement si=con.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);

B. Statement si=con.createStatement(ResultSet.TYPE_FORWARD_ONLY)

C. Statement si=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE)

D. Statement si=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE)

Answer optionc

Marks: 2

Consider following program what should be the correction done in the program to get correct output?

Class demo
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc:odbc:jdbcodbcDrive);
System.ot.println("Drivers are Loaded");
Connection con=DriverManager.getConnection("jdbc:odbc:abc");
System.out.println("Connection estbalished");
s1="select * fromemp";
Statement st=con.createStaement();
ResultSet rs=st.executeQuery(s1);
rs=st.getResultSet();
1340 while(rs.netx())
{
System.out.println("rs.getString(1)+""+rs.getInt(2)+""rs.getInt(3));
}
con.close( );
}
catch(SQLEXception e)
{
System.out.println(e);
}
catch(Exception s)
{
System.out.println("s");

}
}
}

A. System.out.println("rs.getString("name)+""+rs.getInt("id"))+""rs.getInt("salary"));

B. missing package statement

C. Correction in CONNECTION statement

D. Both B and C option

Answer optionb

Marks: 2

Which of the following statement is true in case security consideration for JDBC.
A)normal unsigned applets are generally untrustworthy.
1341 B) Downloaded driver should be used for connection purpose only.
C)No automatic or implicit use of local credentials while connecting to remote database servers.
D)Untrusted applets should not be permitted to access to local database data.

A. A and B true

B. B and C true

C. A and C true

D. all of the above

Answer optiond

Marks: 2
consider the following four codes for index.jsp. Select any one option which will print following output.
1342 Cube of 3 is: 27

<html>
<body>

<%!
int cube(int n){
return n*n*n*;
A. }
%>

<%= "Cube of 3 is:"+cube(3) %>

</body>
</html>

<html>
<body>

<%!
int cube(int n){
B. return n*n*n*;
}
%>
<%out.print("Cube of 3 is:"+cube(3) %>
</body>
</html>

<html>
<body>

<%!
int cube(int n){
C. return n*n*n*;
}
%>
<%print("Cube of 3 is:"+cube(3)) %>
</body>
</html>

<html>
<body>

<% doc!
int cube(int n){
return n*n*n*;
D. }
%>

<%= "Cube of 3 is:"+cube(3) %>

</body>
</html>

Answer optiona

Marks: 2

1343 Which Class is used to get dimension of an Applet?

A. Dimension

B. Applet

C. Metrics

D. All of them

Answer optiona

Marks: 1

1344 What Checkbox method allows you to tell if a Checkbox is checked?

A. getLabel()

B. setLabel

C. getState()

D. None of above

Answer optionc

Marks: 1

1345 State true or false i) AWT is an extended version of swing ii) Paint( ) of Applet class cannot be overridden

A. i-true, ii-true

B. i-false,ii-true
C. i-false, ii-false

D. i-true, ii-false

Answer optionc

Marks: 1

1346 Matches the following Component from Figure

A. fig(a)-TextField,fig(b)-Button,fig(c)-Label,fig(d)-List,fig(e)-CheckBoxGroup,fig(f)-checkbox,fig(g)-Choice

B. fig(a)-Choice,fig(b)-JButton,fig(c)-Label,fig(d)-List,fig(e)-CheckBoxGroup,fig(f)-checkbox,fig(g)-TextField

C. fig(a)-Label,fig(b)-JButton,fig(c)-Choice,fig(d)-List,fig(e)-checkbox,fig(f)-CheckBoxGroup,fig(g)-TextField

D. None of Them

Answer optiona

Marks: 2

Select the missing statement in given code


import java.applet.*;
import java.awt.event.*; import java.awt.*;
public class MouseClickExample extends Applet implements MouseListener
{
int xpos;
int ypos;
int rect1xco,rect1yco,rect1width,rect1height;
boolean mouseEntered;
boolean rect1Clicked;
public void init()
{
rect1xco = 20;
rect1yco = 20;
rect1width = 100;
rect1height = 50;

}
public void paint(Graphics g)
{ g.setColor(Color.green);
g.fillRect(rect1xco,rect1yco,rect1width,rect1height);
g.setColor(Color.red);
g.drawString("("+xpos+","+ypos+")",xpos,ypos);
1347 if (rect1Clicked) g.drawString("You clicked in the Rectangle",20,120);
else g.drawString("You clicked outside of the rectangle",20,120);
if (mouseEntered) g.drawString("Mouse is in the applet area",20,160);
else g.drawString("Mouse is outside the Applet area",20,160);
}
public void mouseClicked (MouseEvent me) {
xpos = me.getX();
ypos = me.getY();
if (xpos > rect1xco && xpos < rect1xco+rect1width && ypos >rect1yco &&
ypos < rect1yco+rect1height) rect1Clicked = true; else
rect1Clicked = false; repaint();
}
public void mousePressed (MouseEvent me) {}
public void mouseReleased (MouseEvent me) {}
public void mouseEntered (MouseEvent me) {
mouseEntered = true;
repaint();
}
public void mouseExited (MouseEvent me) {
mouseEntered = false;
repaint();
}
}

A. addMouseListener(this);

B. addMouseMotionerListner(this)

C. both I and II

D. None of these

Answer optiona

Marks: 2

1348 which are the methods are used for Connection interface

A. public Statement createStatement()

B. public Statement createStatement(int resultSetType,int resultSetConcurrency)

C. public void setAutoCommit(boolean status)

D. All of the above

Answer optiond

Marks: 2
JSP pages have access to implicit objects that are exposed automatically. One such object that is available is request. The request
1349 object is an instance of which class?

A. HttpRequest

B. ServletRequest

C. Request

D. HttpServletRequest

Answer optiond

Marks: 2

1350 How does Tomcat execute a JSP?

A. As a CGI script

B. As an independent process

C. By one of Tomcat's threads

D. None of the above is correct

Answer optionc

Marks: 1

1351 Below show the figure matches with respect to output

import java.awt.*;
import java.applet.*;
/*<applet code="Border.class" width=300 height=300> */

public class Border extends Applet{

public void init()


{
BorderLyout br=new BorderLayout();
setLayout(br);
Button b1=new Button("NORTH");
Button b2=new Button("SOUTH");
A. Button b3=new Button("EAST");
Button b4=new Button("WEST");
Button b5=new Button("CENTER");
add(b1,BorderLayout.NORTH);
add(b2,BorderLayout.SOUTH);
add(b3,BorderLayout.EAST);
add(b4,BorderLayout.WEST);
add(b5,BorderLayout.CENTER);
}
}

import java.awt.*;
import javax.swing.*;

public class Border {


JFrame f;
Border(){
B. f=new JFrame();

JButton b1=new JButton("NORTH");;


JButton b2=new JButton("SOUTH");;
JButton b3=new JButton("EAST");;
JButton b4=

import java.awt.*;
import javax.swing.*;

public class Border {


Border(){
C.
JButton b1=new JButton("NORTH");;
JButton b2=new JButton("SOUTH");;
JButton b3=new JButton("EAST");;
JButton b4=new JButton("WEST");;

import java.awt.*;
import javax.swing.*;

public class Border {


JFrame f;
Border(){
D. f=new JFrame();

JButton b1=new JButton("NORTH");;


JButton b2=new JButton("SOUTH");;
JButton b3=new JButton("EAST");;
JButton b4=

Answer optiona

Marks: 2
1352 Select proper code for given image as shwon in below

import java.awt.*;
import java.applet.*;
public class choice11 extends Applet
{
public void init()
{
Choice os=new Choice();
os.add("wnn18");
A. os.add("wnn xp");
os.add("wnn nt");
os.add("win 2000");
add(os);
}
}
/*<applet code="choice11" height=200 width=300>
</applet>*/

import java.awt.*;
import java.applet.*;
public class choice11 extends Applet
{
public void init()
{
Choice os=new Choice();
B. os.add("wnn18");
os.add("wnnxp");
add(os);
}
}
/*<applet code="choice11" height=200 width=300>
</applet>*/

import java.awt.*;
import java.applet.*;
public class choice11 extends Applet
{
public void init()
{
C. Choice os=new Choice();
os.add("wnn18");
os.add("wnnxp");
os.add("win 2000");
add(os);
}
}

import java.awt.*;
import java.applet.*;
public class choice11 extends Applet
{
public void init()
{
Choice os=new Choice();
D. os.add("wnn18");
os.add("wnnxp");
os.add("wnnnt");
os.add("win 2000");
}
}
/*<applet code="choice11" height=2

Answer optiona

Marks: 2

For the following code select the method that can be used to handle event
import java.awt.*;
import java.awt.event.*;

class AEvent extends Frame implements ActionListener{


TextField tf;
AEvent(){

tf=new TextField();
tf.setBounds(60,50,170,20);

Button b=new Button("click me");


b.setBounds(100,120,80,30);

b.addActionListener(this);
1353 add(b);add(tf);

setSize(300,300);
setLayout(null);
setVisible(true);

public void actionPerformed(ActionEvent e){


tf.setText("Welcome");
}

public static void main(String args[]){


new AEvent();
}
}

A. itemStateChanged(ActionEvent e)

B. adjustmentPerformed(AdjustementEvent e)

C. actionPerformed(ActionEvent e)
D. None of the them

Answer optionc

Marks: 2

what are the content are shown by following code


import java.awt.*;
import javax.swing.*;

public class JTabbedPaneDemo extends JApplet


{
public void init()
{
JTabbedPane jtp = new JTabbedPane();

jtp.addTab("Cities", new ButtonPanel());


jtp.addTab("Table", new TablePanel());
jtp.addTab("flavours", new flavoursPanel());
jtp.addTab("colours", new ColorsPanel());

Container contentPane = getContentPane();


contentPane.add(jtp);
}
}

class ButtonPanel extends JPanel


{
public ButtonPanel()
{
JButton b1 = new JButton("Parbhani");
JButton b2 = new JButton("Pune");
JButton b3 = new JButton("Mumbai");
JButton b4 = new JButton("Aurangabad");
JButton b5 = new JButton("Nanded");

add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
}
}
class ColorsPanel extends JPanel
{
public ColorsPanel()
{
JCheckBox cb1=new JCheckBox("Red");
add(cb1);
JCheckBox cb2=new JCheckBox("Green");
add(cb2);
1354 JCheckBox cb3=new JCheckBox("Blue");
add(cb3);
}

class TablePanel extends JPanel


{
public TablePanel()
{
String colHead[] = {"Event Source", "Event Type", "Event Listener"};
Object data[][] = {
{"Button", "ActionEvent", "ActionListener"},
{"ScrollBar", "AdjustmentEvent", "AdjustmentListener"},
{"Choice", "ItemEvent", "ItemListener"},
{"TextField", "TextEvent", "TextListener"}
};

JTable table = new JTable(data, colHead);

int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;

JScrollPane jsp = new JScrollPane(table, v, h);

setLayout(new BorderLayout());
add(jsp, BorderLayout.CENTER);
}
}

class flavoursPanel extends JPanel


{
public flavoursPanel()
{
JComboBox jc=new JComboBox();
jc.addItem("vannila");
jc.addItem("Chocolate");
jc.addItem("strabary");
add(jc);

What will be the output of the above program?

The output contains JTabbedPane,Jbutton,JCheckBox,


A. Jtable,

The output contains button,JCheckBox,


B. Jtable,JComboBox with canvas

The output contains ,JCheckBox,


C. table,ComboBox with Frame

The output contains JTabbedPane,Jbutton,JCheckBox,


D. Jtable,JComboBox with JPanel
Answer optiond

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.io.*;
import java.sql.*;
import java.util.*;
class dri
{
public static void main(String x[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver registered with the driver manager class");
System.out.println("connected");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Roll no");
int a=Integer.parseInt(br.readLine());
System.out.println("Enter name");
String b=br.readLine();
System.out.println("Enter branch");
String c=br.readLine();
1355
System.out.println("Enter Marks");
int d=Integer.parseInt(br.readLine());
//query for inserting values in the table
PreparedStatement p=con.prepareCall("insert into stud values(?,?,?,?)");
p.setInt(1,a);
p.setString(2,b);
p.setString(3,c);
p.setInt(4,d);
p.executeUpdate();
System.out.println("Record inserted")
}

catch(Exception e)
{
System.out.println(e);
}

A. Missing semicolon

B. Missing {

C. Missing }

D. Missing connection

Answer optiond

Marks: 2

What is the output of following Program

import java.sql.*;
public class jdbcConn {
public static void main(String[] args) throws Exception{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/testDb","name","pass");
Statement stmt = con.createStatement();
String query = "insert into emp values(2,'name1','job')";
String query1 ="insert into emp values(5,'name2','job')";
String query2 = "select * from emp";
ResultSet rs = stmt.executeQuery(query2);
int no_of_rows = 0;
while (rs.next()) {
1356 no_of_rows++;
}
System.out.println("No. of rows before commit statement = "+ no_of_rows);
con.setAutoCommit(false);
stmt.execute(query1);
stmt.execute(query);
con.commit();
rs = stmt.executeQuery(query2);
no_of_rows = 0;
while (rs.next()) {
no_of_rows++;
}
System.out.println("No. of rows after commit
statement = "+ no_of_rows);
}

A. Error in main()

B. Error in loop

No. of rows before commit statement = 1


C. No. of rows after commit statement = 3

D. None of them

Answer optionc

Marks: 2
Consider the following program
Select the statement that should be added to the program to get correct output.

importjava.sql.*;
class create {
public static void main main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.jdbcOdbcDriver");
System.out.printf(�Driver Loaded�);
String url=� jdbc.odbc.:dsn1�;
Connection con=DriverManager.getConnection(url);
1357 System.out.println(�Connection established �);
String sql=�create table employee1(emp_id int,emp_name char�);
PreparedStatement ps1=con.prepareStatement(sql);

System.out.println(�table created�);
ps1.close();
con.close();
}
Catch(Execption e)
{
}
}
}

A. con.close();

B. ps1.executeUpdate();

C. ps1.close();

D. None of them

Answer optionb

Marks: 2

What is the output of program

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
private String message;
public void init() throws ServletException
{
message = "Hello World";
}
1358 public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1>" + message + "</h1>");
}

public void destroy()


{
}
}

A. Hello Word

B. Missing Semicolon

C. Missing Package ststement

D. None of these

Answer optiona

Marks: 2

1359 AWT classes are contained in the __________ package

A. java.awt

B. java.util

C. java.net

D. java.applet

Answer optiona

Marks: 1

1360 The correct hierchy for panel is

A. Component-Container-Window-Panel

B. Component-Container-Applet-Panel

C. Component-Container-Panel
D. Container-Component-Panel

Answer optionc

Marks: 1

1361 To display text on the applet ______ method is used.

A. showString()

B. drawString()

C. println()

D. printString()

Answer optionb

Marks: 1

1362 AppletViewer tool is available in which of the folder of JDK

A. bin

B. lib

C. source

D. class

Answer optiona

Marks: 1

1363 Which of the following is true about AWT and Swing Component?

AWT Components create a process where as Swing


A. Component create a thread

AWT Components create a thread where as Swing


B. Component create a process

C. Both AWT and Swing Component create a process

D. Both AWT and Swing Component create a thread

Answer optiona

Marks: 1

Given the following servlet mapping definition for the web application named 'secureapp',
<servlet>
<servlet-name>ProcessLoginData</servlet-name>
<servlet-class>DoLogin</servlet-class>
</servlet>
1364 <servlet-mapping>
<servlet-name>ProcessLoginData</servlet-name>
<url-pattern>do/Login</url-pattern>
</servlet-mapping>
which of the following URLs will correctly request the Servlet?

A. http://localhost:8080/secureapp/do/Login?name="bob"

B. http://localhost:8080/secureapp/doLogin?name="bob"

C. http://localhost:8080/Login?name="bob"

D. http://localhost:8080/secureapp/Login?name="bob"

Answer optiona

Marks: 2
Observe the following code

import java.awt.*;
import javax.swing.*;
/*<applet code="JTableDemo.class" width=400 height=500>
</applet> */
public class JTableDemo extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
1365 final String[] colHeads = { "Name", "Phone", "Fax"};
final Object[][] data = {
{"Prashant", "12345","6789"},
{"Rupesh", "12345", "23456"}
};
JTable table = new JTable(data, colHeads);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
JScrollPane jsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}

A. The output is obtained in table with two rows and three columns.

B. The output is obtained in table with two rows and two columns.

C. The output is obtained in table with three rows and three columns.

The output is obtained in table with two rows and three columns
D. with horizontal and vertical scrollbar

Answer optiond

Marks: 2

consider following code. what is an ouput of given code?

import java.sql.*;
class Rsmd{
public static void main(String args[]){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
PreparedStatement ps=con.prepareStatement("select * from employee");
ResultSet rs=ps.executeQuery();

ResultSetMetaData rsmd=rs.getMetaData();
1366
System.out.println("Total columns: "+rsmd.getColumnCount());
System.out.println("Column Name of 1st column: "+rsmd.getColumnName(1));
System.out.println("Column Type Name of 1st column: "+rsmd.getColumnTypeName(1));

con.close();

}catch(Exception e){ System.out.println(e);}

}
}

Total columns: 2
A. Column Name of 1st column: empid
Column Type Name of 1st column: INTEGER

Column Name of 1st column: empid


B. Column Type Name of 1st column: INTEGER

Total columns: 2
C. Column Name of 1st column: empid

Total columns: 2
D. Column Type Name of 1st column: INTEGER

Answer optiona

Marks: 2
Choose missing statements in following code from given options.
public class GetSession extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(false);
try {
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.println("<html><body>");
if (session == null) {
writer.println("<p>You are not logged in</p>");
} else {
writer.println("Thank you, you are already logged in");
writer.println("Here is the data in your session");
1367 Enumeration names = session.getAttributeNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
Object value = session.getAttribute(name);
writer.println("<p>name=" + name + " value=" + value + "</p>");
} }
writer.println("<p><a href=\"/ServletSession/login.html\">Return" +
"</a> to login page</p>");
writer.println("</body></html>");
writer.close();
} catch (Exception e) {
e.printStackTrace();
} } }

import javax.servlet.http.*;
import java.io.*;
A. import java.util.*;
import javax.servlet.*;

import javax.servlet.http.*;
B. import java.util.*;

import javax.servlet.*;
C. import java.util.*;

import javax.servlet.http.*;
D. import java.io.*;

Answer optiona

Marks: 2

1368 A checkbox is a control that consist of a :

A. � Combination of a small Box

B. � � � A Label

C. � � Combination of a Large Box and a label

D. � Both a & b

Answer optiond

Marks: 1

1369 Which of the following is mediator between real web server and client application

A. Host

B. Proxy

C. HTTP

D. TCP

Answer optionb

Marks: 1

1370 In the applet window a user wants to arrange all component one after another Which statement will work efficiently

A. setLayout(new cardLayout() );

B. setFlowLayout();

C. FlowLayout f=new FlowLayout();

D. setLayout(new FlowLayout());

Answer optiond

Marks: 2
State whether given code is correct or wrong:
import java.awt.*;
import java.applet.*;
class Demo extends Applet
{
CheckBox c1,c2;
1371 public void init(){
C1=new CheckBox(�awt�);
C2=new CheckBox();
System.out.println(c2.getLabel());
}
}

A. TRUE

B. FALSE

C.

D.

Answer optionb

Marks: 2

1372 When a program class implements an interface, it must provide behavior for

A. two methods defined in that interface

B. any methods in a class

C. only certain methods in that interface

D. all methods defined in that interface

Answer optiond

Marks: 2

Which JDBC driver maps the JDBC calls to the native method calls, which are
1373 passed to the local native Call Level Interface (CLI)?

A. Native-API-Partly-Java driver

B. JDBC-ODBC Bridge driver

C. Native Protocol Pure-Java driver

D. JDBC-Net-Pure-Java driver

Answer optiona

Marks: 2

What will be the error in following code?


import java.awt.*;
import java.applet.*;
public class Demo extends Applet
{
List l;
public void init(){
1374 l=new List(2);
l.add(�Satara�);
l.add(�Akola�);
l.add(�Pune�,2);
int x=getItem(2);
}
}

A. List index will out of bound

B. the return type of method getItem () is not match

C. Syntex error in l.add (“Pune”,2);

D. List l is created

Answer optionb

Marks: 2

What will be the result of executing the following code snippet?


1375 Statement sql2 = con.createStatement();
int result=sql2.executeUpdate("Select * From Publishers");

A. Will throw an exception

B. Will result in compilation error


C. Will return the number of rows retrieved from Publishers table

D. Will return null

Answer optionb

Marks: 2

1376 Why are swing component termed as lightweight ?

A. they depend on native platform

B. they do not depend on native platform

C. they depend on native application

D. they do not depend on native application

Answer optionb

Marks: 1

1377 Which method is used to close a swing frame?

A. setTitle()

B. setDefaultCloseOperation()

C. setVisible()

D. pack()

Answer optionb

Marks: 1

1378 What is the default layout for a dialog?

A. FlowLayout

B. GridLayout

C. CardLayout

D. BorderLayout

Answer optiond

Marks: 1

1379 Which method is used to display Label on checkbox?

A. boolean getState()

B. void setState(boolean)

C. String getLabel()

D. void setLabel()

Answer optionc

Marks: 1

1380 How to remove the event listener?

A. Using removeTypeListener( ) method.

B. Using removeListener( ) method.

C. Using removeEvent( ) method.

D. It is not possible to remove the event listener.

Answer optiona

Marks: 1

1381 In which package the methods for receiving and processing events are defined

A. java.event
B. java.awt.event

C. java.event.event

D. java.util.event

Answer optionb

Marks: 1

1382 Which of the following is correct event handling methods

A. mousePressed(MouseEvent e){}

B. mousePressed(MouseClicked e){}

C. functionkey(KeyPressed k){}

D. mouserelese(MouseMoved e){}

Answer optiona

Marks: 1

1383 Which interface is important from java.sql package in JDBC?

A. Statement

B. Result

C. Connection

D. None of these

Answer optionc

Marks: 1

1384 Which method is used to extract cookies from a request?

A. getCookies()

B. getData()

C. getHeaders()

D. getParameter()

Answer optiona

Marks: 1

1385 Which methods are used to Extract all names and value pairs from the Http request

A. getParameter() and getParameterValues()

B. getParameter() and getParameterNames()

C. getParameterNames() and getParameterValues()

D. getParameterNameValues() and getParameter()

Answer optionc

Marks: 2

1386 Suppose A is an inner class in Test. A is compiled into a file named _________.

A. A.class

B. Test.class

C. A$Test.class

D. Test&A.class

Answer optionb

Marks: 2

1387 What is the disadvantage of Type-4 Native-Protocol Driver?


A. At client side, a separate driver is needed for each database.

B. Type-4 driver is entirely written in Java

C. The driver converts JDBC calls into vendor-specific database protocol

D. It does not support to read MySQL data.

Answer optiona

Marks: 2

1388 Suppose the servlet class named Test does not have the package statement, by default, you use ________ to invoke it

A. http://localhost:8080/examples/servlet/Test

B. http://localhost:8080/examples/servlet/test

C. http://localhost:8080/Test

D. http://localhost:8080/test

Answer optiona

Marks: 2

1389 Every layout manager is an instance of __________.

A. the LayoutManager interface

B. the LayoutManager class

C. the Layout interface

D. the Layout class

Answer optiona

Marks: 1

1390 A MenuItem object can generate __________ events.

A. ActionEvent

B. ItemEvent

C. ComponentEvent

D. ContainerEvent

Answer optiona

Marks: 1

1391 ___________ class is designed to connect to server sockets.

A. Socket

B. SocketClient

C. ClientSocket

D. SerevrSocket

Answer optiona

Marks: 1

1392 Invoking Class.forName() method may throw ___________.

A. RuntimeException

B. ClassNotFoundException

C. IOException

D. SQLException

Answer optionb

Marks: 1
1393 The GET and POST methods are specified in _________.

A. a CGI program

B. Java program

C. an HTML form

D. a URL string

Answer optionc

Marks: 1

1394 To compile a Java servlet program, the ___________ file must be in the classpath.

A. TomcatRootDir\servlet.jar

B. TomcatRootDir\common\servlet.jar

C. TomcatRootDir\common\lib\servlet.jar

D. TomcatRootDir\common\bin\lib\servlet.jar

Answer optionc

Marks: 1

1395 _________ contains classes and interfaces required to build servlets

A. javax.servlet

B. HttpServlet

C. ServletRequest

D. ServletResponse

Answer optiona

Marks: 2

1396 For a HttpSession, say session, how do you get its attribute?

A. session.getValue("lastName")

B. session.getAttribute("lastName")

C. session.value("lastName")

D. session.attribute("lastName")

Answer optionb

Marks: 2

1397 Which of the following statements are true?

A. The model-view-controller (MVC) approach is a way of developing components by separating data storage and handling from the visual representation of the da

B. The model-view-controller (MVC) approach makes multiple views possible so that data can be shared through the same model.

C. The model-view-controller (MVC) approach simplifies the task of writing complex applications and makes the components scalable and easy to maintain. Change

D. ALL

Answer optiond

Marks: 2

1398 To get the depth of a JTree jTree, invoke ________________

A. jTree.getRoot().getDepth()

B. jTree.getDepth()

C. jTree.getTreeRoot().getDepth()

D. jTree.getRoot().getSize()

Answer optiona
Marks: 2

Select the proper command to run the following code


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
/*
<applet code="combodemo11" width=300 height=100>
</applet>
*/
public class combodemo11 extends JApplet
{
1399 public void init()
{
Container co = getContentPane();
co.setLayout(new FlowLayout());
JComboBox jc=new JComboBox();
jc.addItem("cricket");
jc.addItem("football");
jc.addItem("hockey");
jc.addItem("tennis");
co.add(jc);
}
}

A. java combodemo11

B. java combo11

C. appletviewer combodemo11.java

D. All of above

Answer optionc

Marks: 2

1400 Java servlets are better than the CGI programs because ______________.

A. Servlets are written in Java while CGI programs are written in Perl or other languages. you can develop servlets with the support of Java API for accessing

B. Servlets are dynamically executed.

C. For each CGI execution, the Web browser spawns a new process to execute a CGI program. However, all servlets are executed within the servlet engine. Each e

D. A and C

Answer optiond

Marks: 2

The ________ directive lets you provide information for the page, such as importing classes and setting up content type. The page
1401 directive can appear anywhere in the JSP file.

A. page

B. include

C. tablib

D. import

Answer optiona

Marks: 2

1402 ______________________class encapsulates AWT events.

A. Button

B. AWTEvent

C. AWTEVENTMulticaster

D. BorderLayout

Answer optionb

Marks: 1

1403 ____________________class creates blank sementics free window

A. Choice

B. CardLayout

C. AWTEvent
D. Canvas

Answer optiond

Marks: 1

1404 The method drawRect() is used to display an ___________________________

A. field rectangle

B. outlined rectangle

C. Half field rectangle

D. Half outlined rectangle

Answer optionb

Marks: 1

1405 Swing is the set of ____________ that provides more powerful & flexible components as compare to AWT.

A. functions

B. Members

C. Classes

D. Objects

Answer optionc

Marks: 1

1406 In which class the constructors are not visible

A. socket class

B. address class

C. Inetaddress class

D. sever class

Answer optionc

Marks: 1

1407 Type 3 driver is also known as_________________

A. JDBC-ODBC Bridge Driver

B. JDBC-Native API

C. JDBC-net Pure Java

D. None of above

Answer optionc

Marks: 1

1408 Backbone of JDBC Architecture is ________________

A. Driver Interface

B. Driver Manager

C. Connection Manager

D. Connection Interface

Answer optionb

Marks: 1

1409 JDBC-ODBC bridge product provide _________ access via ____________.

A. ODBC drivers,JDBC drivers

B. Drivers,Application
C. Application,Drivers

D. JDBC driver, ODBC drivers

Answer optiond

Marks: 1

1410 Which of these protocol uses service() method to process the request in servlet?

A. TCP

B. UDP

C. HTTP

D. SHTTP

Answer optionc

Marks: 1

1411 _____ Method returns true if the server created the session and it has not yet been accessed by the client.

A. isSession()

B. isNew()

C. getId()

D. invalidate()

Answer optionb

Marks: 1

What is the purpose of following code?


1412 JTextField jtf=new JTextField(15)

A. Defining Textfield

B. Adding textfeld

C. Layout managing

D. content pane creation

Answer optiona

Marks: 2

1413 No of constructors of JComboBox are______________

A. 1

B. 2

C. 3

D. 4

Answer optionb

Marks: 2

1414 ___________________ is not a constructor of JTree class

A. JTree(Hashtable ht)

B. JTree(Object obj[])

C. JTree(Vector v)

D. JTree(Button b[])

Answer optiond

Marks: 2
Which type of the following program :
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class OuterClass extends JFrame
{
public static void main(String[] args)
{
OuterClass outer = new OuterClass();
JButton button = new JButton(�Don�t click me!�);
button.addActionListener(new ActionListener ()
1415 {
public void actionPerformed(ActionEvent event)
{
System.out.printIn(�Ouch !�);
}
});
outer.add(button);
outer.pack();
outer.setVisible(true);
}
}

A. Anonymous Inner class

B. Local Inner class

C. Member Inner class

D. Static Inner class

Answer optiona

Marks: 2

1416 When client and server is communicating using TCP protocol then communication is ____________

A. connection-oriented, concurrent

B. connectionless, iterative

C. connection-oriented, iterative

D. connectionless, concurrent

Answer optiona

Marks: 2

1417 Which of the following statements is true concerning JDBC?

A. It is Useful for all object-oriented language

B. It consist three main layers.

C. It is similar concept to ODBC.

D. It is language independent.

Answer optionc

Marks: 2

1418 API is which of the following

A. The same thing as ODBC

B. Middleware that does not provide access to database

C. Middleware that provide access to database.

D. The same thing as JDBC.

Answer optionc

Marks: 2

1419 Three-tier Architecture includes which of the following.

A. Two client layers and one sever layers

B. Three server layers

C. Three client layers

D. client layer and two server layers

Answer optiond
Marks: 2

1420 The Status code _____ shows �Resource Temporarily Moved�

A. 202

B. 200

C. 302

D. 503

Answer optionc

Marks: 2

Which will be correct line of code at line no 13


1.
2. import java.awt.*;
3. import javax.swing.*;
4. /*
5. <applet code=�JTextField1� width=300 height=50>
6. </applet>
7. */
8. public class JTextField 1 extends JApplet
1421 9. {
10. JTextField jtf;
11. public void init()
12. {
13. �������
14. contentPane.setLayout(new FlowLayout());
15. jtf=new JTextField(15);
16. contentPane.add(jtf);
17. }
18. }

A. Container contentPane=getContent();

B. Container contentPane=ContentPane(a);

C. Container contentPane=getContentPane(int a);

D. Container contentPane=getContentPane();

Answer optiond

Marks: 2

What will be output of following code.


Import javax.swing>*;
Public class Test {
Public static void main(String[] args) {
JButtonjbtOK=new JButton(�OK�);
1422 System.out.print(jbtOK.isVisible()) + �,�);
JFrame frame =new JFrame();
System.out.println(frame.isVisible());
}
}

true,true
A.

B. true,false

C. false,true

D. false,false

Answer optionb

Marks: 2

Analyse the following code


import javax.swing.*;
Import javax.swing.border.*;
Import java.awt.*;
Public class Test extends JFrame {
Public Test() {
Border border=new TitledBorder(�My button�);
Jbutton jbt1=new JButton(�OK�);
Jbutton jbt=new JButton(�Cancel�);
Jbt1.setBorder(border);
1423 Jbt2.setBorder(border);
Add(jbt1,BorderLayout.NORTH);
Add(jbt2,BorderLayout.NORTH);
}
Public static void main(String[] args){
JFrame frame=new Test();
Frame.setSize(200,100);
Frame.setDefaultCloseOperation(JFrame.ExIT_ON_CLOSE);
Frame.setVisible(true);
}
}

A. The program has runtime error


B. Two buttons displayed,but only one button has the border

C. The program has compile error.

D. Two buttons displayed with same border

Answer optionc

Marks: 2

For the following code select the method that can be used to handle event.
import java.awt.*;
import java.awt.event.*;

class AEvent extends Frame implements ActionListener{


TextField tf;
AEvent(){

tf=new TextField();
tf.setBounds(60,50,170,20);

Button b=new Button("click me");


b.setBounds(100,120,80,30);

b.addActionListener(this);

1424 add(b);
add(tf);

setSize(300,300);
setLayout(null);
setVisible(true);

public void __________________(ActionEvent e){


tf.setText("Welcome");
}

public static void main(String args[]){


new AEvent();
}
}

A. actionPerformed(ActionEvent e)

B. itemStateChanged(ActionEvent e)

C. itemStateChanged(ItemEvent e)

D. adjustmentPerformed(AdjustmentEvent e)

Answer optiona

Marks: 2

What is output of follwong program ?


import java.awt.*;
import java.awt.event.*;
public class MyWc extends Frame implements WindowListener
{
public static void main(String argv[])
{
MyWc mwc = new MyWc();
}
1425 public void windowClosing(WindowEvent we){
System.exit(0);
}
public void MyWc()
{
setSize(300,300);
setVisible(true);
}
}

A. Error at compile time

B. Visible Frame created that that can be closed

C. Compilation but no output at run time

D. Error at compile time because of comment before� import� statements

Answer optiona

Marks: 2
Choose missing statements in following code from given options.
Import java.sql.*;
Class conn
{
Public static void main(String args[])
{
try
{
System.out.println(�Drivers are properly loaded�);
String url=�jdbc:odbc:abc�;
Connection con=DriveManager.getConnection(url);
1426 System.out.println(�Connection Established�);
con.close();
}
catch(SQLExcption e)
{
System.out.println(�SQL Error has occurred �);
catch(Exception e)
{
System.out.println(�Error! Connection not established�);
}
}
}

A. ClassforName(“sun.jdbc.odbc.OdbcJdbcDriver”);

B. Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

C. Class.forName(“sun.odbc.jdbc.jdbcOdbcDriver”);

D. None of the above

Answer optionb

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
Import java.sql.*;
Class Test
{
Public static void main(String args[])
{
try
{
System.out.println(�Drivers are properly loaded�);
String url=�jdbc:odbc:abc�;
1427 System.out.println(�Connection Established�);
con.close();
}
catch(SQLExcption e)
{
System.out.println(�SQL Error has occurred �);
catch(Exception e)
{
System.out.println(�Error! Connection not established�);
}
}}

A. Connection con=DriverInterface.getConnection(url);

B. Connection con=DriveManager.getConnection(url);

C. Connection con=DriveManager.setConnection(url);

D. Connection con=DriveInterface.getConnection(url);

Answer optionb

Marks: 2

what is the output of following code

import java.sql.*;

class cont {
public static void main(String args[]){
try {
Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver�);
System.out.println(�Drivers are properly loaded�);
String url=�jdbc:odbc:abc�;
Connection con=DriverManager.getConnection(url);
System.out.println(�Connection to database created�);
1428 con.close();
}
catch(SQLExcption e)
{
System.out.println(�SQL Error �);
{
catch(Exception e)
{
System.out.println(�error�);
}
}
}

A. Connection to database created

B. Error

C. Drivers are properly loaded


D. both b and c

Answer optiond

Marks: 2

what is the output of following code


Try{
String sql=�update emp set salary=? Where id=?�;
PreparedStatement pstmt=con prepareStatement(sql) ;
1429 }
Catch(SQL Exception e)
{
}

A. update emp by accepting salary

B. update emp by accepting id and salary as aparameter

C. update emp by accepting salary and id as a parameter

D. None of the above

Answer optionc

Marks: 2

what is the output of following code

import java.sql.*;

class StudentData {
public static void main(String args[])
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:stud");
1430 PreparedStatement ps = con.prepareStatement("select * from Student where Marks > ?");
ps.setInt(1,40);
ResultSet rs = ps.executeQuery();
System.out.println("marks");
while(rs.next())
System.out.println(rs.getString(2));
con.close();
} catch(Exception e){ }
}
}

A. marks>40

B. marks < 40

C. c) both a and b

D. None of above

Answer optiona

Marks: 2

Find out the missing statement


<html>
<head>
<title>Reading Cookies</title>
</head>
<body>
<center>
<h1>Reading Cookies</h1>
</center>
<%
Cookie cookie = null;
Cookie[] cookies = null;
// Get an array of Cookies associated with this domain
1431 if( cookies != null ){
out.println("<h2> Found Cookies Name and Value</h2>");
for (int i = 0; i < cookies.length; i++){
cookie = cookies[i];
out.print("Name : " + cookie.getName( ) + ", ");
out.print("Value: " + cookie.getValue( )+" <br/>");
}
}else{
out.println("<h2>No cookies founds</h2>");
}
%>
</body>
</html>

A. cookies = request.getCookies();

cookies = response.getCookies();
B.

C. cookies = response.Cookies();

D. cookies = request.setCookies();

Answer optiona
Marks: 2

1432 Which of the following class is Derived from Container Class?

A. Componenet

B. Panel

C. MenuComponent

D. List

Answer optionb

Marks: 1

1433 Which Method Is used to register a mouse Motion Listner

A. addMouse()

B. addMouseListener()

C. addMouseMotionListener()

D. eventMouseMotionListener()

Answer optionc

Marks: 1

1434 Modification of the text can be controlled by

A. isEditable()

B. setEditable()

C. Echochar()

D. nane of the above

Answer optionb

Marks: 2

1435 �����.method is used to find the host name of URL?

A. gethost()

B. GetHost()

C. Gethost()

D. getHost()

Answer optiond

Marks: 2

1436 In the following statements identify the disadvantages of CGI?

A. If number of clients increases, it takes more time for sending response

B. For each request, it starts a process and Web server is limited to start processes

C. It uses platform dependent language e.g. C, C++, perl

D. All mentioned above

Answer optiond

Marks: 2

1437 java Applets are used to create ��������Applications

A. graphical

B. userintractive

C. both (a) and (b)

D. none of these
Answer optionc

Marks: 2

1438 �����method can be used to obtain refrence to the container that generate ContainerEvent.

A. getContainer()

B. getContainerCommand()

C. getActionEvent()

D. getContainerEvent()

Answer optiond

Marks: 2

1439 Are Resultsets Updateable?

A. yes,but if only you call the method openCursor()on ResultSet,and if the driver and database supprot this option

B. yes,but if only you indicate concurrent strategy when executing the statement ,and if the driver and database supprot this option

C. yes,but if the resultset is an object of class UpdatableResultSet ,and if the driver and database support this option

D. no,ResultSets are never Updatable.

Answer optionc

Marks: 2

1440 Which Of these Compenent can be added to frame?

A. Label

B. Button

C. CheckboxGroup

D. All of the Above

Answer optiond

Marks: 1

1441 Which of the subclasses of java.awt.component?

A. Container classes

B. Net user interface classes

C. Helper classes such as Color and Font

D. Layout managers

Answer optiona

Marks: 1

1442 The method ____gets the text of the button jtb is

A. jtb.text( )

B. jtb.getText( )

C. jtb.FindText( )

D. jtb.retrieveText( )

Answer optionb

Marks: 1

1443 Which package is necessary to import all java classes concerned with database connectivity?

A. java.io.*

B. java.mysql.*

C. java.sql.*
D. java.awt.*

Answer optionc

Marks: 1

Advantages of Cookies are ____________

A. It is used to maintain the state information.

1444 B. Cookies are maintained at client side.

C. It will not work if cookie is disabled from browser.

D.Only textual information can be set in cookie object.

A. All are correct.

B. Only A and B are correct.

C. Only A,B and C are correct.

D. Only A and C are correct.

Answer optiona

Marks: 2

Consider the following program. Find which statement contains error.

import java.awt.*;
import javax.swing.*;

public class Demo


{
public static void main(String args[])
{
JFrame f =new JFrame("Toggle Button Sample");
1445 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=f.getContentPane();
c.add(new JToggleButton("North"),BorderLayout.NORTH);
c.add(new JToggleButton("North"),BorderLayout.EAST);
c.add(new JToggleButton("North"),BorderLayout.WEST);
c.add(new JToggleButton("North"),BorderLayout.SOUTH);
c.add(new JToggleButton("North"),BorderLayout.CENTER);
f.setSize(300,300);
f.setVisible(true);
}
}

A. f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); statement contains error.

B. Container c=f.getContentPane(); statement contains error.

C. public static void main(String args[]) contains error.

D. No error.

Answer optiond

Marks: 2
Select the proper command to run the following code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class mymenu extends JFrame
{
JTextField tf=new JTextField(20);
JMenuBar mb=new JMenuBar();
JMenu file = new JMenu("File");
JMenu edit=new JMenu("Edit");
JMenuItem fnew=new JMenuItem("New");
JMenuItem fopen=new JMenuItem("Open");
JMenuItem fsave=new JMenuItem("Save");
JMenuItem fclose=new JMenuItem("Close");
JCheckBoxMenuItem fprint=new JCheckBoxMenuItem("Print");
JMenuItem ecut=new JMenuItem("Cut");
JMenuItem ecopy=new JMenuItem("Copy");
JMenuItem epaste=new JMenuItem("Paste");
public mymenu(String title)
{
super(title);
file.add(fnew);
file.add(fopen);
file.add(fsave);
file.addSeparator();
file.add(fclose);
file.add(fprint);
edit.add(ecut);
edit.add(ecopy);
1446 edit.add(epaste);
mb.add(file);
mb.add(edit);
setJMenuBar(mb);
getContentPane().setLayout(new FlowLayout());
fnew.addActionListener(new MIHandler());
fopen.addActionListener(new MIHandler());
fsave.addActionListener(new MIHandler());
fclose.addActionListener(new MIHandler());
ecut.addActionListener(new MIHandler());
ecopy.addActionListener(new MIHandler());
epaste.addActionListener(new MIHandler());
getContentPane().add(tf);
}
public static void main(String args[])
{
mymenu mm=new mymenu("Editor Frame");
mm.setSize(300,300);
mm.setVisible(true);
}
class MIHandler implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
String cmd=ae.getActionCommand();
tf.setText(cmd);
}
}
}

A. appletviewer mymenu.java

B. appletviewer mymenu.html

C. java mymenu

D. none of the above.

Answer optionc

Marks: 2

Find the missing statement in the program.

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*
<APPLET
CODE=textarea.class
WIDTH=200
HEIGHT=200 >
</APPLET>
*/
public class textarea extends Applet
{
TextArea textarea1;
Button button1;
1447 public void init()
{
textarea1 = new TextArea("", 10, 20, TextArea.SCROLLBARS_BOTH);
add(textarea1);
button1 = new Button("Click Me!");
add(button1);
button1.addActionListener(this);
}
public void actionPerformed (ActionEvent e)
{
String msg = "Hello from Java!";
if(e.getSource() == button1){
textarea1.insert(msg, 0);
}
}
}

A. implements ActionListener
B. implements ItemListener

C. Implements MouseListener

D. implements ButtonListener

Answer optiona

Marks: 2

Analyze the following code


import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
public class BorderTest extends JFrame{
public BorderTest(){
Border border=new TitledBorder("MyButton");
JButton b1=new JButton("Ok");
JButton b2=new JButton("Cancel");
b1.setBorder(border);
b2.setBorder(border);
1448 add(b1,BorderLayout.NORTH);
add(b2,BorderLayout.SOUTH);
}
public static void main(String args[]){
JFrame f=new BorderTest();
f.setSize(200,100);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
What will be the output of the above code?

A. Two buttons displayed with the same border.

B. Two buttons displayed,but only one button has the border.

C. The program has compile error because you assigns new TitledBorder("MyButton")to a variable of the Border type.

D. The program has the run time error because you cannot set a border on a button.

Answer optiona

Marks: 2

Choose missing statements in following code from given options.

import java.sql.*;
class DBTest
{
public static void main(String args[])
{
try
{
Class.ForName("sun.jdbc.odbc,JdbcOdbcDriver");
System.out.println("Driver Loaded");
String url="jdbc:odbc:xyz";
Connection con=DriverManager.getConnection(url);
1449 System.out.println("Connection to database is created");
Statement st=con.createStatement();
System.out.println("Statement Object is created");
catch(SQLException e)
{
System.out.println("SQL Error");
}
catch(Exception e)
{
System.out.println("Error");
}
}
}

A. { missing

B. ; missing

C. URL class missing

D. } missing

Answer optiond

Marks: 2
Choose missing statements in following code from given options.
import java.io.*;
import javax.servlet.*;
public class GetCookiesServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException
{
// Get cookies from header of HTTP request.

Cookie[] cookies = request.getCookies();


// Display these cookies.
1450 response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>");
for(int i = 0; i < cookies.length; i++)
{
String name = cookies[i].getName();
String value = cookies[i].getValue();
pw.println("name = " + name +"; value = " + value);
}
pw.close();
}
}

A. import javax.servlet.http.*; and ServletException

B. import javax.servlet.ftp.*; and HeaderException

C. import javax.servlet.http.*; and IOException

D. import javax.servlet.http.*; and NullPointerException

Answer optiona

Marks: 2

Find error in following code from given options.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ColorPostServlet extends HttpServlet
{
public void doPost(ServletRequest request,ServletResponse response)throws ServletException, IOException
1451 {
String color = request.getParameter("color");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>The selected color is: ");
pw.println(color);
pw.close();
}
}

A. Error in Exception

B. Error in importing packages

C. Error in doPost() method

D. No error.

Answer optionc

Marks: 2

Write the method in the following code for adding cookies.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class AddCookieServlet extends HttpServlet


{
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
1452 String data = request.getParameter("data");
Cookie cookie = new Cookie("MyCookie",data);
response.____________(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<b>My Cookie Has been set to : ");
pw.println(data);
pw.close();
}
}

A. setCookie()

B. addCookie()

C. getCookie()

D. addCookieValue()

Answer optionb

Marks: 2
Choose the desired command to compile the following program HelloServlet.java
import java.io.*;
import javax.servlet.*;
public class HelloServlet extends GenericServlet {
public void service(ServletRequest request,ServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
1453
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

A. javac HelloServlet.java

B. javac HelloServlet.java -classpath "C:\Program Files\Apache Tomcat 4.0\bin"

C. javac HelloServlet.java -classpath "C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar"

D. javac HelloServlet.java setpath ="C:\Program Files\ Apache Tomcat4.0 \common\lib\servlet.jar";

Answer optionc

Marks: 2

1454 Which of these methods is used to setting the winwods dimension

A. void setSize(Dimension new_size)

B. void setBounds(int x,int y, int x1, int y1)

C. void setCoordinate()

D. void setAlignment(int how)

Answer optiona

Marks: 1

1455 Which is the method is used to count the number of items in the list

A. getItem()

B. getSelectedItem()

C. getItemCount()

D. getCount()

Answer optionc

Marks: 1

1456 Which is the correct constructor of GridLayout

A. GridLayout(int a)

B. GridLayout(int numrows, int numcols)

C. GridLayout(int numrows, int cols,int vert)

D. GridLayout(int horz)

Answer optionb

Marks: 1

1457 Which is not the correct listener

A. ActionListener

B. TextAreaListener

C. WindowListener

D. FocusListener

Answer optionb

Marks: 1

1458 Which methods are defined by ComponentListener

A. void componentAdded(ContainerEvent obj)


B. void componentRemoved(ContainerEvent obj)

C. void componentDisabled(ContainerEvent obj)

D. void componentHidden(ComponentEvent obj)

Answer optiond

Marks: 1

1459 Which is the correct syntax from given?

A. getAddress(byte[])

B. byte getAddress()

C. []byte getAddress()

D. byte[] getAddress()

Answer optiond

Marks: 1

1460 Which class is used to connect java application to JDBC driver

A. Connection

B. DriverManager

C. GetManager

D. Manager

Answer optionb

Marks: 1

1461 Which is default ResultSet type

A. TYPE_FORWARD_ONLY

B. TYPE_AFTERFIRST_ONLY

C. TYPE_NEXT_ONLY

D. TYPE_BACKWARD_ONLY

Answer optiona

Marks: 1

1462 ________________ is a table of data which represents a data from database

A. MetaData

B. ResultSetMetaData

C. ResultSet

D. Statement

Answer optionc

Marks: 1

1463 Which is not the method in servlet to handle http request

A. doPost()

B. doGet()

C. doPut()

D. doShow()

Answer optiond

Marks: 1

1464 how to disable the default layout manager


A. setLayout(null)

B. setLayout(false)

C. a or b

D. setLayout()

Answer optiona

Marks: 2

1465 afterLast() method returns��������.

A. Moves cursor to the end of resultset that is after last row

B. Moves cursor to the last row of resultset

C. Moves cursor to the end of resultset

D. Moves cursor to the end of resultset that is before last row

Answer optiona

Marks: 2

1466 The getAttribute(String attr) returns

A. Returns MIME type of attribute

B. Returns path of the attribute

C. Returns value of the server attribute

D. both a and b

Answer optionc

Marks: 2
Consider the following output,Find the missing Statement in program
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class MouseEvent1 extends Applet implements MouseListener,MouseMotionListener


{
String msg=" ";
int mx=0,my=0;
public void init()
{
addMouseListener(this);
addMouseMotionListener(this);
}
public void mouseClicked(MouseEvent me)
{
mx=0;
my=10;
msg="mouse clicked";
repaint();
}
void mouseEntered(MouseEvent me)
{
mx=0;
my=10;
msg="mouse entered";
repaint();
}
public void mousePressed(MouseEvent me)
{
mx=me.getX();
my=me.getY();
msg="mouse pressed";
repaint();
}

{
mx=me.getX();
1467 my=me.getY();
msg="mouse Released";
repaint();
}
public void mouseExited(MouseEvent me)
{
mx=0;
my=10;
msg="mouse Exited";
repaint();
}
public void mouseDragged(MouseEvent me)
{
mx=me.getX();
my=me.getY();
msg="*";
showStatus("Dragging mouse at"+mx+","+my);
repaint();
}
public void mouseMoved(MouseEvent me)
{
mx=me.getX();
my=me.getY();
showStatus("moving mouse at"+mx+","+my);
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,mx,my);
}
}

/* <applet code=MouseEvent1.class
height=400
width=300>
</applet>*/
S1Q47.jpg

A. }

B. public void mouseReleased(MouseEvent me)

C. addMouseMotionListener(this);

D. ()

Answer optionb

Marks: 2
Select the missing code in the program for following output
import java.awt.*;
import java.awt.event.*;
public class MenuD extends Frame
{
MenuD( )
{
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});

}
public static void main(String a[])
{
MenuD m=new MenuD();
CheckboxMenuItem debug,test;
m.setVisible(true);
1468 MenuBar mbr=new MenuBar();
m.setMenuBar(mbr);
Menu file=new Menu("File");
Menu edit= new Menu("edit");
mbr.add(file);
mbr.add(edit);
MenuItem new1=new MenuItem("New");
MenuItem open=new MenuItem("Open");
file.add(new1);
file.add(open);
MenuItem copy=new MenuItem("Copy");
MenuItem paste=new MenuItem("Paste");
copy.setEnabled(false);
edit.add(copy);
edit.add(paste);
debug =new CheckboxMenuItem("Debug");
test =new CheckboxMenuItem("Test");
edit.add(test);
edit.add(debug);
}
}

A. addItemListener();

B. addActionListener(this);

C. addItemListener(this);

D. None of the Above

Answer optionc

Marks: 2

1469 What is the correct sequence of database connectvity

My Computer->Control Panel->Admistrative Tool->


A. Create User DNS

My Computer->Control Panel->Admistrative Tool->


B. Data Source(ODBC)->Create User DSN->Add DSN

My Computer->Admistrative Tool->Control Panel->


C.
Data Source(ODBC)

My Computer-->Admistrative Tool->Control Panel


D. Data Source(ODBC)->Create User DSN

Answer optionb

Marks: 2
What correction should be done in the program to get corrected output
import java.sql.*;
import java.io.*;
class JdbcP
{
public static void main(String arg[])
{
try
{
DataInputStream in=new DataInputStream(System.in);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
System.out.println("connection established");
ps.executeUpdate();
System.out.println("Table Created");
String sql="insert into movie6 VALUES(?,?)";
PreparedStatement ps2=con.prepareStatement(sql);
1470 System.out.println("Enter movie code");
int mcd=Integer.parseInt(in.readLine());
ps2.setInt(1,mcd);
System.out.println("Enter movie name");
String name=in.readLine();
ps2.setString(2,name);
ps2.executeUpdate();
con.close();
}
catch(SQLException e)
{
System.out.println(" sql error");
}
catch(Exception e)
{
System.out.println(" connection error1");
}
}
}

A. Missing {

B. Missing Semicolon

C. Missing Statement

D. Missing }

Answer optionc

Marks: 2

Select the statement that should be added to program to get corrected output
import java.sql.*;
import java.io.*;
class Jdbc_ResultSet
{
public static void main(String arg[])
{
String s1;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
System.out.println("connection established");
s1="select comp_name,num,cost,capacity from company order by num";
Statement st=con.createStatement();

1471 rs=st.getResultSet();
System.out.println("Comp_name"+" "+"num"+" "+"cost"+ " "+"capacity");
System.out.println();
while(rs.next())
{
System.out.println(rs.getString("comp_name")+" "+rs.getInt("num")+" "+rs.getInt("cost")+" "+rs.getString("capacity"));
}
con.close();
}
catch(SQLException e)
{
System.out.println(" sql error");
}
catch(Exception e)
{
System.out.println(" connection error1");
}
}
}

A. st.close()

B. rs.createStatement()

C. ResultSet rs=st.executeQuery(s1);

D. st.executeUpdate(s1);

Answer optionc

Marks: 2
What correction should be done in the program to get corrected output
import java.sql.*;
import java.io.*;
class JdbcP
{
public static void main(String arg[])
{
try
{
DataInputStream in=new DataInputStream(System.in);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded");
String url="jdbc.odbc.abc";
Connection con=DriverManager.getConnection(url);
System.out.println("connection established");
PreparedStatement ps=con.prepareStatement("create table movie6(num Integer,mvnm Varchar(30))");
ps.executeUpdate();
System.out.println("Table Created");
String sql="insert into movie6 VALUES(?,?)";
1472 PreparedStatement ps2=con.prepareStatement(sql);
System.out.println("Enter movie code");
int mcd=Integer.parseInt(in.readLine());
ps2.setInt(1,mcd);
System.out.println("Enter movie name");
String name=in.readLine();
ps2.setString(2,name);
ps2.executeUpdate();
con.close();
}
catch(SQLException e)
{
System.out.println(" sql error");
}
catch(Exception e)
{
System.out.println(" connection error1");
}
}
}

A. Class.forName("sun.jdbc.odbc.JdbcOdbcDriverManger");

B. Class.forName("sun:jdbc:odbc:JdbcOdbcDriver");

C. String url="jdbc:jdbcodbcDriver:abc";

D. String url="jdbc:odbc:abc";

Answer optiond

Marks: 2

Observe the following code and what will be the output of the program
import java.sql.*;
import java.io.*;

public class Resultset1


{
public static void main(String a[])
{
String s1;
int cnt=0;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers are properly loded");
String url="jdbc:odbc:abc";
Connection con= DriverManager.getConnection(url);
System.out.println("Connection Sucessful");
s1="Select Comp_name,num,cost,capacity from company order by num";
1473 Statement st = con.createStatement();
ResultSet rs = st.executeQuery (s1);
rs= st.getResultSet();
ResultSetMetaData rsmd= rs.getMetaData();
System.out.println("Total COLOUNMS ="+ rsmd.getColumnCount());
System.out.println("Column no 1 is = " +rsmd.getColumnName(1));
System.out.println("Column no 1 data type is = " + rsmd.getColumnTypeName(1));
System.out.println("Name of table = "+rsmd.getTableName(1));
con.close();
}
catch(SQLException e)
System.out.println("SQL Error...!!!");
}
catch(Exception e)
{
System.out.println("Error Connection Un-sucessful...!!!");
}
}
}

A. The output will give information about rows and coloums

B. The output will give information about ResultSet Metadata

C. The output will give information about database

D. The output will give information about ResultSet table

Answer optionb

Marks: 2
In following program fill statement showing ***** Select any one option from given options
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class DemoServ extends HttpServlet{
public void*****(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
1474 String name=req.getParameter("name");
pw.println("Welcome "+name);
}
}
// Html File

<html><form action="DemoServ" method="GET">

<input type="submit" value="Click">


</form></html>

A. doGet

B. doPost

C. doPut

D. doDelete

Answer optiona

Marks: 2

1475 Which of the following class act as a super class in class hierachy?

A. Panel

B. Window

C. Component

D. Container

Answer optionc

Marks: 1

1476 Which components are needed to get following shown output

A. TextField,Label,Button

B. Label,TextFied,TextArea,Button

C. Label,TextField

D. Button,Label,TextArea,TextArea

Answer optionc

Marks: 1

1477 In how many ways we can define the scrollbar?

A. Scrollbar()

B. Scrollbar(int style)

C. Scrollbar(int style,int initialvalue,int thumbSize,int min,int max)

D. All of the above

Answer optiond

Marks: 1

1478 When DialogBox is closed which method gets called

A. System.gc

B. WindowClosing()

C. dispose()

D. destroy()

Answer optionc

Marks: 1
1479 In FlowLayout manager the default space between each component is

A. 7 Pixel

B. 4 Pixel

C. 5 Pixel

D. 6 Pixel

Answer optionc

Marks: 1

1480 Which is the interface of MouseEvent class ?

A. MouseListener

B. MouseMotionListener

C. MouseAdapter

D. MouseClass

Answer optiona

Marks: 1

1481 How many bytes are required to represent an IPv4 address?

A. 8

B. 16

C. 4

D. 64

Answer optionc

Marks: 1

Which statements about HttpSession objects are true?


1. A session may become invalid due to inactivity.
2. A new session is created each time a user makes a request.
1482 3. A session may become invalid as a result of a specific call
by a servlet.
4. Multiple requests made from the same browser may have
access to the same session object.

A. 1,2 are correct

B. 1,3 are correct

C. 1,3,4 are correct

D. 1,2,4 are correct

Answer optionc

Marks: 1

1483 To place any component in AWT/Swing which method will be used if layout is null

A. setSize(int x,int y )

B. setSize(int x,int y,int height,int width

C. setBounds(int x,int y,int height,int width)

D. Component.add(int x,int y,int height,int width)

Answer optionc

Marks: 2

Which Statement with respect to inner class is true


A)It is a way of logically grouping classes that are only used in one place:
1484 B)It increases encapsulation
C) It can lead to more readable and maintainable code:

A. Only A Statement is True

B. Only B Statement is true


C. Only C Statement is true

D. All A , B C are True

Answer optiond

Marks: 2

__________are used to implement reliable, bidirectional, persistent point to point stream based
1485 connection.

A. TCP/IP

B. MIME

C. UDP

D. SMTP

Answer optiona

Marks: 2

1486 What is, in terms of JDBC, a DataSource?

A. A DataSource is the basic service for managing a set of JDBC drivers

B. A DataSource is the Java representation of a physical data source

C. A DataSource is a registry point for JNDI-services

D. A DataSource is a factory of connections to a physical data source

Answer optiond

Marks: 2

Give proper command to compile & run following program code?


import java.applet.*;
import java.awt.*;
/*
<applet code="A1" height="300" width="300">
</applet>
*/
1487 public class A1 extends Applet
{
public void paint(Graphics gr)
{
gr.drawString("Welcome to JAVA ",50,100);
setBackground(Color.cyan);
}
}

C:\javac A1.java
A. C:\appletviewer A1

C:\javac A1.java
B. C:\java A

C. C:\appletviewer A1.java

C:\javac A1.java
D. C:\appletviewer A1.java

Answer optiond

Marks: 2

You have created a simple Frame and overridden the paint method as follows
public void paint(Graphics g)
1488 { g.drawString("Dolly",50,10);
}
What will be the result when you attempt to compile and run the program?

A. The string "Dolly" will be displayed at the centre of the frame

B. The string "Dolly" will be shown at the Right of the form.

C. The word "Dolly" will be seen at the top-left of the form.

D. The string "Dolly" will be shown at the bottom of the form.

Answer optionc

Marks: 2

A Frame's background color is set to Color.Yellow, and a Button's background color is to Color.Blue.
1489 Suppose the Button is added to a Panel, which is added to the Frame.
What background color will be used with the Panel?
A. Color.Blue

B. Color.Green.

C. Color.Yellow.

D. Color.White.

Answer optionc

Marks: 2

Consider the following code.

PreparedStatement stmt=con.prepareStatement("select * from emp");


ResultSet rs=stmt.executeQuery();
1490 while(rs.next()){
System.out.println(rs.getInt(1)+" "+rs.getString(2));
}
This is an example of prepared statement interface that will _______________?

A. deletes the record

B. retrieve the record

C. updates the record

D. inserts the record

Answer optionb

Marks: 2

What is the result of following code, given there already exists a header by name "TestHeader".
1491 response.addHeader("TestHeader","TEST VALUE");

A. The "TEST VALUE" will be replaced by headers old value.

B. The "TEST VALUE" will be appended to the old value of the header.

C. Exception.

D. None of the above.

Answer optiona

Marks: 2

Given that resp is an HttpServletResponse, and no custom


headers exist in this response before this snippet executes:
resp.addHeader(�myHeader�, �foo�);
1492 resp.addHeader(�myHeader�, �bar�);
resp.setHeader(�myHeader�, �baz�);
String [] s = resp.getHeaders(�myHeader�);
What is the value of s[0]?

A. foo

B. bar

C. An exception is thrown at runtime

D. Compilation fails

Answer optiond

Marks: 2

<form action=�/handler�>
<!-- form tags here -->
</form>
1493 The URL pattern /handler is mapped to an HTTP servlet.
Which HttpServlet service method will the web container call
in response to this form submit?

A. doHead()

B. doGet()

C. doPost()

D. Get

Answer optionb

Marks: 2

1494 At the top of the AWT hierarchy is the__________________ class.


A. Component

B. Container

C. Frame

D. Applet

Answer optiona

Marks: 1

1495 Scrollbar( ) creates a ______________ scroll bar by default.

A. Horizontal

B. Vertical

C. Both a & b

D. None of these

Answer optionb

Marks: 1

1496 Deafult layout manager for Frame is ___________________.

A. FrameLayout

B. FlowLayout

C. BorderLayout

D. CardLayout

Answer optionc

Marks: 1

1497 Which of these methods cannot be called on TextArea?

A. void append(String str)

B. void insert(String str, int index)

C. String getItem(int index)

D. void replaceRange(String str, int startIndex, int endIndex)

Answer optionc

Marks: 1

1498 Which of the following is not true about Dialog Boxes?

A. Dialog boxes are primarily used to obtain user input.

B. Dialog boxes are often child windows of a top-level window.

C. Dialog boxes contains menu bars.

D. Dialog boxes may be model or modeless.

Answer optionc

Marks: 1

1499 Which of these is a not a factory method of InetAddress class?

A. static InetAddress getLocalHost( )

static InetAddress getByName(String hostName)


B.

C. static InetAddress getAllName(String hostName)

D. static InetAddress[ ] getAllByName(String hostName)

Answer optionc

Marks: 1
1500 URL class has several constructors; each can throw a _____________________.

A. MalformedException

B. URLException

C. URLMalformedException

D. MalformedURLException

Answer optiond

Marks: 1

1501 Which of the following is not a constructor of DatagramSocket

A. DatagramSocket( )

B. DatagramSocket(int port)

C. DatagramSocket(InetAddress address)

D. DatagramSocket(int port, InetAddress ipAddress)

Answer optionc

Marks: 1

1502 In JDBC _________imports all java classes concerned with database connectivity.

A. javax.sql.*

B. java.mysql.*

C. java.sql.*

D. com.*

Answer optionc

Marks: 1

1503 The HttpServlet class support ____________________________.

A. doGet()

B. doPost()

C. doPut()

D. All of the mentioned

Answer optiond

Marks: 1

1504 A toggle button looks just like a push button, but it acts differently because _________________________..

A. it has three states: clicked, pushed and released

B. it has two states: pushed and released

C. it has two states: enabled and disabled

D. None of these

Answer optionc

Marks: 2

1505 Which of these classes can be added to any Container class, using the add method defined in Container class ?

A. Button

B. CheckBoxMenuItem

C. Menu

D. MenuBar

Answer optiona
Marks: 2

1506 What components will be needed to get following output?

A. Jtable, JScrollBar

B. JTree, JScrollBar

C. Jtable, JScrollPane

D. JTree, JScrollPane

Answer optionc

Marks: 2

1507 Select the proper method to retrieve the host name & IP address of remote machine having domain name as "www.msbte.com"

A. static InetAddress getLocalHost( )throws UnknownHostException

B. static InetAddress getByName(String hostName)throws UnknownHostException

C. static InetAddress getAllByName(String hostname) throws UnknownHostException

D. string getHostAddress()

Answer optionb

Marks: 2

1508 getConnection() method of DriverManager returns __________________________

A. Driver Object

B. ResultSet object

C. Connection Object

D. DataSet Object

Answer optionc

Marks: 2

1509 getResultSet() method belongs to _____________________.

A. Statement interface

B. Connection interface

C. ResultSet interface

D. DriverManager interface

Answer optionc

Marks: 2

Identfy the following is/are true for JSP technology ?


I. It is persistent.
1510 II. Platform independent.
III. Browser executes the code.

A. Only (I)

B. Only (II)

C. Both (I) & (II)

D. Only (III)

Answer optionc

Marks: 2

1511 Identify the correct sequence in Lifecycle of JSP

A. Compile, Initialize, Execute, Destroy

B. Initialize, Compile, Execute, Destroy

C. Invoke, Initialize, Execute, Destroy


D. Initialize, Invoke, Execute, Destroy

Answer optiona

Marks: 2

Observe the following code


import java.awt.*;
import java.applet.*;
import java.util.*;
/*
<applet code="BorderLayoutDemo" width=400 height=200>
</applet>
*/
public class BorderLayoutDemo extends Applet {
public void init() {
setLayout(new BorderLayout());
add(new Button("This is across the top."),
BorderLayout.NORTH);
add(new Label("The footer message might go here."),
1512 BorderLayout.SOUTH);
add(new Button("Right"), BorderLayout.EAST);
add(new Button("Left"), BorderLayout.WEST);
String msg = "The reasonable man adapts " +
"himself to the world;\n" +
"the unreasonable one persists in " +
"trying to adapt the world to himself.\n" +
"Therefore all progress depends " +
"on the unreasonable man.\n\n" +
" - George Bernard Shaw\n\n";
add(new TextArea(msg), BorderLayout.CENTER);
}
}
What will be the output of the above program?

A. The output is obtained in Applet with BorderLayout placing button on east,west,north,south.

B. The output is obtained in Applet with BorderLayout placing button on east,west,north,south and TextArea at center

C. The output is obtained in Applet with BorderLayout placing button on east,west,north,south and TextField at center

D. The output is obtained in Applet with two layouts: Border layout and Flow Layout.

Answer optionb

Marks: 2

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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
1513 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();
}
}
}

A. Missing semicolon

B. Missing {

C. Missing }

D. Missing statement.

Answer optiona

Marks: 2
Consider the following program.
What should be the correction done in the program to get correct output?
import java.sql.*;

public class MyResultSetEx {

public static void main(String a[]){

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:MyDSN");
Statement stmt = con.createStatement();
System.out.println("Created DB Connection....");
ResultSet rs = stmt.executeUpdate("select name, salary from emp");
1514 while(rs.next()){
System.out.println(rs.getString("name"));
System.out.println(rs.getInt("salary"));
}
rs.close();
con.close();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {

e.printStackTrace();
}
}
}

A. replace executeUpdate with executeQuery

B. replace executeUpdate with execute

C. Replace ResultSet with PreparedStatement

D. Replace ResultSet with Statement

Answer optiona

Marks: 2

Choose missing statements in following code from given options.

import javax.servlet.*;

public class HelloServlet


{
public void service(ServletRequest request, ServletResponse response)
1515 {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

A. extends GenericServlet

B. import java.io.*;

C. throws ServletException, IOException

D. All mentioned above

Answer optiond

Marks: 2

Consider the following program and identify the error statement.

import java.io.*;
import java.util.*;
import javax.servlet.*;
public class PostParametersServlet extends GenericServlet {
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
PrintWriter pw = response.getWriter();
String e[]=request.getParameterNames();
1516 // Display parameter names and values.
while(e.hasMoreElements()) {
String pname = (String)e.nextElement();
pw.print(pname + " = ");
String pvalue = request.getParameter(pname);
pw.println(pvalue);
}
pw.close();
}
}

A. while(e.hasMoreElements())

B. String pvalue = request.getParameter(pname);

C. String pname = (String)e.nextElement();

D. String e[]=request.getParameterNames();

Answer optiond
Marks: 2

1517 Which of the following is not active control

A. Button

B. choice

C. labels

D. radio button

Answer optionc

Marks: 1

1518 The syntax for drawRect() method is

A. drawRect(int top, int left, int width, int height)

B. Draw Rect(int top, int left, int width, int height)

C. drawRect(int top, int bottom, int height, int width)

D. none of these

Answer optiona

Marks: 1

1519 TCP protocol is connectionless protocol

A. TRUE

B. FALSE

C.

D.

Answer optionb

Marks: 1

1520 Pretty Good Privacy (PGP) is used in security of

A. browser

B. Email

C. FTP

D. website

Answer optionb

Marks: 1

1521 Which control is a combination of text field and dropdown list?

A. list

B. separator

C. combo boxes

D. text area

Answer optionc

Marks: 2

1522 ______is a platform dependant.

A. AWT

B. swing

C. both AWT and swings

D. not AWT and nor swings


Answer optiona

Marks: 2

1523 When ContainerEvent is generated, following action is done-

A. Component is added or removed

B. Size of component is changed

C. both I and ii

D. none of the above

Answer optiona

Marks: 2

1524 port number of Telnet is________

A. 21

B. 23

C. 25

D. 79

Answer optionb

Marks: 2

1525 When UnknownHostException is thrown, that indicates

A. The IP address of a host could not be determined

B. The port of a host could not found

C. The packet is not received

D. all of the above

Answer optiona

Marks: 2

1526 Select the proper class for creating servers that listen for either local or remote client programs

A. HttpServer

B. MimeHeader

C. HttpResponse

D. ServerSocket

Answer optiond

Marks: 2

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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
1527 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();
}
}

A. Error in main()

B. Error in loop

C. Error in connection statement

D. Error in close()
Answer optiona

Marks: 2

1528 In applet, which of the following tag is used for accepting user defined parameter?

A. Body

B. center

C. Applet

D. Param

Answer optiond

Marks: 1

1529 Text field usually called as

A. change control

B. correct control

C. edit control

D. modify control

Answer optionc

Marks: 1

1530 Which method is defined when action event is occurs?

A. actionReleased()

B. actionPerformed()

C. actionmove()

D. actionListner

Answer optionb

Marks: 1

1531 When key is pressed which event is occurred

A. KeyPressed

B. KeyReleased

C. Both A and B

D. None of the above

Answer optiona

Marks: 1

1532 Which class is used to implement datagrams with UDP protocol.

A. DatagramPocket

B. DatagramSocket

C. Datagram Server & Client

D. Both a & b

Answer optionb

Marks: 1

1533 What is the first part of URL address?

A. Host name

B. Port number

C. File path
D. Protocol

Answer optiond

Marks: 1

Which class defines following methods.


1. int getContentLength()
1534 2.long getDate()
3. long getExpiration()

A. URLConnection

B. Datagram

C. Clinet

D. None of these

Answer optiona

Marks: 1

1535 Where does the object of ResultSet maintains a cursor?

A. Current column

B. Starting of column

C. Current Row

D. First Row

Answer optiond

Marks: 1

1536 Which Label defines the constructor?

A. Label()

B. Label(String str)

C. Label(String str, int how)

D. all of above

Answer optiond

Marks: 2

1537 Constructor of ItemEvent is

A. itemevent(itemselectable src,int type,object entry,int state)

B. Itemevent(itemselectable src,int type,object entry,int state)

C. ItemEvent(ItemSelectable src,int type,Object entry,int state)

D. itemEvent(itemselectable src,int type,object entry,int state)

Answer optionc

Marks: 1

1538 Set XXX() method binds values to the parameters. Where XXX represents

A. Data Type

B. Object

C. Both a & b

D. None of above

Answer optiona

Marks: 2

1539 boolean execute() method returns

A. Result set object


B. Boolean values

C. Multiple results

D. All of above

Answer optionc

Marks: 2

1540 The setAttributes(), getAttributes(), getAttributesNames() & removeAttributes() are the bindings of _________________.

A. Session

B. Cookies

C. Servelet

D. JSP

Answer optiona

Marks: 2

To set password as '******' which command should be added in the following code
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class textfield extends Applet implements ActionListener
{
TextField nm,psw;
public void init()
{
Label nml=new Label("name:",Label.RIGHT);
Label psw=new Label("Password:",Label.RIGHT);
nm=new TextField(12);
psw=new TextField(8);
add(nml);
1541 add(nm);
add(pswl);
add(psw);
nm.addActionListener(this);
psw.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{ repaint(); }
public void paint(Graphics g)
{g.drawString("name:"+nm.getText(),6,80);
g.drawString("Selected text in name:"+nm.getSelectedText(),6,100);
g.drawString("password:"+psw.getText(),6,120); } }
/* <applet code="textfield.class" width=200 height=200>
</applet>*/

A. psw.setPwdChar('*');

B. psw.setChar('*');

C. psw.setEchoChar('*');

D. psw.putChar('*');

Answer optionc

Marks: 2
Choose correct fig. as ouput for given code
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class addition2 extends Applet implements ActionListener
{
TextField t1;
TextField t2;
TextField t3;
Button b;
{
Label num1=new Label ("Addition of two numbers");
Label num2=new Label("Enter First no in text field");
Label num3=new Label("Enter Second no in text field");
t1=new TextField();
t2=new TextField();
t3=new TextField();
b=new Button("add");
setLayout(new GridLayout(4,2));
add(num1);
add(t1);
1542 add(num2);
add(t2);
add(num3);
add(t3);
add(b);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{if(ae.getSource()==b)
{
int n1=Integer.parseInt(t2.getText());
int n2=Integer.parseInt(t3.getText());
int sum=n1+n2;
t1.setText(Integer.toString(sum));
}
}
}

/*<applet code="addition1" height=200 width=300>


</applet>*/

A.

B.

C.

D.

Answer optionc

Marks: 2

1543 What is the correct code to create Button with caption Ok?

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class ok extends Applet implements ActionListener
{
Button b;
b=new Button("OK");
putLayout(new GridLayout(4,2));
A. add(b);
b.addActionListener(this);
}

/*<applet code="ok" height=200 width=300>


</

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class ok extends Applet implements ActionListener
{
Button b;
b=new Button("OK");
getLayout(new GridLayout(4,2));
B. add(b);
b.addActionListener(this);
}

/*<applet code="ok" height=200 width=300>


</
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class ok extends Applet implements ActionListener
{
Button b;
b=new Button("OK");
setLayout(new GridLayout(4,2));
C. add(b);
b.addActionListener(this);
}

/*<applet code="ok" height=200 width=300>


</

D. None of above

Answer optiond

Marks: 2

1544 What is correct code to get ip address of host machine ?

import java.net.*;
class InetAddressTest
{
public static void main(String args[]) throws
A. UnknownHostException {
InetAddress Address = InetAddress.getLocalHost();
System.out.println(Address);
}
}

import java.net.*;
class InetAddressTest
{
public static void main(String args[]) throws
UnknownHostException {
Address = InetAddress.getByName("starwave.com");
B. System.out.println(Address);
InetAddress SW[] = InetAddress.getAllByName("www.nba.com");
for (int i=0; i<SW.length; i++)
System.out.println(SW[i]);
}
}

import java.net.*;
class InetAddressTest
{
public static void main(String args[]) throws
UnknownHostException {
InetAddress Address = InetAddress.getLocalHost();
C. System.out.println(Address);
InetAddress SW[] = InetAddress.getAllByName("www.nba.com");
for (int i=0; i<SW.length; i++)
System.out.println(SW[i]);
}
}

import java.net.*;
class InetAddressTest
{
public static void main(String args[]) throws
UnknownHostException {
D. InetAddress Address = InetAddress.getLocalHost();
System.out.println(Address);
Address = InetAddress.getByName("starwave.com");
System.out.println(Address);
}
}

Answer optiona

Marks: 2

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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
1545 Statement s=c.createStatement();
ResultSet rs=s.("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();
}
}

A. Write executeQuery

B. Write updateQuery

C. Write Booleanexecute
D. None of above

Answer optiona

Marks: 2

import java.sql.*;
import java.io.*;
import java.sql.Satement;
import java.lang;
public class conTestTable
{ public static void main(String args[]);
{ String s1;
int cnt=0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers are properly loaded");
String url="jdbc:odbc:abc";
1546 Connection con=DriverManager.getConnection(url);
System.out.println("Connection established");
Statement sd=con.createStatement();
sd.executeUpdate("delete from student");
con.close();
}
catch(SQLException e) {
System.out.println("SQL error has occured");
}
catch(Exception e) {
System.out.println("Error connection not established");
}
}

A. Selected record is deleted

B. Selected table is deleted

C. Selected column is deleted

D. Both a & c

Answer optiona

Marks: 2

Consider the following program.


Which statement is missing to get correct output?
import java.sql.*;
class Ddemo1
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
1547 Statement s=c.createStatement();
ResultSet rs=s.("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();
}
}

A. Statement object not declated

B. Statement not closed

C. Connection object not declated

D. Connection c not closed

Answer optiond

Marks: 2

Fill correct statement to get output


import java.io.*;
import javax.servlet.;
import javax.servlet.http.*;
public class SessionIdServlet extends HttpServlet
{ public void doGet(HttpServletRequest request,HttpServletREsponse response)
throws ServletException,IOException
1548 {
response.setContenetType("text/html");
printWriter pw=response.getWriter();
HttpSession session=_____________________________;
String id=session.getId();
pw.printl("session Id is:"+id);
}
}

A. response.getSession()

B. response.putSession()

C. request.putSession()

D. request.getSession()
Answer optiond

Marks: 2

1549 TextField class is used for__________

A. Multi-Line text-entry area

B. Single-Line text-entry area

C. both A and B

D. none of these

Answer optionb

Marks: 1

1550 constructors of Jseparator are

A. Jseparator()

B. Jseparator(int)

C. both i and ii

D. none of these

Answer optionc

Marks: 1

1551 Inet Address class encapsulates__________________

A. IP Address

B. domain name

C. Both A and B

D. None of these

Answer optionc

Marks: 1

1552 ______is networking protocol for hypermedia, collaborative & distributed information system.

A. TCP

B. UDP

C. HTTP

D. FTP

Answer optionc

Marks: 1

1553 Which method is used to translate a mouse click on a specific point of the tree to a tree?

A. addTreeExpansionListener()

B. getPath()

C. getPathForLocation()

D. getLocation()

Answer optionc

Marks: 2

Which of the following statements are true about Two tier client server model.
a)it is simple in design
1554 b)client side scripting uploads work onto the client.
c) It is scalebale.

A. a and b

B. b and c
C. All of the above

D. none of these

Answer optiona

Marks: 2

1555 Advantage of Servlet over CGI is____________

A. servelet is platform dependent

B. Performance of servlets is significantly better.

C. both i and ii

D. none of these

Answer optionb

Marks: 2

1556 Choose the correct sequence for the following output

import java.awt.*;
import java.applet.*;
/*
<applet code="LabelDemo" width=300 height=200>
</applet>
A. */
public class LabelDemo extends Applet {
public void init() {
Label one = new Label("One");
Label two = new Label("Two");
Label three = new Label

import java.awt.*;
import java.applet.*;
/*
<applet code="LabelDemo" width=300 height=200>
</applet>
B. */
public class LabelDemo extends Applet {
public void init() {
Label one = new Label("One");
Label two = new Label("Two");
Label three = new Label

import java.awt.*;
import java.applet.*;
/*
<applet code="LabelDemo" width=300 height=200>
</applet>
*/
C. public class LabelDemo extends Applet {
public void init() {
add(one);
add(two);
add(three);
Label one = new Label("One");
Label two = new Label("T

import java.awt.*;
import java.applet.*;
/*
<applet code="LabelDemo" width=300 height=300></applet>
*/
public class LabelDemo extends Applet {
D. public void init() {
Label one = new Label("One");
Label two = new Label("Two");
Label three = new Label("Three");
add(one);add(two);add(three);
}
}

Answer optiond

Marks: 2

Choose missing statements in following code from given options.


import java.awt.*;
import java.applet.*;
/*
<applet code="Ellipses" width=300 height=200>
</applet>
*/
public class Ellipses extends Applet {
1557
{
g.drawOval(10, 10, 50, 50);
g.fillOval(100, 10, 75, 50);
g.drawOval(190, 10, 90, 30);
g.fillOval(70, 90, 140, 100);
}
}

A. public void paint(Graphics g)


B. public void paint()

C. public int paint(Graphics g)

D. none of these

Answer optiona

Marks: 2

Following program is the example of


import java.applet.*;
import java.awt.event.*;
/*
<applet code="ClassDemo" width=200 height=100>
</applet>
*/
public class ClassDemo extends Applet {public void init()
{
addMouseListener(new MyMouseAdapter());
1558 }

class MyMouseAdapter extends MouseAdapter


{
public void mousePressed(MouseEvent me)
{
showStatus("Mouse Pressed");
}
}
}

A. Adapter class

B. Inner class

C. interface

D. none of the above

Answer optionb

Marks: 2

In following Java program fill statement showing ***.Select any one option from given options
import java.awt.*;
import java.awt.event.*;

class AEvent extends Frame implements ********{


TextField tf;
AEvent(){

tf=new TextField();
tf.setBounds(60,50,170,20);

Button b=new Button("click me");


b.setBounds(100,120,80,30);

b.addActionListener(this);

1559 add(b);add(tf);

setSize(300,300);
setLayout(null);
setVisible(true);

public void actionPerformed(ActionEvent e){


tf.setText("Welcome");
}

public static void main(String args[]){


new AEvent();
}
}

A. ComponentListener

B. FocusListener

C. KeyListener

D. ActionListener

Answer optiond

Marks: 2
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: " + hp.getProtocol());
1560 System.out.println("Port: " + hp.getPort());
System.out.println("Host: " + hp.getHost());
System.out.println("File: " + hp.getFile());
System.out.println("Ext:" + hp.toExternalForm());
}
}

A. FTP

B. SMTP

C. TFTP

D. HTTP

Answer optiond

Marks: 2

Import java.sql.*;
class connectionTest
{
public static void main(String args[])
{
try
{
Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver�);
1561 Connection con=DriverManager.getConnection(url);
con.close();
}
catch(SQLException e)
{
}
}
}

A. undefined symbol url

B. error in catch{}

C. no error

D. import statement error

Answer optiona

Marks: 2

In following Java code fill statement showing ***.Select any one option from given options
import java.io.*;
public static void main(String args[])
{
class.forName("sun.jdbc.odbcOdbcDriver");
System.out.println("Driver Loaded");
String s="jdbc:odbc:dsn1";
Connection con=DriverManager.getConnection(s);
1562 System.out.println("connection established");
String s="*************************";
Statement st=con.createStatement(s);
st.executeUpdate();
System.out.println("data inserted");
st.close();
con.close();
}

A. insert student values(11,'ramesh')

B. insert into student values(11,'ramesh')

C. insert student values(11,'ramesh')

D. insert into student (11,'ramesh')

Answer optionb

Marks: 2
Consider the following program and identify the missing statement.
import java.sql.*;
class ps_isert
{
public static void main(String args[])
{
try{
Class.forName("sun.jddc.odbc.jdbcOdbcDriver");
System.out.println("Driver loaded");
String url="jdbc:obbc:insert1";
Connection con=DriverManeger.getConnection(url);
System.out.println("Connection Created");
int r1=11,r2=22;
String s1="Madras",s2="Delhi";
String str="Insert into if6g values(?,?)";
PreparedStatement ps=con.prepareStatement(str);
1563 ps.setInt(1,r1);
ps.setString(2,s1);
int i1=ps.executeUpdate();
System.out.println("data inserted "+i1);
String str1="insert into if6g values(?,?)";
PreparedStatement ps1=con.PreparedStatement(str1);
ps.setInt(1,r2);
ps.setString(2,s2);
int i2=ps1.executeUpdate();
System.out.println("data inserted"+i2);
con.close();
ps.close();
}

}
}

A. missing package statement

B. missing throws

C. missing catch block

D. none of the above

Answer optionc

Marks: 2

Consider the following program and identify the missing statement.


import java.io.*;
import javax.servlet.*;
public class HelloServlet extends GenericServlet {
public void service(ServletRequest request,
ServletResponse response)
1564 throws ServletException, IOException {
response.setContentType("text/html");
pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

A. PrintWriter pw;

B. int pw;

C. PageWriter pw;

D. Password pw;

Answer optiona

Marks: 2

Consider the following program


Select the statement that should be added to the program to get correct output.
import javax.servlet.*;
imopr javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponce responce) throwsServletException,IOException
{
String data = request.getParameter("data");
1565 Cookie cookie = new Cookie("MyCookie",data);

responce.setContentType("text/html");
PrintWriter pw = responce.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. responce.cookie(cookie);

B. responce.add(cookie);

C. responce.addCookie(cookie);

D. none of the above


Answer optionc

Marks: 2

Choose missing statements in following code from given options.

import java.io.*;
import java.until.*;
import javax.servelet.*;
import javax.servlet.http.*;
public class session1 extends HttpServelet
{
public void doGet(HttpServletRequest request,HttpServlatResponse response)
thtowsServletException, IOException
{

response.setCounterType("text/html");
1566 PrintWriter pw = response.getWriter();
pw.print("<B>");

Date date=(Date)hs.getAttribute("date");
if(date!=null)
{
pw.print("Last acess:"+date"+"<br>");
}
date = new Date();
hs.setAttribute("date",date);
pw.println("Current date:"+date);
}
}

A. HttpSession hs = request.getsession(true);

B. HttpSession hs ;

C. HttpSession hs = getsession(true);

D. HttpSession hs =response.getsession(true);

Answer optiona

Marks: 2

1567 What methods are used to get and set the text label displayed by a Button object?

A. getLabel( ) and setLabel( )

B. getLabel()

C. setLabel()

D. setEditable()

Answer optiona

Marks: 1

Which
1568 of the following are true

A. The event inheritance model has replaced the event delegation model.

The event
-
B. inheritance model is more efficient than the event
-
delegation model.

The event
-
C. delegation model uses event listeners to define the methods of event
-
handling classes.

The event
D. -
delegation model uses the handleEvent( ) method to support event handling

Answer optionb

Marks: 1

The whole life cycle of a servlet breaks up into 3


1569 phases:

A. Initialization, Service , Destroy

B. Init, get, destroy

C. init address, getresponce, delete

D. initialization, service provider, destroy


Answer optiona

Marks: 1

1570 This method is called once just before the servlet is unloaded and taken out of service.

A. public void destroy()

B. public void init()

C. public void configure()

D. public void set()

Answer optiona

Marks: 1

1571 Which code will produce the output shown in figure

f=new Font("Times New Roman",Font.ITALIC,14);


A. setFont(f); //setting the new font
setForeground(Color.red);

f=new Font("Times New Roman",Font.BOLDITALIC,14);


B. setFont(f); //setting the new font
setForeground(Color.red);

f=new Font("Times New Roman",Font.ITALIC,14);


C. setFont(f); //setting the new font
setForeground(Color.white);

f=new Font("Times New Roman",Font.BOLD,14);


D. setFont(f); //setting the new font
setForeground(Color.red);

Answer optiona

Marks: 2

1572 Which AWT control is uesd to produce given output

A. GridLayout, Label, TextField, Button

B. TextArea, Grid Layout and Button

C. BorderLayout, Text Field, Label, Button

Label, Button Grid Layout, Menu Manager


D.

Answer optiona

Marks: 2
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));
// BufferedReader br1 = new BufferedReader(new InputStreamReader(c.getInputStream()));
1573 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();
}

}
}

A. client

B. server

C. client and server

D. None of the above

Answer optiona

Marks: 2

1574 What contains object specific to database,and Used to create Connection object from the options ?

A. Driver Interface / Connect()

B. ResultSet

C. Statement

D. Driver Manager

Answer optiona

Marks: 1

1575 The given diagram is about:

A. Life Cycle of Servlet

B. Life Cycle of Applet

C. Life Cycle of thread

D. Life cycle of JDBC

Answer optiona

Marks: 2
The code Code will produce how many buttons:
public class JScrollPaneDemo extends JApplet {

public void init() {

// Get content pane


Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());

JPanel jp = new JPanel();


jp.setLayout(new GridLayout(20, 20));
int b = 0;
for(int i = 0; i < 20; i++) {
1576 for(int j = 0; j < 20; j++) {
jp.add(new JButton("Button " + b));
++b;
}
}

// Add panel to a scroll pane


int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(jp, v, h);

// Add scroll pane to the content pane


contentPane.add(jsp, BorderLayout.CENTER);
}
}

A. 400 Buttons

B. 200 Buttons

C. 40 Buttons

D. 100 Buttons

Answer optiona

Marks: 2

Which statemnet is missing where ******* is marked to produce given output


public class login extends JApplet
{
JTextField t1,t2;
JLabel l1,l2;
JButton b1,b2;
public void init()
{
Container CP=getContentPane();
CP.setLayout(new GridLayout(3,2));

t1=new JTextField(15);
1577 t2=new JTextField(15);
l1=new JLabel("Name :: ");
********
b1=new JButton("Login");
b2=new JButton("Cancel");

//Adding the controls to the content pane


CP.add(l1);CP.add(t1);
CP.add(l2);CP.add(t2);
CP.add(b1);CP.add(b2);
}
}

A. l2=new JLabel("Password :: ");

B. l2=new JLabel("User ID :: ");

C. l2=new JLabel("Enter Password :: ");

D. l2=new JLabel("User Password :: ");

Answer optiona

Marks: 2
Which statemnet is missing in following code which will generate given output::
public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo m=new MenuDemo();
m.setTitle("Menu Demo");
m.setVisible(true);
m.setSize(300,200);
**********

//Setting the menu bar


m.setMenuBar(mbar);

//Creating menus
Menu format=new Menu("Format");
Menu Tool =new Menu("Tool");
1578 Menu Help=new Menu("Help");

//Creating menu items


MenuItem item1,item2,item3,item4,item5,item6;
format.add(item1=new MenuItem("Font"));
format.add(item2=new MenuItem("Bullets"));
format.add(item3=new MenuItem("Paragraph"));
Tool.add(item4=new MenuItem("Spelling and Grammar"));
Tool.add(item5=new MenuItem("Word Count"));
Help.add(item6=new MenuItem("Help Topics"));

//Adding menus to the menu bar


mbar.add(format);
mbar.add(Tool);
mbar.add(Help);
}
}

A. m.setMenuBar(mbar);

B. MenuBar mbar=new MenuBar();

C. MenuDemo m=new MenuDemo();

D. Menu format=new Menu("Format");

Answer optionb

Marks: 2

Find missing statement from given code:


public class ButtonLabelDemo extends Applet
{
Label l1,l2;
Button b1;
public void init()
{
**
1579 **
**
//Adding the controls to the applet
add(l1);
add(l2);
add(b1);
}
}

l1=new Label("one");
A. l2=new Label("two");
b1=new Button("OK");

l1=new Label("one");
B. l2=new Label("two");
b1=new Button("Enter");

l1=new Label("Calculate");
C. l2=new Label("Accept");
b1=new Button("OK");

l1=new Label("four");
D. l2=new Label("two");
b1=new Button("OK");

Answer optiona

Marks: 2
The given code produces which event :
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=Fact height=150 width=200>
</applet>*/
public class Fact extends Applet implements ActionListener
{
int fact,n;
TextField t1,t2;
Button b1;
Label l1,l2;
public void init()
{
t1= new TextField(5);
t2= new TextField(5);
l1= new Label("Enter number");
l2= new Label("Factorial is:");
b1=new Button("Find Factorial");
b1.addActionListener(this);
//GridLayout g= new GridLayout(5,2);
1580 //setLayout(g);
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
n= Integer.parseInt(t1.getText());
fact=1;
for(int i=1; i<=n; i++)
{
fact=fact*i;
}
t2.setText(Integer.toString(fact));
}
repaint();
}
}

A. ActionEvent

B. MouseEvent

C. ItemEvent

D. FocusEvent

Answer optiona

Marks: 2
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));
// BufferedReader
br1 = new BufferedReader(new
1581 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();
}

}
}

A. TCPIP server

B. TCPIP client

C. UDP server

D. UDP client

Answer optiona

Marks: 2
The output of following program is :

import java.sql.*;
class preparestmt
{
public static void main(String[] args)
{ try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("driver loaded");
String url = "jdbc:odbc:TYCM";
Connection con = DriverManager.getConnection(url);
System.out.println("connection created");

PreparedStatement prepare=con.prepareStatement("select * from Information where age=15");

ResultSet rs=prepare.executeQuery();
if(rs.next())
1582 {
System.out.println("student information is");
System.out.println(rs.getString("name"));
System.out.println(rs.getInt("age"));
}
else
System.out.println("No student found");
con.close();
System.out.println("Connection is closed");
}
catch (SQLException e)
{
System.out.println("SQL Exception");
}
catch (Exception e)
{
System.out.println("General Exception");
}}}

driver loaded
connection created
student information is
A. BBB
14
Connection is closed

driver loaded
connection created
student information is
B. CCC
14
Connection is closed

driver loaded
connection created
student information is
C. BBB
15
Connection is closed

driver loaded
connection created
student information is
D. BBB
14
Connection is Opened

Answer optionc

Marks: 2

Which statmenet is missing at place marked as *****


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloServlet extends HttpServlet


{
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
1583 {
response.setContentType("text/html");
******
pw.println("<b> Hello This is first servlet program");
pw.close();
}

A. PrintWriter pw = response.getWriter();

B. PrintWriter pw = response.getWritten();

C. PrintWriter pw = res.getWriter();

D. PrintWriter pw = response.getPrintWriter();

Answer optiona

Marks: 2
The follwing program prints: _________________
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ClientPull extends HttpServlet {

1584 public void doGet(HttpServletRequest req, HttpServletResponse res)


throws ServletException, IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();

res.setHeader("Refresh", "10");
out.println(new Date().toString());
}
}

A. Date

B. Time

C. Date and time

D. none of the above

Answer optiona

Marks: 2

1585 An object of Which is created by the web container at time of deploying the project?

A. ServletConfig

B. ServletContext

C. Both A & B

D. None of the above

Answer optionb

Marks: 2

1586 In the following JDBC drivers which is known as partially java driver?

A. JDBC-ODBC bridge driver

B. Native-API driver

C. Network Protocol driver�

D. Thin driver

Answer optionb

Marks: 2

1587 The authentication mechanism in the servlet specification uses a technique called?

A. Role Based Authentication

B. Form Based Authentication

C. Both A & B

D. None of the above

Answer optiona

Marks: 2

1588 Which is the Microsoft solution for providing dynamic Web content?

A. ASP

B. JSP

C. Both A & B

D. None of the above

Answer optiona

Marks: 2
1589 Which of the following method is used to change the Label caption?

A. setLabel()

B. settext(String s,Icon i)

C. setLabel(String s)

D. setText(String s)

Answer optiond

Marks: 1

1590 Which of the following method is use to add a button �b� to the south of the applet using BorderLayout?

A. add(b,”SOUTH”);

B. b.add(BorderLayout.South);

C. add(b,BorderLayout.SOUTH);

D. b.add(“South”);

Answer optionc

Marks: 1

1591 Which class is used for this Processing Method processActionEvent( )?

A. Button,List,MenuItem

B. Button,Checkbox,Choice

C. Scrollbar,Component,Button

D. None of the above

Answer optiona

Marks: 1

1592 In which places can we insert the event handling code

A. Same class

B. Other class

C. Anonymous class

D. All mentioned above

Answer optiond

Marks: 1

1593 Which of the following method is used to register a listener to a button ?

A. registerListener()

B. addActionListener()

C. addActionlistener(this)

D. addActionListener(ActionListener obj)

Answer optiond

Marks: 1

1594 In InetAddress class which method returns the host name of the IP Address?

A. public String getHostName()

B. public String getHostAddress()

C. public static InetAddress getLocalHost()

D. None of the above

Answer optiona
Marks: 1

1595 Which method of class is used to register & dynamically load the driver class?

A. forName()

B. getConnection()

C. createStatement()

D. executeQuery()

Answer optiona

Marks: 1

1596 Which of these is not a method of GenericServlet?

A. init

B. service

C. doGet

D. destroy

Answer optionc

Marks: 1

1597 getCookies is method of which of the following ?

A. ServletContext

B. HttpServletResponse

C. HttpServletRequest

D. Servlet

Answer optionc

Marks: 1

1598 When we create a Dialog box using the Constructor Dialog (Frame f,true) the dialog box is of which type ?

A. Modal

B. Modeless

C. Filedailog

D. None of the above.

Answer optiona

Marks: 2

Which of the following statements are true


1599 i) Scrollbar is a component but not a Container
ii)ScrollPane is a Container and performs its own scrolling

A. i and ii both are true

B. i is true and ii is false

C. i is false and ii is true

D. i and ii both are false

Answer optiona

Marks: 2

1600 Which swing control is used for following output?

A. JButton,JscrollPane

B. JTable,JButton

C. JTree,JButton

D. JTabbedPane,JButton
Answer optiona

Marks: 2

1601 Which method is used to obtain the Port no of client in Client Program

A. get()

B. getPort()

C. getLocalPort()

D. getPortNo()

Answer optionc

Marks: 2

1602 When using HTML forms which of the folowing is true for POST method

A. POST allows users to bookmark URLs with parameters

The POST method should not be used


B. when large amount of data needs to be transferred

C. POST should be used when form submission doesnot cause changes

D. POST method sends data in the body of the request

Answer optiond

Marks: 2

Find the error in the following code.

import java.awt*;
import java.awt.event.*;
import java.applet.*;

public class RadioDemo extends JApplet


{
public void init()
{
1603
Container c=getContentPane();
JRadioButton b1=new JRadioButton("Red");
JRadioButton b2=new JRadioButton("Blue");
c.add(b1);
c.add(b2);

A. The radiobuttons should be added to ButtonGroup object.

B. package is missing

C. A and B

D. the class used for creating radiobuttons should not be JRadioButton

Answer optionc

Marks: 2

find the ouptut of the following :


import javax.swing.*;
class Demo extends JApplet
{
public void init()
1604 {
JTabbedPane jt=new JTabbedPane();
jt.addTab(�Tab 1�,new JButton());
getContentPane().add(jt);
}
}

A. S1Q43O1

B. S1Q43O2

C. S1Q43O3

D. S1Q43O4

Answer optiona

Marks: 2
Find the missing statement in the following code
import java.awt.*;
class MenuDemo extends Frame
{
MenuDemo()
{
MenuBar mb=new MenuBar();
Menu file =new Menu(�File�);
MenuItem open=new MenuItem(�Open�);
MenuItem save=new MenuItem(�Save�);
file.add(open);
1605 file.add(save);
mb.add(file);
}
public static void main(String args[])
{
MenuDemo md=new MenuDemo();
md.setSize(400,400);
md.setLocation(10,10);
md.setVisible(true);
}
}

A. It should extend Applet instead of Frame

B. add(mb);

C. addMenuBar(mb);

D. setMenuBar(mb);

Answer optiond

Marks: 2

1606 Which is the correct code for the following output

import java.awt.*;
import java.applet.*;
public class LayDemo extends Applet
{ � � � public void init() � �
� { � � � � � Button b1=new Button ("OK");
A. � � � � � Button b2=new Button("Cancel"); �
� � � � FlowLayout f=new FlowLayout(200,200); �
� � � � setLayout(f); �
� � � � add(b1);
� �

import java.awt.*;
import java.applet.*;
public class LayDemo extends Applet
{ � � � public void init() �
� � { � � � � � Button b1=new Button ("OK");
� � � � � Button b2=new Button("Cancel");
B. � � � � � FlowLayout f=new FlowLayout(FlowLayout.RIGHT);
� � � � � setLayout(f);
� � � � � add(b1);
add(b2);
}
}

import java.awt.*;
import java.applet.*;
public class LayDemo extends Applet
{ � � � public void init()
� � � { � � � � � Button b1=new Button ("OK"); � � � �
C. � Button b2=new Button("Cancel"); � � �
� � setLayout(new FlowLayout());
� � � � � add(b1);
� � � � � add(b2); �
� � }
}

public class LayDemo extends Applet


{ � � � public void init()
� � � { � � � � � Button b1=new Button ("OK"); �
� � � � Button b2=new Button("Cancel"); � �
D. � � � BorderLayout b=new BorderLayout(); � �
� � � setLayout(b);
� � � � � add(b1,”East”);
add(b2,”East”); �
� � }}

Answer optionb

Marks: 2

1607 Which will be the correct code for the following output

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class EventDemo extends Applet
{ � � � public void init()
A. � � � { � � � � �
addMouseListener(new MouseAdapter()
� � � � � { � � � � � � � � � � �
public void mouseClicked(MouseEvent me) � �
� � � � � � � � � { � � � � � � � � � � � � � �
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class EventDemo extends Applet
{ � � � public void init()
B. � � � { � � � � � addMouseListener(this);
� }
� � � public void mouseClicked(MouseEvent me) � �
� { � � � � � showStatus("Mouse clicked"); �
� } � � �
}

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class EventDemo extends Applet implements MouseListener
{ � � � public void init()
C. � � � { � � � � �
addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent me)
� � � � � � � � {

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class EventDemo extends Applet implements MouseListener
{ � �
� public void init()
D. � � � { � � � � �
addMouseListener(this);
}
public void mouseClicked(MouseEvent me)
� � � { � � � � �
showStatus("

Answer optiond

Marks: 2

Which statements should we add inorder to following code to handle events for MenuItems
import java.awt.*;
import java.awt.event.*;
public class MenuDemo extends Frame implements ___________________
{ Label l;
MenuDemo()
{
MenuBar mbr = new MenuBar();
setMenuBar(mbr);
Menu filemenu = new Menu("File");
mbr.add(filemenu);
MenuItem new1 = new MenuItem("New");
filemenu.add(new1);
1608 new1.__________________
l=new Label();
add(l);
}
public static void main(String args[])
{MenuDemo m = new MenuDemo();
m.setSize(200,200);
m.setLocation(10,10);
m.setVisible(true);
}
public void ______________________
{ l.setText("New Clicked");
}
}

A. ItemListener ,addItemListener(this), itemSelected(ItemEvent ie)

B. ItemListener ,addItemListener(this), itemStateChanged(ItemEvent ie)

C. ActionListener ,addActionListener(this),actionEvent(ActionEvent ae)

D. ActionListener, addActionListener(this), actionPerformed(ActionEvent ae)

Answer optiond

Marks: 2

Find the error in the following code


import java.awt.*;
import java.applet.*;
public class Demo extends Applet implements ActionListener
{
public void init()
{
Button b=new Button();
add(b);
b.addActionListener();
1609 }
public void actionEvent(Event ae)
{
showStatus(�Button clicked�);
}
}

1) Button constructor is wrong


2) Error is addActionListener method
3)ActionListener method should be public void actionPerformed(Event ar)
4)ActionListener method should be public void actionPerformed(ActionEvent ae)

A. 1& 2 is true
B. 1 & 3 is true

C. 2 and 4 is true

D. all are true

Answer optionc

Marks: 2

Find missing statements in order from top to end of the program

import java,awt*;
import java.awt.event.*;
import java.applet.*;

public class RadioDemo extends JApplet implements ______________


{
public void init()
{
Container c=getContentPane();
JRadioButton b1=new JRadioButton("Red");
1610 JRadioButton b2=new JRadioButton("Blue");
b1.add_________________(this);
b2.add___________________(this);
c.add(b1);
c.add(b2);
ButtonGroup bg=new ButtonGroup();
bg.add(b1);
bg.add(b2);
}
public void _____________
{
}
}

A. ItemListener ,addItemListener,addItemListener, itemSelected(ItemEvent e)

B. ItemListener ,addItemListener,addItemListener, itemStateChanged(ItemEvent ie)

C. ActionListener ,addActionListener,addActionListener,actionEvent(ActionEvent ae)

D. ActionListener, addActionListener, addActionListener,actionPerformed(ActionEvent ae)

Answer optionc

Marks: 2

Choose the correct option for the given code


import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class DemoE extends Applet


{
public void init()
{
Button b=new Button("Click");
1611 b.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent me)
{
showStatus("Button clicked");
}
});
add(b);
}
}

We cannot use mouseClicked method for button


A.

The program will display "Button clicked " message in status bar
B. on clicking the button with mouse.

C. All methods of the MouseListener should be implemented.

D. No Listener implemented.

Answer optionb

Marks: 2

find the missing statement


import java.sql.*;
public class dbDemo1
{public static void main(String args[])throws Exception
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
1612 PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
s.setString(1,args[0]);
s.setInt(2,args[1]);
s.close();
c.close();
}
}

A. s.setString(3,args[2]);
B. s.executeQuery();

C. s.executeUpdate();

D. s.executeUpdate(query);

Answer optiond

Marks: 2

Find the error in the following program


import java.sql.*;
public class dbDemo2
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
Statement s=c.createStatement("select* from student");
1613 ResultSet rs=s.executeUpdate();
System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg");
while(rs.next())
{System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3));
}
s.close();
c.close();
}
}

A. error in c.createStatement()

B. error in while condition

C. error in call to executeUpdate() method.

D. Both A and C

Answer optiond

Marks: 2

Find the missing statement

import java.sql.*;
class Ddemo1
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");

Statement s=c.createStatement();
1614 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();
}
}

A. ResultSet rs=s.executeQuery("select *from StudTable");

B. ResultSet rs=s.executeUpdate("select * from StudTable");

C. ResultSet rs=new ResultSet(select * from StudTable");

D. s.executeUpdate(select * from StudTable");

Answer optiona

Marks: 2

Find the error in the following program


import java.sql.*;
class Ddemo1
{
public static void main(String args[]) throws Exception
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
1615 Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");

Statement s=c.createStatement();
s.executeQuery("create table emp(empno number, name text)");
s.close();
c.close();
}
}
A. Error in registering the driver

B. error in call to execute method i.e.s.executeQuery()

C. cannot execute create table command through JDBC

D. error in createStatement method

Answer optionb

Marks: 2

Which of the following is true


1)JSP is a client side technology
1616 2)We can�t do client side validation with JSP
3)JSP is dynamic scripting

A. 1,2,3 are true

B. 2,3 are true

C. 1,3 are true

D. only 1 is true

Answer optionb

Marks: 2

1617 What are the true sentences about Session-Id?

Session Ids are usually stored in the cookies, URLS


A. and hidden form fields ofWeb pages

B. A session Id is an unique identification

C. It is transmitted between client and server

D. All of these.

Answer optiond

Marks: 2

Fill in the missing statements


import javax.servlet.*;

import javax.servlet.http.*;
import java.io.*;

public class AddCookieServlet extends HttpServlet

public void doPost(HttpServletRequest request,

HttpServletResponse response)

throwsServletException, IOException

String data = request.getParameter("data");


1618
Cookie cookie = ------------------------------

response.addCookie(cookie);

response.setContentType("------------------l");

PrintWriter pw = response.getWriter();

pw.println("<B>MyCookie has been set to");

pw.println(data);

pw.close();

new Cookie("MyCookie", data);


A.
text/html

new Cookie("MyCookie", data1);


B. application/java

new Cookie("MyCookie", data2);


C. html/text

new Cookie("MyCookie", database);


D. text/bmp
Answer optiona

Marks: 2

1619 Which of these class is necessary to implement datagrams?

A. DatagramPacket

B. DatagramSocket

C. Both of these

D. None of these

Answer optionc

Marks: 1

1620 DriverManager.getConnection(_______ , ______ , ______) What are the two parameters that are included ?

A. URL or machine name where server runs, Password, User ID

B. URL or machine name where server runs, User ID, Password

C. User ID, Password, URL or machine name where server runs

D. Password, URL or machine name where server runs, User ID

Answer optionb

Marks: 1

Select the missing statement in the program


import java.awt.*;
import java.awt.event.*;

public class combodemo extends JApplet


implementsItemListener
{
JLabeljl;
ImageIconfrance, germany, italy, japan;
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JComboBoxjc = new JComboBox();
1621 jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");
jc.addItemListener(this);
contentPane.add(jc);
contentPane.add(jl);
}
public void itemStateChanged(ItemEventie)
{
String s = (String)ie.getItem();
jl.setIcon(new ImageIcon(s + ".gif"));
}
}

A. }

B. import javax.swing.*;

C. Class declaration

D. JLabel(new ImageIcon("star.gif"));

Answer optionb

Marks: 2

1622 Which method is used to know the full URL of an URL object?

A. fullHostURL()

B. getHostURL()

C. ExternalForm()

D. toExternalForm()

Answer optiond

Marks: 1

1623 _______ calls get converted into native C or C++ API calls.

A. API
B. JDBC

C. JDBC Native API

D. none

Answer optionc

Marks: 1

1624 ___________ interface allows storing results of query?

A. Statements

B. connection

C. ResultSet

D. none

Answer optionc

Marks: 1

1625 Which abstract class is the super class of all menu related classes?

A. MenuComponent

B. menuBar

C. MenuItem

D. CheckboxMenuItem

Answer optiona

Marks: 2

1626 Which method of Applet executes only once?

A. start()

B. init()

C. stop()

D. destroy()

Answer optionb

Marks: 2

1627 If we close an applet window _____ events will be generated

A. ActionEvent

B. ComponentEvent

C. AdjustmentEvent

D. WindowEvent

Answer optiond

Marks: 2
WHAT WILL BE THE OUTPUT OF THE BELOW PROGRAM:

import java.sql.*;
class ConnectionTest
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded");
String url="jdbc:odbc:xyz";
1628 Connection con = DriverManager.getConnection(url);
System.out.println("connection to database created");
}
catch(SQLException e)
{
System.out.println("SQL error");
}
catch(Exception e)
{
System.out.println("error");
}
}
}

A. Driver Loaded

B. connection to database created

C. BOTH Option i and Option ii

D. None of the above

Answer optionc

Marks: 2

Which ONE of the following is missing statement in the program below?

import java.sql.*;
class ExecuteQueryTest
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded");
String url="jdbc:odbc:aditya";
Connection con = DriverManager.getConnection(url);
System.out.println("connection to database created");
Statement st = con.createStatement();
System.out.println("Statement object created");
String sql="select Name,Age from tanni";
1629 ResultSet results = state.executeQuery(sql);
String text=" ";
while()
{
text +=results.getString(1)+ "" +results .getInt (2)+ '\n';
}
System.out.println(text);
}
catch(SQLException e)
{
System.out.println("SQL error");
}
catch(Exception e)
{
System.out.println("error");
}
}
}

A. state.results()

B. results.next()

C. next.results()

D. results()

Answer optionb

Marks: 2
Which statement should be added to get the desired result?
import java.servlet.*;
import java.servlet.http.*;
import java.io.*;
public class RegisterSerlet extends HttpServlet
{
public void dopost(HttpServletRequest req, HttpServletResponse res)throws
servletException, IOException
{
1630 string f1 = res.getParameter("First");
string l1 = res.getParameter("last");
res.setContentType("text/html");
PrintWriter PW = res.getWriter();
pw.println("The Entered Name Is")

pw.close()
}
}

A. pw.println(f1 + " " l1);

B. println(f1 + " " + l1);

C. pw.println(f1 + " " + l1);

D. No Correction Needed

Answer optionc

Marks: 2

1631 The method setLabel can be used with what type of Object ?

A. DoubleField.

B. int.

C. TextField.

D. String

Answer optionc

Marks: 1

1632 the method _________ places a menu mu into a menu bar mb.

A. mb.addMenuItem(mu)

B. mb.addItem(mu)

C. mb.add(mu)

D. None of the above

Answer optionc

Marks: 1

1633 Which method does display the message whenever there is an item selection or deselection of the CheckboxMenuItem menu?

A. itemChanged method.

B. itemState mehod.

C. itemStateChanged method.

D. StateChanged method.

Answer optionc

Marks: 1

1634 Which of the following is not a server-side technology ?

A. Sevelets.

B. Java Server Pages.

C. DHTML

D. CGI

Answer optionc

Marks: 1
1635 Which method returns names of the request parameters as Enumeration of String objects

A. getParameter

B. getParameterNames

C. getParameterValues

D. getParameterVal

Answer optionb

Marks: 1

1636 The URL connection classes are good enough for simple programs that want to connect to ______ server to fetch content.

A. FTP

B. SMTP

C. HTTP

D. UDP

Answer optionc

Marks: 2

1637 Which datagram method returns the byte array of data contained in the datagram?

A. InetAddressgetAddress()

B. int getPort()

C. byte[] getData ()

D. byte[] getAddress()

Answer optionc

Marks: 2

1638 Which class has traditionally been the backbone of the JDBC architecure ?

A. A.the JDBC DriverManager

B. B. the JDBC driver test suite

C. C. the JDBC-ODBC bridge

D. D. All mentioned above

Answer optiona

Marks: 2

1639 Which kind of driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, IBM DB2, or other DBMS?

A. JDBC-ODBC bridge plus ODBC driver

B. Native -API partly-java driver

C. JDBC-Net pure Java driver

D. Native - protocol pure Java driver

Answer optionb

Marks: 2

What is the result of executing the following Java class:


import java .awt.*;
public class FrameTest extends Frame
{ public Frame Test()
{ add (new Button("First"));
add ( new Button( "Second"));
1640 add (new Button ("Third"));

setVisible(true);
}
public static void main ( String args []
{ new FrameTest ();}}

A. Three buttons are displyed across a window.


B. Two buttons are displyed across a window.

one buttons are displyed across a window.


C.

D. none of above

Answer optiona

Marks: 2

find out the errors in the following code if any and correct them:
import java.awt.event.*;
/*<applet code =" AdapterDemo" height = 250 width =350 </applet>*/
public class Adapter Demo extends Applet
public void init ()
{
addMouseListener (
newMouseAdapter()
{
int topX,bottomY;
public void Mousepressed ( Mouseevent me)
1641 {
topX = me.getX(); bottom Y me.get Y ();
}
public void mouse Released ( MouseEvent me )
Graphics g = AdapterDemo. this getGraphics
( 0; g. draw Rect( topX, bottomY, me.GetX()-topX, me. get Y ()-bottomY);
}

} );
}
}

A. public void Mouse pressed ( mouseEvent me )

B. public void mouse pressed (mouseEvent me);

C. public void mouse pressed ( MouseEvent me )

D. public void mousePressed (MouseEvent me )

Answer optiond

Marks: 2

What type of eventlisteners can be added to the following code


import java.awt. Container;
import java.awt. Font;
import java.awt. Gridlayout;
import java.awt. Jbutton;
import java.awt. JFrame;
public calss GridSize test extends Jframe { public static void main (string[] args )
{ GridSize Test gst = new Grid Size Test ();
1642 gst. set Default Close Operation (JFrame. EXIT_ON_CLOSE); gst. pack ();
gst.set Visible (true); } public GridSize Test ()
Container pane = getContent Pane ();
pane.set layout (new Gridlayout (2,2));
JButton button = new Jbutton ("First " ) pane. add (button ) ;
button = new JButton ("Second with a very long name " ); pane. add ( button); button = new JButton ("Hi");
button. set Font (new Font ("courier", Font. PLANIN, 36));
pane . add (button ); button = new JButton ("there"); pane. add ( button ?); } }

A. Action Listener only

B. Window Listener only

C. Both A and B

D. None

Answer optionc

Marks: 2

Which of the following query is correct to fetch all the records from database.
Import java. Sql.*;
class MysqlCon{ public static void main (String args[]){ try { Class.forName ("com.mysql.jdbc. Driver"); Connection con =
DriverManager. getConnection ("jdbc:mysql://localhost:3306/abc","root","root'');
1643 Statement stmt = stmt = con. createStatement();
ResultSet rs = ______________________________________________________________
while ( rs.next()) System.out printIn(rs.getInt(1)+ " " + rs. getString (2) + "" + rs. getString(3)); con.close(); } catch
(Exception e )
{ System.out.println(e);} }}

A. sun.jdbc.odbc.JdbcOdbcDriver

B. select * from emp

C. Stmt.executeQuery("select* from emp");

D. st.execute ("select * from emp");

Answer optionc
Marks: 2

Correct the following code.

import java. Io. * ; import javax. Servlet. * ; import javax. Servlet. Http.*;
public class cookies Example extends HttpServlet {
public void dopost ( HttpServletRequest req,HttpServletResponse res ) throws ServletException, IOException {
res. set content type ( "text/html");
String dta = req. get Parameter ("data");
PrintWriter pw = res. getWriter ();
cookie cookie = new Cookie ( "My cookies " data) ;
cookie.setMaxAge(1);
req.addCookie (cookie);
pw. print In ("<b> Information collected by cookie. </b> <br>");
1644 pw. print In ("<b> value of cookie : <b>"+cookie.get Value () +" <br>");
pw. print In ("<b> name of cookie : <b>"+cookie.get name () +" <br>");
pw. print In ("<b> path of cookie : <b>"+cookie.get path () +" <br>");
pw. print In ("<b> Domain of cookie : <b>"+cookie.get Domain () +" <br>");
pw. print In ("<b> Description of cookie : <b>"+cookie.get comment () +" <br>");
pw. print In ("<b> version of cookie : <b>"+cookie.get Versions () +" <br>");
pw. print In ("<b> MaxAgeof cookie : <b>"+cookie.get MaxAge () +" <br>");
pw. print In ("<b> my cookie : <b>" has been set to ");
pw. print In (data ) ;
pw. close ();
}
}

cookie cookie = new Cookie (MyCooke", data) ;


A. req.addCookie (coookie);

cookie cookie = new Cookie ("MyCooke", data) ;


B. req.addCookie (coookie);

cookie cookie = new Cookie ("MyCooke", data) ;


C. res.addCookie (coookie);

Cookie cookie = new Cookie ("MyCooke", data) ;


D. res.addCookie (coookie);

Answer optiond

Marks: 2

Complete the code below to set the session object false at given underlined line
import java.io.*; import javax. Servlet.*; import javax.servlet. Http.*;
public class Example3 with Session extends HttpServlet
{
public void do Get (HttpServletRequest req,HittpServletResponse res ) throuws ServletException, IOException
{
1645 String color = req. get Parameter("color"); // res. get contentType("text"); PrintWriter pw = res. getWirter(); pw. printIn ("<B>
the Selected color = "); pw. printIn (color ) ; pw. print In ("<B> Test the session <br>");
______________________________________________________
if (session ==null
{ pw. printIn ("no session was available" ); pw. printIn (making one ....."); session = reqq.getSession (); }
else { pw. print In (" there was a session " +session); } pw. close () ; } }

A. HttpSession Session= req.getSession(false);

B. httpSession Session= getSession(false);

C. httpSession Session= req.getSession();

D. all of the above

Answer optiona

Marks: 2

1646 What is the difference between a TextArea and a TextField?

A. A textarea can be used for output

B. A TextArea can handle multiple lines of text

C. TextArea is not a class

D. TextArrea are used for displaying graphics

Answer optionb

Marks: 1

1647 Which of these package is used for graphical user interface ?

A. java.applet

B. java.awt

C. java.awt. Image

D. java.io

Answer optionb
Marks: 1

1648 A JDBC technology -based driver ("JDBC driver") makes it possible to do ?

A. Establish a connection with a data source

B. Send queries and update statements to the data source

C. Process the results

D. All mentioned above

Answer optiond

Marks: 1

1649 Where the session data will store ?

A. Session buffer.

B. Session Disk

C. Session memory

D. Session objects.

Answer optiond

Marks: 1

1650 Which method of the servlet executed first?

A. service()

B. destroy()

C. init()

D. none of the above

Answer optionc

Marks: 1

1651 Arranges the compents as a deck of cards such that only one component is visible at a time

A. A . BorderLayout

B. B.CardLayout

C. C.GridLayout

D. D.FlowLayout

Answer optionb

Marks: 2

1652 Which class can be used to create a server socket. This object is used to establish communication with the clients ?

A. ServerSocket

B. Socket

C. Both A & B

D. None of the above

Answer optionc

Marks: 2

1653 Which methods are commonly used in ServerScocket class ?

A. public OutputStreamgetOutputStream()

B. public Socket accept()

C. public synchronized void close ()

D. None of the above


Answer optionb

Marks: 2

1654 Which list gives a quick way to determine which Connection method is appropriate for creating different types of SQL statements?

A. A.createStatement

B. B.prepareStatement

C. C.prepareCall

D. D.All of the mentioned above

Answer optiond

Marks: 2

In which the result set generally does not show changes to the underlying database that are made while it is open. The membership,
1655 order, and column values of rows are typically fixed when the result set is created?

A. TYPE_FORWARD_ONLY

B. TYPE_SCROLL_INSENSITIVE

C. TYPE_SCROLL_SENSITIVE

D. ALL MENTIONED ABOVE

Answer optionb

Marks: 2

Which statements are missing in the given code below.

import java.awt.*:
import java.awt.event.*;
import java. Applet.*;

public class Pral extends Applet implements ActionListener


{
String s;
Label a ;
Button b;
TextArea t;
public void init ()
{
a = nw Label ( Enter Address: ",LabelLEFT);
b = new Button ("OK");

add (a);
1656 add(t );
add (b);
b.addActionListener(this);
}
public void actionPerformed (ActionEventae)
{
if (ae.getSource()==b)
{
repaint();
}
}
public void paint ( Graphics gr )
{
s=t.getText(0);
gr.drawString ("User Address is : " +s,150,150);
}
}
/*<applet code = Pral width = 400 height = 300 ></applet>*/

A. t= new Textarea ( 5,20);

B. t= new textArea ( 5,20);

C. t= new textarea ( 5,20);

D. t= new TextArea ( 5,20);

Answer optiond

Marks: 2

Which statements is missing in the given code below.


import javax.swing.*;
public class FirstSwingExample extends JFrame
{
public static void main ( String [] args)
{
JFrame f =new JFrame();//creating instance of Jframe
1657 JButton b = new JButton ("click") ;// creating instance of Jbutton
b. setBounds( 130,100,100,40);//x axis ,y axis , width,height
f. add(b);//adding button in JFrame
f.seSize(400,500);//400 width and 500 height
f.setLayout (null);//using no layout manager
}
}
A. f.setVisible(true);

B. f.SetVisible();

C. f.SetLayout(true);

D. SetVisible(true)

Answer optiona

Marks: 2

Which method is missing in the code given below :


import java. Awt. *;
import java.awt.event.*;
class Aevent extends Frame implements ActionListener
{
TextFieldtf; Aevent ()
{
tf=new TextField ();
tf.setBounds(60,50,170,20);
Button b = new Button ("click me " );
b.setBounds (100,120,80,30);
add ( b);
add(tf);
1658 setSize(3600,300);
setLayout(null);
setVisible (true);
}
public void actionPerformed (ActionEvent e )
{
tf.setText("Welcome");
}
pulic static void main ( String args [] )
{
new AEvent();
}
}

A. b.addActionListener()

B. b.add()

C. b.addListener(0

D. b.ActionListener ()

Answer optiona

Marks: 2

1659 Which of the following are valid return types, for listener methods ?

A. Boolean

B. the type of event handled

C. void

D. component

Answer optionc

Marks: 2

1660 Choose the correct alternative to update employee table

A. Statement pstmt = null; try { String SQL = "Update Employees SET age = ? WHERE id = ? "; pstmt = conn. prepareStatement (SQL); … } catch (SQLEx

B. PreparedStatement pstmt = null; try { String SQL = "Update Employees SET age = ? WHERE id = ? "; pstmt = conn. prepareStatement (SQL); … } catc

C. prepareStatement pstmt = null; try { String SQL = "Update Employees SET age = ? WHERE id = ? "; pstmt = conn. prepareStatement (SQL); … } catch

D. both a and c

Answer optionb

Marks: 2

1661 Which is correct method for adding button component into North region of border layout? Assume b1 as button object .

A. b1.add(NORTH)

B. b1.add(BL,NORTH)

C. add(b1.NORTH)

D. add(b1, BorderLayout.NORTH)
Answer optiond

Marks: 1

1662 What are the variables defined in Dimension

A. length and width

B. height and length

C. height and width

D. len and wid

Answer optionc

Marks: 1

1663 Which of the following layout managers need to create a Panel?

A. FlowLayout

B. GridLayout

C. CardLayout

D. NullLayout

Answer optionc

Marks: 1

1664 ItemListener event defines this method�

A. itemEventChanged( )

B. itemEventOccured()

C. itemValueChanged()

D. itemStateChanged()

Answer optiond

Marks: 1

1665 Which of the following creates a List with 3 visible items and multiple mode selection disabled?

A. new List(3,false)

B. new List(3,true)

C. new List(false,3)

D. new List(true,3)

Answer optiona

Marks: 2

1666 Which of the following constructor creates a Checkbox?

A. Checkbox

B. Checkbox(int i)

C. Checkbox(String str, int i)

D. Checkbox(String str, boolean s, null)

Answer optiond

Marks: 2

1667 Which of the following method adds item "I" to the List with deprecation warnings at the end of List?

A. addItem(“I”)

B. addItem(“I”,0)

C. add(“I”)
D. add(“I”,0)

Answer optiona

Marks: 2

1668 Which of the following event of KeyEvent class is generated when a character is pressed?

A. keyPressed

B. keyReleased

C. keyTyped

D. All of above

Answer optiond

Marks: 2

1669 Which of the following handles event in Event Delegation Model?

A. Source

B. Listener

C. Both a and b

D. None of the above

Answer optionb

Marks: 2

1670 Which client accesses the Web server by using a GET MESSAGE?

A. HTTP

B. FTP

C. SMTP

D. IMTP

Answer optiona

Marks: 2

import java.awt.*;
import javax.swing.*;
/*<applet code="L.class" width=200 height=200>
</applet>*/
1671 public class L extends JApplet
{ public void init()
{ ImageIcon i1 = new ImageIcon("Koala.jpeg");
JButton b1=new JButton(i1); getContentPane().add(b1); } }

A. Button is created with given image

B. Button is created without specified image

C. Blank output

D. Error

Answer optiona

Marks: 2

class Fr
{ public static void main(String ar[])
1672 { JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}}

A. closes frame

B. disposes frame

C. exit frame

D. do nothing

Answer optionb

Marks: 2
Find Errors
import java.sql.*;
class Test{
public static void main(String ar[])throws Exception
1673 {
String url="jdbc:odbc:mydsn";
Connection c=DriverManager.getConnection(url);
}
}

A. Drivers are not loaded

B. Drivers are loaded

C. Connection is created

D. Connection is not created

Answer optiona

Marks: 2

what will be the correct output following program.


import java.io.*;
import javax.servlet.*;

public class H extends GenericServlet


{
public void service(ServletRequest req, ServletResponse res)throws ServletException, IOException
1674 {
res.setContentType("text/html");
PrintWriter pw = res.getWriter();
pw.println("<B>Hello!!");
pw.close();

}
}

A. Hello message is displayed

B. No message is printed

C. Hello message is printed with bold style

D. Error

Answer optionc

Marks: 2

1675 Which of the following allows substitution of code to occur at the translation time in a JSP page?

A. <jsp:include> Tag

B. <@ include> directive

C. <@ page > directive

D. Declaration block

Answer optionb

Marks: 2

1676 Which class defines the setSize( ) method ?

A. Frame

B. Applet

C. Component

D. Panel

Answer optiona

Marks: 1

1677 Which class encapsulates a blank window upon which we can draw?

A. Applet

B. Canvas

C. Window

D. Panel
Answer optionb

Marks: 1

1678 Which of these methods are used to determine the type of adjustment event?

A. getType()

B. getEventType()

C. getAdjustmentType()

D. getEventObjectType()

Answer optionc

Marks: 1

1679 Which of the following constructor of InetAddress is generally used?

A. InetAddress()

B. InetAddress(int port)

C. InetAddress(URL url)

D. InetAddress class does not contain any visible constructor.

Answer optiond

Marks: 1

1680 What is the return type of the method getAllByName( ) of InetAddress class?

A. InetAddress[ ]

B. InetAddress

C. Byte[]

D. URL[]

Answer optiona

Marks: 1

The number 80 in following URL specifies?


1681 http://www.rediff.com:80/index.htm/

A. Port number

B. Site number

C. URL Uniform number

D. HTML Page number

Answer optiona

Marks: 1

1682 How can you execute DML statements (i.e. insert, delete, update) in the database?

A. By making use of the InsertStatement, DeleteStatement or UpdateStatement classes

B. By invoking the executeUpdate(...) method of a Statement object

C. By invoking the executeInsert(...), executeDelete(...) or executeUpdate(...) methods of the DataModificationStatement object

D. By making use of the execute(...) statement of the DataModificationStatement object

Answer optionb

Marks: 1

1683 what should you use to position a button within an application Frame so that the size of Button is NOT affected by frame size?

A. FlowLayout

B. GridLayout

C. the center area of BorderLayout


D. the East and West area of BorderLayout

Answer optiona

Marks: 2

1684 Which method specifies that the text and icon are horizontally aligned to the right in the button jbt.

A. jbt.setVerticalTextPosition(JButton.LEFT)

B. jbt.setHorizontalTextPosition(JButton.LEFT)

C. jbt.setHorizontalTextPosition(JButton.RIGHT)

D. jbt.setHorizontalAlignment(JButton.RIGHT)

Answer optionc

Marks: 2

1685 To connect to a server running on the same machine with client, which of the following can be used for hostname?

A. "localhost"

B. "127.0.0.1"

C. InetAddress.getLocalHost()

D. All of the above

Answer optiond

Marks: 2

import java.awt.*;
import java.applet.*
/*<applet code="my.class" width=300 height=300></applet>*/
1686
public class my extends Applet
{ public void paint(Graphics g)
{ g.drawString(�Hello�); } }

A. Hello

B. Compilation Error

C. Runtime Error

D. None of the above

Answer optionb

Marks: 2

Select the missing statement


public class A1 extends Applet
{
Button b1;
Label l1;
public void init()
{ setLayout(new FlowLayout());
b1=new Button("Click");
1687 l1=new Label();
b1.addActionListener(this);
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
l1.setText("Hello");
}

A. add(l1,b1)

B. add(l1); add(b1);

C. add(b1,l1)

D. None of the above

Answer optionb

Marks: 2
import java.sql.*;
class FetchRecord{
public static void main(String args[])throws Exception{

Class.forName("oracle.jdbc.driver.OracleDriver");
1688 Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
Statement stmt=con.createStatement();
int result=stmt.executeUpdate("delete from emp765 where id=33");
System.out.println(result+" records affected");
con.close();
}}

A. deletes the record having id=33

B. inserts the record

C. updates the record

D. retrieves the record

Answer optiona

Marks: 2

what will be the correct output of the following program?


import java.io.*;
import javax.servlet.*;

public class H extends GenericServlet


{
public void service(ServletRequest req, ServletResponse res)throws ServletException, IOException
1689 {
res.setContentType("text/html");
PrintWriter pw = res.getWriter();
pw.println("<H1>Hello!!");
pw.close();

}
}

A. Hello message is displayed

B. No message is printed

C. Hello message is printed with H1 style

D. Error

Answer optionc

Marks: 2

1690 Which is a method of the MouseMotionListener Interface?

A. public void mouseDragged(MouseEvent )

B. public void MouseDragged(MouseMotionEvent)

C. public void mouseDragged(MouseMotionEvent)

D. publicboolenMouseDragged(MouseMotionEvent)

Answer optiona

Marks: 1

1691 ________ is an interface by which application programs can access and process SQL databases in a DBMS-independent manner.

A. ODBC

B. OLE DB

C. JPCD

D. ADO

Answer optiona

Marks: 1

Which of the following are interface?


1.ServletContext
1692 2.Servlet
3.GenericServlet
4.HttpServlet

A. 1,2,3,4

B. 1,2
C. 1,3,4

D. 2,4

Answer optionb

Marks: 1

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 DataInputStream(client.getInputStream());
1693 String data=null;
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");

A. b,c,a

B. a,b,c

C. a,c,b

D. error

Answer optionc

Marks: 2

1694 A benefit of the three-tier architecture is which of the following?

A. New modules can be built to support specific business needs.

B. Performance improves for compiled SQL statements

C. Results in a thinner client and database server

D. All of the above

Answer optiona

Marks: 2

1695 Stored procedures have which of the following advantages?

A. It takes a longer time to write them as compared to writing Visual Basic

B. Network traffic increases

C. Data integrity improves as multiple applications access the same stored procedure.

D. Result in thicker client and thinner database server

Answer optionc

Marks: 2

1696 Which of the following statements is a true statement concerning the open database connectivity standard (ODBC)?

A. Each vendor desiring to be ODBC-complaint provides an ODBC driver.

B. Requires certain criteria to be met in order to establish an ODBC connection.

C. Provides a programming interface that provides a common language for application programs to access and process SQL databases independent of the RDBMS acce

D. All of the above.

Answer optiond

Marks: 2

1697 A servlet can access the headers of an HTTP request through which following methods of the HttpServletRequest interface:

A. getHeader()
B. getHeaderNames()

C. both A and B

D. none of the above

Answer optiond

Marks: 1

class Frame{ Frame(){


}
}
class VFrame extends Frame {
1698 VFrame(){
super();
}
}
Which statement are true?

A. Class VFrame’s constructor is public.

B. Class VFrame’s constructor has arguments

C. Class VFrame’s constructor includes a call to this().

D. Class VFrame’s constructor includes a call to super().

Answer optiond

Marks: 2

1699 Show a single line of code that will convert char ch into String s

A. String s=ch.toString

B. String s=””+ch;

C. String s=ch;

D. none of these

Answer optionb

Marks: 2

1700 The Socket class has how many constructors that a client uses to connect to a server:

A. 2

B. 3

C. 4

D. 5

Answer optiona

Marks: 2

1701 Is Servlet thread Safe?

A. Yes

B. No

C. Maybe

D. cant predict

Answer optionb

Marks: 2

1702 What are controls or components?

A. Controls or components allow users to interact with application

B. Controls or components do not allow users to interact with users

C. Controls or components allow users to interact with users

D. Controls or components allow application to interact with user


Answer optiona

Marks: 1

1703 The JComboBox is having following constructor

A. JCombobox(),JComboBox(Vector v)

B. JComboBox(int v)

C. JComboBox(),JComboBox(Object obj)

D. JCombobox(Vector v,int obj)

Answer optiona

Marks: 2

1704 Which package is used to add progress bar in an application?

A. java.swing

B. javax.swing.ProgressBar

C. javax.swing.JProgrssBar

D. javax.JProgressBar

Answer optionc

Marks: 2

1705 The Swing component classes that are used in encapsulate a mutually exclusive set of buttons are?

A. AbstractButton

B. ButtonGroup

C. Jbutton

D. ImageIcon

Answer optionb

Marks: 1

1706 The JDBC-ODBC bridge allows ---------------------- to be used as ---------------------------

A. JDBC drivers,ODBC drivers

B. Drivers, Application

C. ODBC drivers,JDBC drivers

D. Application,drivers

Answer optiona

Marks: 2

1707 Choose the correct sequence steps for running the servlet

• Write the servlet source code. We need to import the javax.servlet


package and the javax.servlet.http package in your source file.
A. • Compile your source code.
• Run Tomcat. • Create a deployment descriptor

• Write the servlet source code. We need to import the javax.servlet


package and the javax.servlet.http package in your source file.
B. • Create a deployment descriptor. • Compile your source code.
• Run Tomcat.
• Call your servlet from a web bro

• Write the servlet source code. We need to import the javax.servlet


package and the javax.servlet.http package in your source file.
C. • Compile your source code.
• Create a deployment descriptor.
• Call your servlet from a web browser. • Run Tomcat.

• Write the servlet source code. We need to import the java.io , javax.servlet package and the javax.servlet.http package in your source file.
• Compile your source code.
D. • Create a deployment descriptor.
• Run Tomcat.
• Call your servlet from a web browser.

Answer optiond
Marks: 2

Choose the correct missing statement from the given code


import java.awt.*;
import java.io.*;
import java.awt.event.*;
import java.applet.*;
class Myframe extends Frame
{
Myframe(String title)
{
super(title);
}
public void paint(Graphics g)
{
g.drawString("This is frame window",120,150);

}
}

public class Myframeapplet extends Applet //implements windowListener


{
public void init()
{
1708 f1=new Myframe("Frame window");
f1.setSize(350,350);
//f1.setLocation(450,450);
f1.setVisible(true);
//f1.addwindowListener(this);
}
public void start()
{
f1.setVisible(true);
}
public void stop()
{
f1.setVisible(false);
}
public void paint(Graphics g)
{
g.drawString("This ia a applet window",10,50);
}
}

/*<applet code="Myframeapplet" width=1000 height=1000>


</applet>*/

A. Myframeapplet f1;

B. Myframe f1;

C. myframe f1;

D. frame f1;

Answer optionb

Marks: 2

Consider the following program. Find which statement contains error.


import java.applet.*;
import java.awt.*;
import java.awt.event.*;

/*<applet code = "PasswordAL.java" width = 600 height=600></applet>*/

public class PasswordAL extends Applet implements ActionListener


{

Button b1; String msg;


TextField t1;

public void init()


{
b1 = new Button("Click ME");
b1.addActionListener(this);
add(b1);
msg ="Wait";
t1 = new TextField(10);
t1.setEchoChar('#');
add(t1);
}
1709
public void actionPerformed()
{
String t;
t = ae.getActionCommand();
if(t.equals("Click ME") )
{
t = t1.getText();
if(t.equals("java") )
msg = "Correct";
else
msg="Wrong";
repaint();
}

public void paint(Graphics g)


{
g.drawString(msg,200,200);
}

}
A. error in the statement where ActionListener is implemented

B. error in the statement where getActionCommand is called

C. error in the statement where public void actionPerformed() method is called

D. None of the above

Answer optionc

Marks: 2

Choose the correct missing statement from the given code


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class eventdemo2 extends Applet implements ActionListener
{
TextField t1,t2;
Button b1;
public void init()
{
t1=new TextField(5);
t2=new TextField(5);
b1=new Button("FACTORIAL");
add(t1);
add(t2);
add(b1);

}
public void actionPerformed(ActionEvent a)
1710 {
if(a.getSource()==b1)
{
int fact=1;
int n1=Integer.parseInt(t1.getText());

while(n1!=0)
{
fact=fact*(n1);
n1=n1-1;
}
t2.setText(Integer.toString(fact));
}
}
}
/*
<applet code=eventdemo2.class width=250 height=200>
</applet>
*/

A. t1.addActionListener(this);

B. b1.addActionListener(this);

C. t2.addActionListener(this);

D. none of above

Answer optionb

Marks: 2

1711 Choose the proper code for the following output

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;

public class ScrollbarDemo extends Applet implements AdjustmentListener


{
String msg=" ";
Scrollbar vertSB,horiSB;
public void init()
{
vertSB=new Scrollbar(Scrollbar.VERTICAL,0,1,0,100);
A. horiSB=new Scrollbar(Scrollbar.HORIZANTAL,0,1,0,100);
add(vertSB);
add(horiSB);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
}
public void paint(Graphics g)
{
g.DrawString("Vertical:"+vertSB.getValue(),5,200);
g.DrawString("Horizantal:"+vertSB.getValue(),5,220);
}
}
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;

public class ScrollbarDemo extends Applet implements AdjustmentListener


{
String msg=" ";
Scrollbar vertSB,horiSB;
public void init()
{
vertSB=new Scrollbar(Scrollbar.VERTICAL,0,1,0,100);
B. horiSB=new Scrollbar(Scrollbar.HORIZANTAL,0,1,0,100);
add(vertSB);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
repaint();
}
public void paint(Graphics g)
{
g.DrawString("Vertical:"+vertSB.getValue(),5,200);
g.DrawString("Horizantal:"+vertSB.getValue(),5,220);
}
}

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;

public class ScrollbarDemo extends Applet implements AdjustmentListener


{
String msg=" ";
Scrollbar vertSB,horiSB;
public void init()
{
vertSB=new Scrollbar(Scrollbar.VERTICAL,0,1,0,100);
C. horiSB=new Scrollbar(Scrollbar.HORIZANTAL,0,1,0,100);
add(vertSB);
add(horiSB);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
repaint();
}
public void paint(Graphics g)
{
g.DrawString("Horizantal:"+vertSB.getValue(),5,220);
}
}

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;

public class ScrollbarDemo extends Applet implements AdjustmentListener


{
String msg=" ";
Scrollbar vertSB,horiSB;
public void init()
{
vertSB=new Scrollbar(Scrollbar.VERTICAL,0,1,0,100);
horiSB=new Scrollbar(Scrollbar.HORIZANTAL,0,1,0,100);
D. add(vertSB);
add(horiSB);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
repaint();
}
public void paint(Graphics g)
{
g.DrawString("Vertical:"+vertSB.getValue(),5,200);
g.DrawString("Horizantal:"+vertSB.getValue(),5,220);
}
}

Answer optiond

Marks: 2
Consider the following program
Select the statement that should be added to the program to get correct output.

import java.sql.*;
import java.io.*;
public class DeleteRecord4
{
public static void main (String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:mcm");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
1712 System.out.print("Enter rollno to delete:");
int rno=Integer.parseInt(br.readLine());
stmt.setInt(1,rno);

stmt.executeUpdate();
System.out.println("Record Deleted");
stmt.close();
conn.close();
br.close();
}
catch(ClassNotFoundException ce){}
catch(SQLException se){}
catch(IOException ie){}
}
}

A. stmt.setInt(1,rno);

B. stmt.executeUpdate();

C. PreparedStatement stmt=conn.prepareStatement("Delete from Stud where rno=?");

D. No statement is missing

Answer optionc

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.sql.*;
import java.io.*;

public class InsertRecord2


{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:");
Statement stmt=conn.createStatement();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
1713 System.out.println("\nEnter userid:");
String uid=br.readLine();
System.out.println("\nEnter password:");
String ps=br.readLine();
stmt.executeUpdate("insert into login values(' "+uid+" ',' "+ps+" ')");
System.out.println("Record Inserted..........");
stmt.close();
conn.close();
br.close();
}
catch(ClassNotFoundException ce){}
catch(SQLException se){}
catch(IOException ie){}
}
}

A. missing {

B. missing ;

C. missing database name

D. missing package file

Answer optionc

Marks: 2
Consider Following Code. Select the statement that should be added to the program to get correct output.
import java.sql.*;
import java.io.*;
public class DeleteRecord3
{
public static void main (String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter rollno to delete:");
1714 int rno=Integer.parseInt(br.readLine());
Statement stmt=conn.createStatement();
stmt.executeUpdate("Delete from Stud where rno="+rno);
System.out.println("Record Deleted");
stmt.close();
conn.close();
br.close();
}
catch(ClassNotFoundException ce){}
catch(SQLException se){}
catch(IOException ie){}
}
}

A. Connection conn=DriverManager.getConnection("jdbc:odbc:mcm");

B. Connection conn=getConnection("jdbc:odbc:mcm");

C. Connection conn=DriverManager.getConnection("mcm");

D. conn=DriverManager.getConnection("jdbc:odbc:mcm");

Answer optiona

Marks: 2

Consider the following code.


Select the missing statement in the given code.
import java.io.*;
import javax.servlet.http.*;
public class CookieExample extends HttpServlet {
public void doGet( HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{

response.setContentType("text/html");
PrintWriter out = response.getWriter();
// print out cookies
Cookie[] cookies = request.getCookies();
1715 for (int i = 0; i < cookies.length; i++) {
Cookie c = cookies[i];
String name = c.getName();
String value = c.getValue();
out.println(name + " = " + value);
}
// set a cookie
String name = request.getParameter("cookieName");
if (name != null && name.length() > 0) {
String value = request.getParameter("cookieValue");
Cookie c = new Cookie(name, value);
response.addCookie(c);
}
}
}

A. missing ;

B. missing {

C. missing import javax.servlet.*;

D. missing constructor

Answer optionc

Marks: 2
Consider the following program
Select the statement that should be added to the program to get correct output.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class CookieServlet extends HttpServlet {public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
Cookie c1 = new Cookie("userName", "Helen");
Cookie c2 = new Cookie("password", "Keppler");
response.addCookie(c1);

response.setContentType("text/html");
1716 PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Cookie Test</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("Please click the button to see the cookies sent to you.");
out.println("<BR>");
out.println("<FORM METHOD=POST>");
out.println("<INPUT TYPE=SUBMIT VALUE=Submit>");
out.println("</FORM>");
out.println("</BODY>");
out.println("</HTML>");
}

A. response.addCookie(c2);

B. response.addCookie(c1);

C. addCookie();

D. response.addcookie(c2);

Answer optiona

Marks: 2

1717 Which of the following applet tags is legal to embed an applet class named Test into a Web page?

< applet
A. class = Test width = 200 height = 100>

< applet
B. code = Test.class width = 200 height = 100></applet>

< applet>
C. code = Test.class width = 200 height = 100>

< applet
D. code = Test.class width = 200 height = 100

Answer optionb

Marks: 1

What is the use of following method in JDialog?


1718 Container getContentPane()

A. This method returns,a Content Pane for the JDialog.

B. This method returns,a Content Pane for the Menu

C. This method returns,a Content Pane for the Applet

D. None of the Above

Answer optiona

Marks: 1

If you need to use a stored procedure with output parameters, which of the following statement type should be used to call the
1719 procedure?

A. Statement

B. PreparedStatement

C. CallableStatement

D. None of the Above

Answer optionc

Marks: 1

Which one of the following will not get the data from the first column of ResultSet rs, returned from executing the following SQL
1720 statement: SELECT name, rank, serial_No FROM employee?

A. rs.getString(0)
B. rs.getString("name")

C. rs.getString(1)

D. None of the Above

Answer optiona

Marks: 1

1721 In which of these getAttribute () and setAttribute() method is declared?

A. HttpSession

B. ServletRequest

C. ServletContext

D. ServletConfig

Answer optiona

Marks: 1

1722 Observe the following output and determine which component and listener is required?

A. Label, frame, actionListener

B. Button, frame, itemListener

C. Button, frame, actionListener

D. None of the above

Answer optionc

Marks: 2

Match The Pair ?


1) Button() a) AdjustmentListener
1723 2) Scrollbar() b) Non Of Above
3) Checkbox() c) ItemListener
4) Label() d) ActionListener

A. 1-d 2-b 3-c 4-b

B. 1-d 2-a 3-b 4-c

C. 1-b 2-a 3-c 4-d

D. 1-d 2-a 3-c 4-b

Answer optiond

Marks: 2

which is not the constructor of URL?


1) public URL()throws MalformedURLException
1724 2) public URL(String Protocol,String Host,int Port,String File) throws MalformedURLException
3) public URL(String URL) throws MalformedURLException.
4) public URL(URL Context,String Url)throws MalformedURLException

A. 2

B. 3

C. 1

D. 4

Answer optionc

Marks: 2
What will be the Output of following code?
import java.sql.*;
public class SmtInterfaceDemo
{

public static void main(String args[])


{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:db");
System.out.println("Connection established.....");

Statement smt=con.createStatement();
System.out.println("Statement Created.....");

String sql="create table t2(Name char,Age int)";

boolean result=smt.execute(sql);
if(result==true)
{
1725 System.out.println("Table Created.....");
}
else
{
System.out.println("Table not Created.....");

con.close();
}

catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException se)
{
se.printStackTrace();
}

}
}

A. Empty table is created in the database

B. Table is created with two data field in database

C. Table is inserted by two data field

D. All of above

Answer optionb

Marks: 2

what will be the final output after Enter the valute for First & Second and also click on Clac Button?
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.PrintWriter;
import java.io.IOException;

public class calcServlet extends HttpServlet


{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
PrintWriter pw=res.getWriter();
res.setContentType("text/html");
pw.println("<html><head><title>CALCULATOR</title></head>");
pw.println("<body>");
pw.println("<form method=post action=calcServlet>");
pw.println("Enter first No.:");
pw.println("<input type=text name=nm><br>");
pw.println("Enter Second No.:");
pw.println("<input type=text name=r>");
pw.println("<input type=submit value=calc>");
pw.println("</form></body></html>");
pw.close();
}
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
1726 {
String a=req.getParameter("nm");
String b=req.getParameter("r");
int c=Integer.parseInt(a);
int d=Integer.parseInt(b);
int e=c+d;
int f=c-d;
int g=c*d;
PrintWriter pw=res.getWriter();
res.setContentType("text/html");
pw.println("<html><head><title>CALCULATOR</title></head>");
pw.println("<body>");
pw.println(a+"+"+b+"="+e+"<br>");
pw.println(a+"-"+b+"="+f+"<br>");
pw.println(a+"*"+b+"="+g+"<br>");

int h=c/d;
pw.println(a+"/"+b+"="+b+"<br>");

pw.println("</body></html>");
pw.close();
}
public void destroy()
{}
}
A. o1

B. o2

C. o3

D. None of the Above

Answer optiona

Marks: 2

which statement is required for following output?


import java.awt.*;
import java.applet.*;
public class TextArea_Demo extends Applet
{
TextArea ta1;
1727 public void init()
{
ta1=new TextArea("My name Is troy",25,25);
ta1.append(" name is khan ");
}
}

A. add(textarea)

B. add(ta1)

C. add(TextArea1)

D. all of the above

Answer optionb

Marks: 2

import java.awt.*;
import java.applet.*;
/*<applet code="Choice_Demo.class" width=300 height=300></applet>*/
public class Choice_Demo extends ________________
{
Choice c1;
1728 public void init()
{
c1=new Choice();
add(c1);
}
}

A. Applet

B. Panel

C. Frame

D. None of the above

Answer optiona

Marks: 2

import java.awt.*;
import javax.swing.*;
public class Swing_Demo extends JApplet
{
public void init()
1729 {
ImageIcon ii=new ImageIcon("Sunset.jpg");
JLabel l1=new JLabel("Sunset Image",ii,JLabel.CENTER);
c.add(l1);
}
}

A. Semicolon missing ‘ ;’

B. Container c=getContentPane();

C. Package missing

D. getContentPane();

Answer optionb

Marks: 2
which listener is missing in following code.?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TextField_Demo extends Applet implements _______________
{
Label l1,l2;
TextField t1,t2;
String msg;
public void init()
{
l1=new Label("Name :");
l2=new Label("Pass :");
t1=new TextField(20);
t2=new TextField(20);
t2.setEchoChar('*');
add(l1);
add(t1);
add(l2);
1730 add(t2);
t1.addActionListener(this);
t2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
repaint();
}
public void paint(Graphics g)
{
msg="Name : ";
msg+=t1.getText();
g.drawString(msg,6,100);
msg="Selected text : ";
msg+=t1.getSelectedText();
g.drawString(msg,6,200);
msg="Pass : ";
msg+=t2.getText();
g.drawString(msg,6,300);
}

A. ActionListener

B. Itemlistener.

C. AdjustmentListener.

D. EventListener.

Answer optiona

Marks: 2

Find the missing statement for getting following output

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Swing_Demo1 extends JApplet implements ActionListener
{
JButton b1,b2,b3,b4;
JTextField t1;
public void init()
{
Container c=getContentPane();
c.setLayout(new GridLayout(3,3));
t1=new JTextField(20);
c.add(t1);

ImageIcon i1=new ImageIcon("Sunset.jpg");


ImageIcon i2=new ImageIcon("Blue hills.jpg");
ImageIcon i3=new ImageIcon("Winter.jpg");
ImageIcon i4=new ImageIcon("Water lilies.jpg");

b2=new JButton(i2);
b3=new JButton(i3);
b4=new JButton(i4);

b1.setActionCommand("Sunset image");
b2.setActionCommand("Blue hills");
1731 b3.setActionCommand("Winter");
b4.setActionCommand("Water lilies");

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);

c.add(b1);
c.add(b2);
c.add(b3);
c.add(b4);

}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
t1.setText(b1.getActionCommand());
if(ae.getSource()==b2)
t1.setText(b2.getActionCommand());
if(ae.getSource()==b3)
t1.setText(b3.getActionCommand());
if(ae.getSource()==b4)
t1.setText(b4.getActionCommand());
}
}
A. b1=new JButton(i1);

B. Button b1=new JButton(i1);

C. b1=new JButton(b1);

D. None of the above

Answer optiona

Marks: 2

Which statement is missing from the code


import java.net.*;
import java. io.*;
class Demo
{
1732 public static void main(String args[])
{
URL url=new URL(�http://www.yahho.com/context/current/news.html�);
System.out.println(�{Protocol :�+url. ----------- );
}
}

A. getProtocol()

B. gethost()

C. GetProtocol()

D. None of the above

Answer optiona

Marks: 2

Which statement required for getting proper output


import java.sql.*;
public class updatevalues1
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:db");
String sql="update StudTable set Name=? where Rollno=2";
String Name="Ram";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1,Name);
1733 ----------------------------------------- ;
System.out.println("Record Updated.................");
con.close();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException se)
{
se.printStackTrace();
}
}
}

A. ps.execute();

B. ps.executeUpdate()

C. ps.executeQuery()

D. None of the above

Answer optionb

Marks: 2
What is the error in this code
import java.sql.*;
class ConnectionDemo
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded.....");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
System.out.println("Connection Established....");
System.out.println("Object is Created....");
String sql="create table Raisoni(Name char,Age int)";
1734 boolean res=smt.execute(sql);
if(res==true)
System.out.println("table is created...");
else
System.out.println("Table is not created....");
}
catch(SQLException e)
{
System.out.println("SQL Error...");
}
catch(Exception e)
{
System.out.println("Error is Found...");
}
}
}

A. Semicolon missing

B. Statement not created

C. }

D. Connection not Created

Answer optionb

Marks: 2

1735 What will happen if we does not use the close() method?

A. Program will not terminated

B. Connection will not close

C. Database does not get update

D. Driver Does not load

Answer optionb

Marks: 2

Which Content Type used in following Program?


import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.PrintWriter;
import java.io.IOException;

public class ServiceServlet extends HttpServlet


{
public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
response.setContentType("text/plain");
PrintWriter out=response.getWriter();
1736 if(request.getMethod().equals("GET"))
{
out.println("Request handeled by the service() method");
}
else
{
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
out.println("Method not supported by this servlet");
}
out.close();
}
}

A. text/plain

B. text/html

C. text/jar

D. text/image

Answer optiona

Marks: 2

1737 Executable applet is nothing but _________ file of applet


A. .txt

B. .java

C. .class

D. .html

Answer optionc

Marks: 1

1738 Default orientation of progress bar is:

A. Vertical

B. Horizontal

C. Diagonal

D. Cross

Answer optionb

Marks: 1

1739 Java supports input/output of data through the classes included in the _______ package:

A. java.oi

B. Java.io

C. Java.in

D. Java.out

Answer optionb

Marks: 1

1740 If scroll bar is manipulated ��������.event will be notified.

A. ActionEvent

B. ComponentEvent

C. AdjustmentEvent

D. WindowEvent

Answer optionc

Marks: 2

1741 If you use either Telnet or FTP, which is the highest layer you are using to transmit data?

A. Application

B. Presentation

C. Session

D. Transport

Answer optiona

Marks: 2

1742 EventObject class is defined in which of these libraries?

A. java.io

B. java.lang

C. java.net

D. java.util

Answer optiond

Marks: 2
1743 In which advantage of servlet, Servlets are managed by JVM so no need to worry about memory leak, garbage collection etc.?

A. Better performance

B. Portability

C. Robust

D. Secure

Answer optionc

Marks: 2

1744 In RequestDispacher which method is used to sends the same request and response objects to another servlet?

A. forward()

B. sendRedirect()

C. Both A & B

D. None of the above

Answer optiona

Marks: 2

1745 Which class provides many methods for graphics programming?

A. java.awt

B. java.Graphics

C. java.awt.Graphics

D. None of the above

Answer optionc

Marks: 1

1746 SQL stands for ________ .

A. Structured Query Language

B. Sequential Query Language

C. Structured Question Language

D. Sequential Question Language

Answer optiona

Marks: 1

1747 You can add a row using SQL in a database with which of the following?

A. ADD

B. CREATE

C. INSERT

D. MAKE

Answer optionc

Marks: 1

1748 The command to remove all the rows from a table 'CUSTOMER' is:

A. REMOVE FROM CUSTOMER

B. DROP FROM CUSTOMER

C. DELETE FROM CUSTOMER

D. UPDATE FROM CUSTOMER

Answer optionc
Marks: 1

1749 Which of the following is the correct order of keywords for SQL SELECT statements?

A. SELECT, FROM, WHERE

B. FROM, WHERE, SELECT

C. WHERE, FROM,SELECT

D. SELECT,WHERE,FROM

Answer optiona

Marks: 1

1750 MIME is the abbreviation of ___________.

A. Multilevel internet Mail Extension

B. Multipurpose internet Mail Extension

C. Multiuse information Mail Extension

D. None of the above

Answer optionb

Marks: 1

1751 A JFrame supports three operations when the user closes the window. Which of the choices below is not one of the three:

A. DISPOSE_ON_CLOSE

B. DO_NOTHING_ON_CLOSE

C. LOWER_ON_CLOSE

D. HIDE_ON_CLOSE

Answer optionc

Marks: 2

1752 You can create a JTable using __________

A. new JTable()

B. new JTable(4, 5)

C. new JTable(new Integer[3][4], new Integer[4])

D. All Above

Answer optiond

Marks: 2

1753 _________ are the properties in JTable.

A. gridColor

B. rowCount

C. columnCount

D. All Above

Answer optiond

Marks: 2

1754 Clicking the closing button on the upper-right corner of a frame generates a(n) __________ event.

A. ItemEvent

B. WindowEvent

C. MouseMotionEvent

D. ComponentEvent
Answer optionb

Marks: 2

1755 The statement ___________ changes the Course title to Java Programming for the CourseID 11111.

A. update table Course set title = 'Java Programing' where courseId = '11111'

B. update Course set title = 'Java Programing' where courseId = '11111'

C. update table Course set title = "Java Programing" where courseId = "11111"

D. update table Course set title = "Java Programing" where courseId = "11111"

Answer optionb

Marks: 2

What code should be added so that we can get following Code?


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=SignIn.class width=400 height=400></applet>*/

public class SignIn extends Applet implements ActionListener


{
TextField t1,t2;
Button b1;
Label l;
public void init()
{
t1=new TextField(20);
t2=new TextField(20);
b1=new Button("Sign In");
l=new Label("");
add(t1);
add(t2);
---------------------
add(b1);
1756 ----------------------
add(l);
}

public void actionPerformed(ActionEvent ae)


{
if(ae.getSource()==b1)
{
String msg=t1.getText();
String msg1=t2.getText();

if(msg.equals("Admin")&&msg1.equals("Admin"))
{
l.setText("Correct Password");
}
else
{
l.setText("Incorrect Password");
}
}
}
}

A. b1.addActionListener(this);

B. t2.setEchoChar('*');

C. Both A & B

D. Either A or B

Answer optionc

Marks: 2
What code should be added so that we can get following Code?
import java.awt.*;
import java.awt.event.*;

class WindowCloseDemo extends Frame


{
Button exit;
WindowCloseDemo()
{

exit=new Button("Exit");
add(exit);
WindowClose w=new WindowClose();
addWindowListener(w);
setTitle("Window");
1757 setSize(400,300);
setVisible(true);
}

public static void main(String []cd)


{
WindowCloseDemo wcd=new WindowCloseDemo();
}
}
class WindowClose extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(1);
}
}

A. setLayout(new BorderLayout());

B. setLayout(new CardLayout());

C. setLayout(new BoxLayout());

D. setLayout(new FlowLayout());

Answer optiond

Marks: 2

For the following code select the method that can be used to handle event. ?
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=ListDemo.class width=400 height=400></applet>*/

public class ListDemo extends Applet implements ItemListener


{
List l;
String msg="";

public void init()


{
l=new List(2,true);
l.add("Day");
for(int i=1;i<=31;i++)
{
l.add(i+"");
}
1758 add(l);
l.addItemListener(this);
}

public void _______________________________


{
repaint();
}

public void paint(Graphics g)


{
int idx[];
idx=l.getSelectedIndexes();
for(int i=0;i<idx.length;i++)
{
msg=l.getItem(idx[i]);
g.drawString(msg,20,i*10+20);
}
}
}

A. actionPerformed(ActionEvent e)

B. adjustmentValueChanged(AdjustmentEvent e)

C. itemStateChanged(ItemEvent e)

D. None Of Above

Answer optionc

Marks: 2
What is missing in following code ?
import java.awt.*;
import java.applet.*;
/*<applet code=FontExample.class width=200 height=200></applet>*/
public class FontExample extends Applet
{
Font f;
public void init()
1759 {
f=new Font("Cambria Math",2,20);
set**********(f);
}
public void paint(Graphics g)
{
g.drawString("Adv Java",20,50);
}
}

A. implements ActionListener

B. setBackground(f)

C. setForeground(f)

D. setFont(f)

Answer optiond

Marks: 2

What should be written for ______ in following code ?


import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*<applet code=ScrollDemo.class height=400 width=600></applet>*/

public class ScrollDemo extends Applet implements AdjustmentListener


{
Scrollbar v;
1760 public void init()
{
v=new Scrollbar();
add(v);
v.addAdjustmentListener(this);
}
public void __________________(AdjustmentEvent ae)
{

}
}

A. actionPerformed

B. itemStateChanged

C. AdjustmentValueChanged

D. MouseClicked

Answer optionc

Marks: 2

Consider the following program.


What should be the method used in following program to get correct output?
import java.sql.*;
class Ddemo1
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.get***********("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
1761 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();
}
}
}

A. getLocalHost()

B. Connection()

C. getResultSet()

D. getMoreResults()

Answer optionb

Marks: 2
Consider the following program
What will be the output of following Code?
import java.sql.*;
public class db15
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:DSN2","","");
Statement s=c.createStatement( );
1762 int n=s.executeUpdtae("delete from db3");
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.getDouble(3));
}
s.close();
c.close();
}
}

A. Empty Table

B. Table with All Data

C. Error in ResultSet Statement

D. Error in close()

Answer optiona

Marks: 2

Consider the following program, it has 10 Records in the Table. What will be the output of following Code?

import java.sql.*;
public class db15
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:DSN2","","");
Statement s=c.createStatement( );
1763 int n=s.executeUpdate("update table set name='Ramesh'");
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.getDouble(3));
}
s.close();
c.close();
}
}

A. Ramesh name will be given only for 1st Record

B. The query will not be processed

C. Ramesh name will be given to all the records

D. None Of Above

Answer optionc

Marks: 2

Consider the following program. Which packages must be included for Successfully executing the code?

// Extend HttpServlet class


public class HelloWorld extends HttpServlet {

String message;

public void init() throws ServletException


{
// Do required initialization
message = "Hello World";
}
1764 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
// Set response content type
response.setContentType("text/html");

// Actual logic goes here.


PrintWriter out = response.getWriter();
out.println("<h1>" + message + "</h1>");
}
public void destroy()
{
// do nothing.
}
}

import java.io.*;
A. import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
B. import javax.servlet.*;

import java.net.*;
C. import javax.servlet.*;

D. None Of Above

Answer optiona

Marks: 2

Consider the following program. Which class should be extended.


import java.io.*;
import javax.servlet.*;

public class First extends **************{


public void service(ServletRequest req,ServletResponse res)
throws IOException,ServletException{

1765 res.setContentType("text/html");

PrintWriter out=res.getWriter();
out.print("<html><body>");
out.print("<b>hello generic servlet</b>");
out.print("</body></html>");

}
}

A. Cookie

B. GenericServlet

C. HttpServlet

D. HttpSessionEvent

Answer optionb

Marks: 2

In following Java program which package needs to be imported for Enumeration?

import java.io.*;
import javax.servlet.*;

public class Second extends GenericServlet


{
public void service(ServletRequest req,ServletResponse res)
throws IOException,ServletException{

res.setContentType("text/html");
1766 Enumeration e=req.getParameterNames();
PrintWriter out=res.getWriter();
while(e.hasMoreElements())
{
String name=(String) e.nextElement();
out.print(name+" ");
String value=req.getParameter(name);
out.print(value);
}
out.close();
}

A. import java.net.*;

B. import javax.servlet.http.*;

C. import java.util.*;

D. None of Above

Answer optionc

Marks: 2

1767 A JCheckBoxMenuItem is a subclass of ________.

A. AbstractButton

B. JComponent

C. JMenuItem

D. All of these

Answer optiond

Marks: 1

1768 Which method sets the size and position of a component


A. setComponent()

B. setSizeAndPosition()

C. setComponentSize()

D. setBounds()

Answer optiond

Marks: 1

1769 _______ generates action events when an item is double-clicked.

A. List

B. Checkbox

C. MenuItem

D. TextField

Answer optiona

Marks: 1

1770 Which method is used to close server socket connection?

A. void close()

B. int close()

C. InetAddress close()

D. boolean close()

Answer optiona

Marks: 1

1771 Which method must be used to execute INSERT, UPDATE, or DELETE statement .

A. executeQuery()

B. executeDMLQuery()

C. executeUpdate()

D. executeDelete()

Answer optionc

Marks: 1

1772 Which driver type use middleware server(Application Server)?

A. Type 1

B. Type 2

C. Type 3

D. Type 4

Answer optionc

Marks: 1

An image file representing a company's logo has to be uploaded to the server.


1773 Which of the following HTTP methods can be used in this situation?

A. doGet()

B. doPost()

C. doTrace()

D. doPut()

Answer optiond

Marks: 1
1774 Which interface define a getSession() method?

A. ServletRequest

B. ServletResponse

C. HttpServletRequest

D. HttpServletResponse

Answer optionc

Marks: 1

1775 Which of the following implicit objects is not available to a JSP page by default?

A. application

B. session

C. context

D. config

Answer optionc

Marks: 1

1776 Which of the following is not a constructor of FileDialog?

A. FileDialog()

B. FileDialog(Frame f)

C. FileDialog(Frame f, String title,int mode)

D. FileDialog(Frame f, String title)

Answer optiona

Marks: 2

1777 What AWT classes (components) will be needed to get following output?

A. Label,Checkbox,RadioButton,BorderLayout

B. Label,Checkbox,checkboxGroup,FlowLayout

C. Label,Checkbox,JRadioButtonFrame,FlowLayout

D. Label,Checkbox,GridLayout,ButtonGroup

Answer optionb

Marks: 2

For the following code select the method that can be used to handle event.
import java.applet.*;
import java.awt.*;
public class S1Q29 extends Applet implements TextListener{
Label l;
TextField t1 ;
String msg="";
public void init(){
t1 =new TextField(10);
l = new Label("Enter String");
add(t1);
t1.addTextListener(this);
1778
}
public void ______________________________{
msg = t1.getText();
repaint();
}
public void paint(Graphics g){
g.drawString(msg,100,100);
}
}
/*<applet code=checkbackg.class height=150 width=150>
</applet>*/

A. textValueChanged(TextEvent e)

B. itemStateChanged(TextEvent e)

C. textValueChang(TextEvent e)

D. textChanged(TextEvent e)
Answer optiond

Marks: 2

1779 Select the Listeners needed for components shown in application.

A. actionPerformed(ActionEvent e),itemStateChanged(ItemEvent e)

B. actionPerformed(ActionEvent e),itemValueChanged(ItemEvent e)

C. adjustmentPerformed(AdjustmentEvent ae),itemStateChanged(ItemEvent e)

D. ActionPerformed(ActionEvent e),ItemStateChanged(ItemEvent e)

Answer optiona

Marks: 2

In the following code, what type of protocol is Socket object "skt" uses?
import java.io.*;
import java.net.*;
public class NetClient {
1780 public static void main(String args[]) throws Exception {
Socket skt = new Socket("host",88);
}
}

A. Connectionless

B. FTP

C. UDP

D. TCP

Answer optiond

Marks: 2

1781 Which code segment could execute the stored procedure "countRecs()" located in a database server?

Statement stmt = connection.createStatement();


A. stmt.execute("COUNTRECS()");

CallableStatement cs = con.prepareCall("{call COUNTRECS}");


B. cs.executeQuery();

StoreProcedureStatement spstmt = connection.createStoreProcedure("countRecs()");


C. spstmt.executeQuery();

PrepareStatement pstmt = connection.prepareStatement("countRecs()");


D. pstmt.execute();

Answer optionb

Marks: 2

1782 In a URL query string, the parameter name and value are associated using the ____ symbol.

A. ?

B. =

C. +

D. &

Answer optionb

Marks: 2

1783 Which retrieves all cookies sent in a given HttpServletRequest request?

A. request.getCookies()

B. request.getAttributes()

C. request.getSession ().getCookies()

D. request.getSession (). GetAttributes()

Answer optiona

Marks: 2
From the following code find the correct occurence of key event.
import java.awt.*;
import java.awt.event.*;
public class S1Q46 extends Frame implements KeyListener{
TextField t1;
public S1Q46(){
setLayout(new FlowLayout());
t1= new TextField(10);
t1.addKeyListener(this);
add(t1);
setVisible(true);
}
1784 public void keyTyped(KeyEvent e) {
System.out.println("Key Typed");
}
public void keyPressed(KeyEvent e) {
System.out.println("Key Pressed");
}
public void keyReleased(KeyEvent e) {
System.out.println("Key Released");
}
public static void main(String arg[]){
S1Q46 s = new S1Q46();
}

Key Pressed
A. Key Released
Key Typed

Key Pressed
B. Key Typed
Key Released

Key Typed
C. Key Pressed
Key Released

Key Released
D. Key Typed
Key Pressed

Answer optionb

Marks: 2

Which statement is true about the code fragment listed below?


class MyListener extends MouseAdapter implements MouseListener
{
public void mouseEntered(MouseEvent mev)
1785 {
System.out.println(�Mouse entered.�);
}
}

The code will not compile correctly, because the class does not provide all the methods of the
A. MouseListener interface.

B. The code compiles without error. During execution, an exception will be thrown if a component uses this class as a mouse listener and receives a mouse-exit

C. The code compiles without error and defines a class that could be used as a mouse listener.

D. You can not implement MouseListener interface in MouseAdapter class

Answer optionc

Marks: 2

In following Java program fill statement showing **************.Select any one option to get correct output.
import java.sql.*;
public class S1Q53 {
public static void main(String arg[]){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(""jdbc:odbc:shree");
int rno=7;
String name1 ="hari";
String query ="insert into student(rollno,name) values(?,?)";
PreparedStatement pstm = con.prepareStatement(query);
*****************
1786 *****************
int a= pstm.executeUpdate();
if(a==1){
System.out.println("inserted");
}else{
System.out.println(" not inserted");
}
} catch (Exception ex) {
System.out.println(ex);
}
}
}

A. pstm.setString(1, name1); and pstm.setInt(2, rno);

B. pstm.setInt(1, rno); and pstm.setString(2, name1);

C. pstm.setInt(1, "name"); and psrm.setInt(1,rno);

D. pstm.setInt(rno); and pstm.setString(name1);


Answer optionb

Marks: 2

Consider the following program.Select the statement that should be added to the program to delete the record from student table.

import java.sql.*;
public class Delete {
public static void main(String[] args) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
1787 Connection con = DriverManager.getConnection("jdbc:odbc:shree");
Statement stm = con.createStatement();
String query ="delete from student where rollno=1";

} catch (Exception ex) {


System.out.println(ex);
}
}
}

A. stm.executeQuery();

B. stm.executeUpdate(query);

C. stm.executeUpdate();

D. stm.execute();

Answer optionb

Marks: 2

What happens if the following code is executed?


import java.sql.*;
public class S1Q57{
public static void main(String[] args) {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:shree");
Statement stm = con.createstatement();
String query ="select rollno,name,percent from student ";
ResultSet rs = stm.executeQuery(query);
1788
while(rs.next()){
System.out.println("Roll No = "+rs.getInt(1));
System.out.println("Name = "+rs.getString(2));
System.out.println("per = "+rs.getDouble(3));
}
con.close();
}
}

A. There is a compiler error

B. There is a run time error

C. Program run Successfully and print the content of table

D. Retrieval of the fields is in the wrong order

Answer optiona

Marks: 2

index.html
<html>
<form method="GET"action="MyServlet">
<input type="text" name="foo" /><br>
<input type="text" name="foo" /><br>
<input type="submit" value="Submit" />
</form>
</html>
MyServlet.java
1789 import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String second = ************
}
}
From the above code fill statement showing ************** that retrive the text from the second text field.

A. second = request.getParameter("foo");

B. second = request.getParameter("foo",2);

C. second = request.getParameter("foo")[1];

D. second = request.getParameterValues("foo")[1];

Answer optiond

Marks: 2
What will be the output of the following code snippet?
<% int a=5; %>
1790 <%! int a=10; %>
a = <%=a + this.a%> :: <%= this.a%>

A. a = 15 :: 10

B. a = 10 :: 15

C. The code snippet fails to compile because the variable a is declared twice.

D. a = 10 :: 10

Answer optiona

Marks: 2

Given:
<%-- insert code here --%>
<html>
<body>
1791 Today is: <%= new Date() %>
</body>
</html>
What needs to go on line 1?

A. <%@ page import='java.util.Date' %>

B. <%@ import class='java.util.Date' %>

C. <%@ include file='java.util.Date' %>

D. <%@ include class='java.util.Date' %>

Answer optiona

Marks: 2

1792 Which of the following may contain a menu bar?

A. panel

B. frame

C. applet

D. menu bar

Answer optionb

Marks: 1

1793 ODBC stands for

A. object database connectivity

B. open database connectivity

C. all the above

D. none of the above

Answer optionb

Marks: 1

1794 the interface to the database is handle by

A. ODBC

B. JDBC

C. JDBC &ODBC

D. APIS

Answer optiond

Marks: 2

1795 Which is the correct discription of the close() method

A. closes the current stmt object

B. closes the next stmt object


C. close the object only

D. none of the above

Answer optiona

Marks: 2

What is the output of following program:

import java.sql.*;

class exp10_5
{
public static void main(String m[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
1796 Connection con=DriverManager.getConnection("jdbc:odbc:dsnname");
Statement cmd=con.createStatement();
rs=cmd.executeQuery("select * from tabel1");
while(rs.next())
{
System.out.println(rs.getInt(1)+""+rs.getInt(2)+""+rs.getString(3));
}
cmd.close();
con.close();
}
}

Compile Error
A.

B. Runtime Error

C. It prints all data from table

D. None of these

Answer optiona

Marks: 2

What is the type of 'cmd' object in the following program.

import java.sql.*;

class exp11_4
{
public static void main(String arg[])
{
Class.forName("sun.jdbc.odbc,JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:dsnname");
1797 String str="select * from emp where ename='ram'";
____________________cmd=con.__________________(str);
ResultSet rs=cmd.executeQuery();
while(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2));
}
cmd1.close();
con.close();
}
}

A. Statement

B. PreparedStatement

C. CallableStatement

D. stmt

Answer optionb

Marks: 2

1798 What programming language(s) or scripting language(s) does Java Server Pages support?

A. Any Programming Language code

B. Java Script

C. VBScript

D. Java only

Answer optiond

Marks: 2

1799 Which is the container that contain title bar and can have MenuBars. It can have other components like button, textfield etc.?

A. Panel
B. Frame

C. Window

D. Container

Answer optionb

Marks: 1

1800 What is default hgap and vgap value in Border Layout?

A. 1

B. 2

C. 3

D. 0

Answer optiond

Marks: 1

1801 Which event is handled on MenuItem?

A. ActionEvent

B. ItemEvent

C. AdjustmentEvent

D. KeyEvent

Answer optiona

Marks: 1

1802 What is default mode of Dialog Box?

A. Modal

B. Non-Modal

C. Can not be decided

D. Both a) and b)

Answer optionb

Marks: 1

1803 What type of JProgressBar() is created using default constructor?

A. Horizontal

B. Vertical

C. Not Fixed

D. None of the Above

Answer optiona

Marks: 1

1804 Event Registration is done by whom?

A. Event Source

B. Event Registration

C. Event Listener

D. Event

Answer optiona

Marks: 1

1805 Which method is supported by KeyListener interface?


A. KeyTyped()

B. KeyTyping()

C. keyType()

D. None of the Above

Answer optiona

Marks: 1

1806 What is use of Adapter class?

A. Provides default implimentation of all methods in an event listener interface.

B. It needs all methods to be implemented

C. It' s implementation is simple

D. It is easy to understand

Answer optiona

Marks: 1

1807 Which of the following method is defined by ActionEvent class?

A. getAction()

B. getCommand()

C. getSource()

D. getActionEvent()

Answer optionc

Marks: 1

1808 Which class is used to create servers that listen for either local client or remote client programs?

A. ServerSocket

B. HttpServlet

C. HttpServer

D. HttpResponse

Answer optiona

Marks: 1

1809 The client in socket programming must know which informations?

A. IP Address of Server

B. Port Number

C. Both A & B

D. None of the Above

Answer optionc

Marks: 1

1810 Which method is used for saving records in a database?

A. commit()

B. commit once()

C. single Commit()

D. None of the Above

Answer optiona

Marks: 1
1811 Which of the following constructor creates a RadioButton?

A. Checkbox()

B. Checkbox(int i)

C. Checkbox(String str, int i)

D. Checkbox(String str, boolean s, cbg)

Answer optiond

Marks: 2

1812 Which of the following method adds item "N" to the List without deprecation warnings at the end of List?

A. addItem(“N”)

B. addItem(“N”,0)

C. add(“N”)

D. add(“N”,0)

Answer optionc

Marks: 2

1813 Which of these is superclass of all Adapter classes?

A. Applet

B. EventObject

C. ComponentEvent

D. InputEvent

Answer optionb

Marks: 2

What is output of following program?


import java.net.*;
class networking {
public static void main(String[] args) throws Exception {
URL obj = new URL("http://www.sanfoundry.com/javamcq");
1814 URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType());
}
}
Host URL is written in html and simple text.

A. html

B. text

C. html/text

D. text/html

Answer optiond

Marks: 2

1815 What a deployment descriptor specifies?

A. web component response settings

B. web component settings

C. web component request objects

D. All of the above

Answer optionb

Marks: 2

1816 What the getSession() method with true parameter will returned?

A. the session is completed

B. the session object is passed to another method


C. the session does not exist

D. the session is existing

Answer optiond

Marks: 2

1817 Which cookie is valid for single session only; it is removed each time when user closes the browser?

A. Persistent

B. Non-persistent

C. both a and b

D. None of the above

Answer optionb

Marks: 2

public class L extends JApplet


{ public void init()
1818 { ImageIcon i1 = new ImageIcon(�B1.bmp�);
JButton b1=new JButton(i1); add(b1); } }

A. Button is created with B1 image

B. Button is created without specified image

C. Blank output

D. Error

Answer optionb

Marks: 2

What size of Grid is created?


public class A1 extends Applet
{ public void init()
{ setLayout(new GridLayout());
1819 Button b1=new Button("one");
Button b2=new Button("Two");
Button b3=new Button("Three");
} }

A. three button in one column

B. three button in two column

C. three button in Three column

D. None of the above

Answer optionc

Marks: 2

public class A1 extends Applet


{ public void init()
1820 { setLayout(new FlowLayout());
Button l1 = new Button(�1�);
add(l1); } }

A. Blank output

B. Button is added at Left

C. Label is added at Right

D. Button is added at Center

Answer optiond

Marks: 2

Predict the output


public class R1 extends Applet implements ItemListener
{ public void init()
{ Checkbox c1 = new Checkbox();
add(c1);
1821 c1.addItemListener(this);
Label l1 = new Label();
add(l1); }
public void itemStateChanged(ItemEvent ie) {
if(ae.getItemSelectable()==c1)
l1.setText("Hi"); } }
A. Hi is printed

B. No message is printed

C. Blank Output

D. Error

Answer optiona

Marks: 2

What will be the output of the following code:


import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*<applet code=MFont width=300 height=200>


</applet>*/

public class MFont extends Applet


{
int size=10,i=10;
Font f;
public void init()
{
f=new Font("Arial",Font.BOLD,size);
1822 }
public void paint(Graphics g)
{
addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent me){
for(int i=0;i<=me.getClickCount();i++)
{
f=new Font("Arial",Font.BOLD,size+i);
repaint();
}
}
});
g.setFont(f);
g.drawString("Hello",100,100);
}

A. Hello is displayed and font size is increased by 2 on every click

B. Hello is displayed and font size is increased by 2 only once

C. Hello is displayed and font size is increased by 10 on every click

D. Hello is displayed and font size is increased by 2 only once

Answer optionc

Marks: 2

What will be the output of the following code:


import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*<applet code=MColor width=300 height=200>


</applet>*/
public class MColor extends Applet
{
int size=10,i=2;
Font f;
public void init()
1823 {
setForeground(Color.red);
}
public void paint(Graphics g)
{
addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent me){
setForeground(Color.green);
} });
f=new Font("Cambria", Font.PLAIN,20);
g.setFont(f);
g.drawString("Hello",100,100);
} }

A. Hello is displayed with initial red color and after clicking the color is changed to green

B. Hello is displayed with red color initial and after clicking

C. Hello is displayed with initial green color and after clicking the color is changed to red

D. Hello is displayed with greencolor initial and after clicking

Answer optiona

Marks: 2
Find Errors
import java.sql.*;
class Test{
public static void main(String ar[])throws Exception
{
String url="jdbc:odbc:mydsn";
1824 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers Loaded");
Connection c=DriverManager.getConnection(url);
ResultSet rs=st.executeQuery("Select * from student");
}
}

A. Statement object is not created

B. Drivers are loaded

C. Connection is created

D. Connection is not created

Answer optiona

Marks: 2

import java.io.*;
import javax.servlet.*;

public class H extends GenericServlet


{
public void service(ServletRequest req, ServletResponse res)throws ServletException, IOException
{
1825 res.setContentType("text/html");
PrintWriter pw = res.getWriter();
pw.println("<H1>Hello!!");
pw.close();

}
}

A. Hello message is displayed

B. No message is printed

C. Hello message is printed with H1 style

D. Error

Answer optionc

Marks: 2

Find Errors
import java.io.*;
import javax.servlet.*;

public class H extends GenericServlet


{
public void service(ServletRequest req, ServletResponse res)throws ServletException, IOException
1826 {
res.setContentType("text/html");
PrintWriter pw = res.GetWriter();
pw.println("<B>Hello!!");
pw.close();

}
}

No Error
A.

B. Hello message is printed

C. Error in res.SetContentType()

D. error in res.GetWriter()

Answer optiond

Marks: 2

1827 Which of the following is legal JSP syntax to print the value of k?

<%int k= 1;%>
A. <%= k; %>

<%int k = 1;
B. k; %>

<%int k = 1%>
C. <%= k %>

<%int k = 1;%>
D. <%= k %>
Answer optiond

Marks: 2

Predict the output


<html>
<head><title>A Comment Test</title></head>
<body>
1828 <p>
Today's date: <%=(new java.util.Date()).toLocaleString() %>
</p>
</body>
</html>

A. Today's date: 15-sep-2007 07:02:07

B. date: 15-sep-2007 07:02:07

C. Date: 15-sep-2007 07:02:07

D. Error

Answer optiona

Marks: 2

1829 Frame uses ________________ as default Layout

A. FlowLayout

GridLayout
B.

C. cardLayout

D. BorderLayout

Answer optiond

Marks: 1

1830 ___________ is a simple control which is used to display non editable text on the window

A. Label

B. textbox

C. textField

D. TextArea

Answer optiona

Marks: 1

1831 ____________ package needs to be imported if we use swing component classes in our program

A. java.swing

B. javax.swing

C. java.awt.swing

D. java.awt

Answer optionb

Marks: 1

1832 AWT is abbrivation for______________

A. Abstract Window Toolkit

B. Advanced Window ToolKit

C. Abstract window tools

D. None of the above

Answer optiona

Marks: 1

1833 _______________ method is used to set or change the text on Label


A. setText()

B. text()

C. SettleText()

D. EditText()

Answer optiona

Marks: 1

1834 AWT does not have ____________ control

A. Tree

B. table

C. tab

D. All of the above

Answer optiond

Marks: 1

1835 _______________ is used to change the current layout managers for a container?

A. setLayout()

B. ChangeLayout()

C. GetLayout()

D. setCurrentLayout()

Answer optiona

Marks: 1

1836 ______________________ events is generated when the a window is closed?

A. MyWindowEvent

B. WindowEvent

C. EventArgs

D. WindowClose

Answer optionb

Marks: 1

1837 ________________ method belongs to which event KeyEvent class?

A. getKeyChar( ) and getkeyCode( )

B. readNumber() and readChar()

C. readKey() and readChar()

D. getKey() and getCode()

Answer optiona

Marks: 1

1838 In order to handle button Events I have to implement______________interface

A. ActionListener

B. ActionTaken

C. ActionEvent

D. ActionManagement

Answer optiona

Marks: 1
1839 _________________ package contains classes and interfaces for networking

A. java.net

B. javax.net

C. java.network

D. java.socket

Answer optiona

Marks: 1

1840 The JDBC ( Java Database Connectivity) API defines _______________

A. interfaces and classes for writing database applications in Java by making database connections.

B. classes for GUI

C. Interfaces and classes for GUI

D. Programs for network Connectivity

Answer optiona

Marks: 1

1841 Using JDBC you can send SQL, PL/SQL statements ___________________

A. to almost any relational database.

B. to MySQL database

C. to MSAccess

D. to Oracle

Answer optiona

Marks: 1

1842 In the first step of the jdbc connection process, we load the driver class by calling _______________

A. Class.forName() with the Driver class name as an argument.

B. Class.forName() without the Driver class name as an argument

C. Driver.forName() without the Driver class name as an argument

D. Driver.Class.forName() without the Driver class name as an argument

Answer optiona

Marks: 1

1843 A Java Server Page is translated to ________________

A. servlet

B. application

C. applet

D. html file

Answer optiona

Marks: 1

1844 ___________________ is a small piece of information that is persisted between the multiple client requests.

A. cookie

B. servlet

C. jsp

D. textfile

Answer optiona
Marks: 1

1845 What is MIME?

A. Multipurpose internet Mail Extension

B. Multilevel internet Mail Extension

C. Multipurpose internet Multiple Extension

D. Multiple internet More Extension

Answer optiona

Marks: 1

1846 What is Advantage of JSP over Servlet ?

A. JSP is web page scripting language and servlets are Java programs

B. JSP is easy to write than servlet with full capabilities like servlet

C. JSP is in Java and Servlet is not

D. No Advantage

Answer optionb

Marks: 1

1847 The Jtable used to display data in form of?

A. rows and columns of data.

B. Linear form

C. hirerchical form

D. flexible data.

Answer optiona

Marks: 2

1848 Find out correct syntax of service() method of servlet class

A. void service(ServletRequest req, ServletResponse res)

B. int service(ServletRequest req, ServletResponse res)

C. float service(ServletRequest req, ServletResponse res)

D. char service(ServletRequest req, ServletResponse res)

Answer optiona

Marks: 2

1849 What are Advantage of Servlet over CGI ?

A. Performance of servlets is significantly better.

B. servlet is lightweight

C. Servlet is more powerful

D. No Advantage

Answer optiona

Marks: 2

1850 Advantages of Cookies are ____________

A. A. It is used to maintain the state information.

B. B. Cookies are maintained at client side.

C. D.Cookies are maintained at server side.

D. Both A and B are correct


Answer optiond

Marks: 1

Consider following program and find the missing statement in the code
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
/* <applet code=exp1.class width=200 height=200> </applet> */
public class exp1 extends Applet
1851 {
public void init() {
add(new Button("BOTTOM"),BorderLayout.SOUTH);
add(new Button("RIGHT"),BorderLayout.EAST);
add(new Button("LEFT"),BorderLayout.WEST);
}
}

A. setLayout(new BorderLayout());

B. setLayout(new GridLayout());

C. setLayout(new cardLayout());

D. None of the above

Answer optiona

Marks: 2

Which of the following methods can be used to change the size of a java.awt.Component object?
(A) resize()
(B) setSize()
1852 (C) area()
(D) size()
(E) dimension()

A. A and B

B. B and E

C. C and D

D. A and C

Answer optiona

Marks: 2

1853 ButtonGroup bg = new ButtonGroup(); is used to create group of

A. RadioButton

B. Checkbox

C. button

D. None of the above

Answer optiona

Marks: 2

Consider following code and state how many keyevent generated by this program
import java.awt.event.*;
import javax.swing.*;
/* <applet code="KeyDemo.class " width=300 height=300> </applet> */
public class KeyDemo extends JApplet implements KeyListener
{
String msg="";
int x=10,y=20;
public void init()
{
addKeyListener(this);
requestFocus();
}
public void keyPressed(KeyEvent ke)
{
showStatus("Key Down");
1854
}
public void keyTyped(KeyEvent ke)
{
msg+=ke.getKeyChar();
repaint();
}
public void keyReleased(KeyEvent ke)
{
showStatus("Key up");
}
public void paint(Graphics g)
{
g.drawString(msg,x,y);
}
}
A. 4

B. 3

C. 2

D. 1

Answer optionb

Marks: 2

1855 Calling ServerSocket() constructor with port value 'zero' means______________________.

A. use a port number that is automatically allocated.

B. Don't assign PORT

C. No Port required

D. None of the above

Answer optiona

Marks: 2

1856 All the ___________ data is kept at the application server ___________ data is kept at the web server?

A. dynamic, static

B. Local , Server

C. Small , Large

D. Large , Small

Answer optiona

Marks: 2

Arrange the steps in correct order to run JSP Program


open text editor and type JSP program and store in same directory given above
1857 Open text editor type html program save it witn .html extension
Save .html file in tomcat\webapps\ebanking

1. Open text editor type html program save it witn .html extension
A. 2. Save .html file in tomcat\webapps\ebanking
3. open text editor and type JSP program and store in same directory given above

1. open text editor and type JSP program and store in same directory given above
B. 2. Open text editor type html program save it witn .html extension
3. Save .html file in tomcat\webapps\ebanking

1. open text editor and type JSP program and store in same directory given above
C. 2. Save .html file in tomcat\webapps\ebanking 3. Open text editor type html program save it witn .html extension

D. None of the above

Answer optiona

Marks: 2

Choose missing statements in following code from given options.


public class session1 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{ HttpSession hs = request.getSession(true);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
1858 if(date != null)
{ pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. missing package statement

B. missing system.out.println()

C. missing main() function

D. Everything is ok

Answer optiona
Marks: 2

1859 AdjustmentEvent class defines the integer constants that are

A. BLOCK_DECREMENT

B. BLOCK_INCREMENT

C. UNIT_INCREMENT

D. ALL THE ABOVE

Answer optiond

Marks: 1

1860 ___________________method is used to retrieve the host name associated with URL.

A. getHost()

B. getHostName()

C. getName()

D. getURL()

Answer optiona

Marks: 1

1861 What does a DriverManager class do?

A. It manages the JDBC drivers that are installed on the system

B. It Loads Driver

C. It connects to database Table

D. It connects to MySQL

Answer optiona

Marks: 1

1862 All java classes are derived from

A. javax.object

B. java.object

C. java.lang.Object

D. java.lang

Answer optionc

Marks: 2

1863 A menu bar represents

A. A list of menus which can be added to the top of a top-level window

B. Just a simle list

C. A list that can be added anywhere

D. None of the above

Answer optiona

Marks: 2

1864 To establish connection with database which method of DriverManager class is used?

A. getConnection()

B. getSQLConnection()

C. getQueryConnection()

D. getMyConnection()
Answer optiona

Marks: 2

1865 To execute a stored procedure "totalStock" in a database server, which of the following code is used?

A. CallableStatement clbstmnt = con.prepareCall("{call totalStock}");

B. CallableStatement clbstmnt = con.preparedCall("{call totalStock}");

C. CallableStatement clbstmnt = con.preparedStatement("{call totalStock}");

D. None of the above

Answer optiona

Marks: 2

What is output of following program


import java.net.*;
public class InetAddressExample
{
public static void main(String arg[])
{
try
{
1866 InetAddress ad=InetAddress.getByName("LocalHost");
System.out.println("CTE:"+ad);
System.out.println("CTE:"+ad.getHostAddress());
System.out.println("CTE:"+ad.getHostName());
}
catch(UnknownHostException e) {}
}
}

A. Gives default IP address and host name as LocalHost

B. Gives 100.0.0.1 IP address and host name as LocalHost

C. Gives 192.168.0.0 IP address and any name as LocalHost

D. None of the above

Answer optiona

Marks: 2

Write which method is used for following program execution in blank space:
import java.sql.*;
class exp11_1
{
public static void main(String arg[])
{
Class.forName("sun.jdbc.odbc,JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:dsnname");
1867 PreparedStatement cmd=con.prepareStatement("select * from emp");
ResultSet rs= cmd.______________________();
while(rs.next())
{ System.out.println(rs.getInt(1)+" "+ rs.getString(2) rs.getString(3)+" "+rs.getInt(4));
}
cmd.close(); con.close();
}
}

A. executeQuery()

B. executeQry()

C. executeSQL()

D. executeMyQuery()

Answer optiona

Marks: 2

1868 ___________Calls get converted into native c or c++ API calls

A. JDBC API

B. javax.swing

C. java.awt

D. java events

Answer optiona

Marks: 2

1869 Which statements are needed to establish connection to database?


1) Register the driver class
2) Create the connection object
A. 3) Create the Statement object
4) Execute the query
5) Close the connection object

1) Register the driver class


2) Create the connection object
B. 3) Create the Statement object
4) Execute the query

1) Register the driver class


2) Create the connection object
C. 3) Create the Statement object
4) Close the connection object

1) Register the driver class


D. 2) Create the connection object
3) Close the connection object

Answer optiona

Marks: 2

1870 What are the valid parts of URL?

A. Socket Name

B. Host Name

C. Port Number

D. All of the Above

Answer optiona

Marks: 1

1871 What is invoked via HTTP on the Web server computer when it responds to requests from a user's Web browser?

A. Java Application

B. Java Applet

C. Java Servlet

D. None of the Above

Answer optionc

Marks: 1

what will be output of this program?


class Fr
{
public static void main(String ar[])
1872 {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

A. closes frame

B. disposes frame

C. hide frame

D. do nothing

Answer optiona

Marks: 2

select missing statement


import java.net.*;
class networking {
______________________________________________
1873 {
InetAddress add=InetAddress.getByName("google.com");
System.out.print(add.getHostName());
}
}

A. public static void main(String[] args) throws MalformedURLException

B. public static void main(String[] args) throws UnknownHostURLException

C. public static void main(String[] args) throws UnknownHostException


D. public static void main() throws UnknownHostException

Answer optionc

Marks: 2

1874 Frame has a ________________________________

A. Panel,Radiobutton,button.

B. Menubar,titlebar,borders.

C. Title bar,borders,resixing corners

D. Resizing corners,borders,checkbox

Answer optionc

Marks: 1

1875 All Component on Container can be removed by calling following method

A. Remove ()

B. Remove all ()

C. Add ()

D. Add all ()

Answer optionb

Marks: 1

1876 Current aligment of label can be obtained using ___________________.

A. Set Aligement ()

B. getAlignment ()

C. get text ()

D. set text ()

Answer optionb

Marks: 1

1877 The name of listener used for Checkbox is __________________.

A. ItemListener

B. AdjustmentListener

C. ActionListener

D. Mouse Motion Listener

Answer optiona

Marks: 1

1878 ___________________________ component may have different size rows may have different number of columns.

A. Grid Bag Layout

B. Border Layout

C. Flow Layout

D. Card Layout

Answer optiona

Marks: 1

1879 proxy server is a sever that is a mediator between real __________ and a client application like web browser

A. web client

B. web browser
C. web server

D. server socket

Answer optionc

Marks: 1

1880 TCP/IP uses or reserves the lower __________________ ports for specific protocols

A. 1032

B. 1011

C. 1024

D. 1029

Answer optionc

Marks: 1

1881 In the three tier model the middle tier of the services acts as a mediator between ________________________ and _________________.

A. Java applet and DBMS

B. user and data source

C. Data source and Application server

D. DBMS and user

Answer optionb

Marks: 1

1882 The ______________interface is mainly used to execute queries asked to database .

A. Database Metadata

B. prepared statement

C. statement

D. Result set

Answer optionc

Marks: 1

1883 ______________type JDBC API calles gets converted into native C or C++ API calls

A. JDBC-ODBC Bridge Driver

B. JDBC-Native API

C. JDBC-ODBC Native API

D. JDBC-ODBC %100 Native

Answer optionb

Marks: 1

1884 The focusEvent can be recognized by two integer constant.

A. Focus-Gained and Focus-Lost

B. Focus-lost and Focus-State

C. Focus-State and Focus-entry

D. Focus-Item and Focus-State

Answer optiona

Marks: 2

1885 The main difference between Generic Servlet and HTTP servlet is

A. Generic servlet is platform independent & HTTP servlet is platform dependent


B. Generic servlet is protocol platform independent & HTTP servlet having built in HTTP protocol support

C. Generic servlet is more suitable for sun Java System web server envoirnment & HTTP servlet is not more suitable for sun java System web Server envoirnment

D. Generic servlet uses doget(), dopost() method and HTTP Servlet uses service() method

Answer optionb

Marks: 2

Consider following program and find the missing statement in the code
import java.awt.event.*;
import java.awt.*;
import java.applet.*;

/*
<applet code=exp1.class width=200 height=200>
</applet>
*/

1886 public class exp1 extends Applet


{
public void init()
{

add(new Button("TOP"),BorderLayout.NORTH);
add(new Button("BOTTOM"),BorderLayout.SOUTH);
add(new Button("RIGHT"),BorderLayout.EAST);
add(new Button("LEFT"),BorderLayout.WEST);
}
}

A. setLayout(new BorderLayout());

B. setLayout(new GridLayout());

C. setLayout(new FlowLayout());

D. setLayout(new GridbagLayout());

Answer optiona

Marks: 2

Consider following program and state how meny main menu and sub menu displayed in output:
import java.awt.*;
public class MenuDemo
{
public static void main(String args[])
{
Frame f=new Frame("My Frame");
f.setVisible(true);
MenuBar mbr= new MenuBar();
f.setMenuBar(mbr);
Menu filemenu=new Menu("File");
Menu editmenu=new Menu("Edit");
1887 Menu viewmenu=new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
mbr.add(viewmenu);
MenuItem new1=new MenuItem("New");
MenuItem open1=new MenuItem("Open");
filemenu.add(new1);
filemenu.add(open1);
new1.setEnabled(false);
CheckboxMenuItem wordwrap=new CheckboxMenuItem("WordWrap");
editmenu.add(wordwrap);
}

A. 3 Main,3 Sub menu

B. 3 Main,2 Sub menu

C. 3 Main,1 Sub menu

D. 2 Main,3 Sub menu

Answer optiona

Marks: 2
Find out missing statement in following code:
import java.awt.*;
import java.applet.*;
/*
<applet code=exp4.class width=200 height=200>
</applet>
*/
public class exp4 extends Applet
{
List l1,l2;

public void init()


{
1888 l1=new List(4);
l2=new List(4,true);

l1.add("abc");
l1.add("def");
l1.add("ghi");
l1.add("lmk");

l2.add("1");
l2.add("2");
l2.add("3");
l2.add("4");
}
}

add(l1);
A. add(l2);

B. add(l3)

C. add(l4);

D. add(l1);

Answer optiona

Marks: 2

Following program output display which type of layout manager :


import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*
<applet code=cl.class width=200 height=200>
</applet>
*/

public class cl extends Applet


{
CardLayout cardLayout;

Panel panel;

Button button1, button2, button3;

public void init()

panel = new Panel();

1889 add(panel);

cardLayout = new CardLayout(0,0);

panel.setLayout(cardLayout);

button1 = new Button("Button1");

button2 = new Button("Button2");

button3 = new Button("Button3");

panel.add("Button1", button1);

panel.add("Button2", button2);

panel.add("Button3", button3);

A. BorderLayout

B. CardLayout

C. FlowLayout

D. GridBagLayout

Answer optionb
Marks: 2

Which import statement is used for following program.


/*
<applet code=exp1.class width=200 height=200>
</applet>
*/

public class exp1 extends Applet


{
1890 public void init()
{
setLayout(new BorderLayout());
add(new Button("TOP"),BorderLayout.NORTH);
add(new Button("BOTTOM"),BorderLayout.SOUTH);
add(new Button("RIGHT"),BorderLayout.EAST);
add(new Button("LEFT"),BorderLayout.WEST);
}
}

A. import java.Japplet.*;

import java.awt.event.*;
B. import java.awt.*;
import java.applet.*;

C. import java.applet.*;

D. import java.awt.event.*;

Answer optionb

Marks: 2

Which statement is missing in following code :


import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.awt.event.*;
/*
<applet code="Square" width=300 height=300>
</applet>
*/
public class Square extends Applet implements ActionListener
{
Button b1;
Label l1,l2;
TextField t1,t2;
public void init()
{

l1=new Label("Enter the number");


l2=new Label("Square of number");
1891 t1=new TextField();
t2=new TextField();
b1=new Button("Square");
setLayout(new GridLayout(3,2));
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);

}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{ float a=Float.parseFloat(t1.getText());
float c=a*a;
t2.setText(Float.toString(c));
}
}
}

A. b1.addActionListener(this);

B. l1.addActionListener(this);

C. t21.addActionListener(this);

D. t1.addActionListener(this);

Answer optiona

Marks: 2
How many component is used in following program :-
import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.awt.event.*;
/*
<applet code="Square" width=300 height=300>
</applet>
*/
public class Square extends Applet implements ActionListener
{
Button b1;
Label l1,l2;
TextField t1,t2;
public void init()
{
1892
l1=new Label("Enter the number");
l2=new Label("Square of number");
t1=new TextField();
t2=new TextField();
b1=new Button("Square");
setLayout(new GridLayout(3,2));
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);

b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{

A. 5

B. 6

C. 7

D. 2

Answer optiona

Marks: 2

Consider following program and state which command is used to run following code:
import java.net.*;
class urldemo
{
public static void main(String args[]) throws MalformedURLException
{
URL netaddress= new URL("htp://www.msbte.com/java_technology_tutorials.htm");
1893
System.out.println("Protocol " + netaddress.getProtocol());
System.out.println("Port " + netaddress.getPort());
System.out.println("Host " + netaddress.getHost());
System.out.println("file " + netaddress.getFile());
}
}

C:\java>javac urldemo.java
A. C:\java>java urldemo1

C:\java>javac urldemo.java
B. C:\java>java urldemo

C:\java>javac urldemo.java
C. C:\java> urldemo

C:\java>javac urldemo.java
D. C:\java>appletviewer urldemo

Answer optionb

Marks: 2

Consider following code of servlet and find out missing method in the program
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Mathservlet extends HttpServlet


{

public void ______ (HttpServletRequest request, HttpServletResponse


response) throws ServletException, IOException
{
response.setContentType("text/html");
1894 PrintWriter out = response.getWriter();
out.println("<html><h1>Table Example</h1>");
out.println("<table border = 1>");
out.println("<tr><td> Number </td> <td> Result <td></tr>");
for(int i=1;1<10;i++)
{
out.println("<tr><td>"+ i + "\t" + Math.pow(2,i) + "<td><tr>");
}
out.println("</table></html>");
printwriter.close();
}
}

A. doGet()
B.

C. destroy()

D. init()

Answer optiona

Marks: 2

Which import statement required for following program.


public class servlet extends GenericServlet
{

public void service(ServletRequest request, ServletResponse


response) throws ServletException, IOException
1895 {
response.setContentType("text/html");
PrintWriter printwriter = response.getWriter();
printwriter.println("<B>Hello from Java!</B>");
printwriter.close();
}
}

A. import java.io.*;
import javax.string.*;

import java.io.*;
B. import java.Japplet.*;

import java.io.*;
C. import javax.servlet.*;

import java.io.*;
D. import java.applet.*;

Answer optionc

Marks: 2

Find out the error in the following code.


public class servlet extends HTTPServlet
{

public void service(ServletRequest request, ServletResponse


response) throws ServletException, IOException
1896 {
response.setContentType("text/html");
PrintWriter printwriter = response.getWriter();
printwriter.println("<B>Hello from Java!</B>");
printwriter.close();
}
}

A. Mismatch servlet

B. Missing semicolon

C. Missing brackets

D. Missing statement

Answer optiona

Marks: 2

1897 Which of these classes can be added to a Frame component ?

A. FrameContainer

B. Button

C. Window

D. Applet

Answer optionb

Marks: 1

1898 ______________________________method is used to add a tab to the pane.

A. addTab ()

B. add pane ()

C. append ()

D. add ()
Answer optiona

Marks: 1

1899 Which of the following method executes only once

A. start

B. init

C. stop

D. destroy

Answer optionb

Marks: 1

1900 Which event class can be used for scrollbar

A. AdjustmentEvent

B. ComponentEvent

C. FocusEvent

D. InputEvent

Answer optiona

Marks: 1

1901 How many components are used for form validation i.e input username and password

A. 2 Label,2 Button,2 List

B. 2 Label,2 Button,2 TextField

C. 2 Label,1 Button,2 Textfield

D. 2 Label,2 Button,5 Textfield

Answer optionc

Marks: 2

1902 URL Connection is class used for_____________________.

A. Accessing the date and time on remote server.

B. Accessing the file on remote server.

C. Accessing the server name.

D. Accessing the attributes of a remote resource.

Answer optiond

Marks: 2

1903 The Statement interface is mainly used to_______________

A. Used to execution of select query

B. Used to execute batch of sql Commands

C. To execute queries asked to database

D. Used to execute sql Commands

Answer optionc

Marks: 2

1904 PreparedStatement interface creates an object that represents a________________

A. Compiled SQL Statement

B. Precompiled SQL Statement

C. Select SQL Statement


D. Insert SQL Statement

Answer optionb

Marks: 2

1905 The correct sequence of JSP life Cycle is

A. init(), Service(), destroy()

B. init(), add(), destroy()

C. init(), addall(), destroy()

D. service(), init(), destroy()

Answer optiona

Marks: 2

1906 Which of the following statements is for placing the frame's upper left corner to (200,100)?

A. frame.setLocation(100,100)

B. frame.setLocation(100,200)

C. frame.setLocation(200,100)

D. frame.setLocation(200,200)

Answer optionc

Marks: 1

1907 The default layout of a Jpanel is

A. FlowLayout

B. GridLayout

C. BorderLayout

D. None

Answer optionc

Marks: 1

1908 You can use methods_______________ on any istanceof java.awt.component

A. setBackground

B. getBackground

C. getBorder

D. getHeight

Answer optiona

Marks: 1

1909 Can you use the setToolTip method to set a tool tip for _____________?

A. Jlable

B. Container

C. Jcomponent

D. Jbutton

Answer optionc

Marks: 1

1910 Which of the following statements are true?

A. To distinguish new Swing component classes form their AWT counterparts, Swing GUI component classes are named with a prefix J.

B. All Swing GUI components are lightweight.


C. A user interface object such as (button, list) can appear in one container

D. A container such as Jframe is also a component.

Answer optionc

Marks: 1

1911 The method______________ sets the font (Helvetica, 20-point bold) in component C.

A. c.setFont(new Font("Helvetica", Font.bold, 20))

B. c.setFont(new Font("helvetica", BOLD, 20))

C. c.setFont(Font("Helvetica", Font.BOLD, 20))

D. c.setFont(new Font("Helvetica", Font.BOLD, 20))

Answer optiond

Marks: 1

1912 The method______________ sets the foreground color to yellow in Jframe f.

A. setForeground(color.yellow)

B. f.setForeground(Color.yellow)

C. f.setForeground(color.yellow)

D. setForeground(color.YELLOW)

Answer optionb

Marks: 1

1913 Which of the following is true

A. Jbutton inherits from javax.swing.AbstractButton.

B. You can create a Jbutton by specifying an icon and text

C. You can create a Jbutton by specifying an icon.

D. You can create a Jbutton by a text.

Answer optionb

Marks: 1

1914 ____________defines methods that give access to the wheel event.

A. MouseEvent

B. MouseWheelEvent

C. MouseMotionEvent

D. None of the mentioned.

Answer optionb

Marks: 1

1915 Which of these methods can be used to obtained the reference to the container that generated a ContianerEvent

A. getContianer()

B. getContainerCommand()

C. getActionEvent()

D. getContainer()

Answer optiond

Marks: 1

1916 Which of these methods can be used to know which key is pressed?

A. getKey()
B. getModifier()

C. getActionKey()

D. getActionEvent()

Answer optionb

Marks: 1

1917 Policy object can be installed by calling the ________ method

A. setPolicy()

B. getPolicy()

C. control()

D. connect()

Answer optiona

Marks: 1

1918 How many ports of TCP/IP are reserved for specific protocols?

A. 10

B. 1024

C. 2048

D. 512

Answer optionb

Marks: 1

1919 How to get the object of URLConnection class

A. public URLConnection openConnection()throws IOException{}

B. public URL getConnection()throws IOException{}

C. public URL openConnection()throws IOException{}

D. public InetAddress openConnection()throws IOException{}

Answer optiona

Marks: 1

1920 To connect a server running on the same machine with the client, which of the following can be used for the hostname?

A. "localhost"

B. "127.0.0.1"

C. InetAddress.getLocalHost()

D. "127.127.127.1"

Answer optionc

Marks: 1

1921 The JDBC-ODBC Bridge driver translate the JDBC API to the ODBC API and used with _______________

A. JDBC drivers

B. ODBC drivers

C. Both A and B

D. None of the above

Answer optionb

Marks: 1

1922 MS-SQL stores data in a ________________ file format.


A. .MDF

B. .MDB

C. .MSSQL

D. .OBJ

Answer optiona

Marks: 1

1923 The _____________ object provides you with methods to access data from the table.

A. ResultSet

B. Parametrized

C. TableStatement

D. Condition

Answer optiona

Marks: 1

1924 JSP includes a mechnism for defining ____________ or custom tags.

A. static attributes

B. local attributes

C. dynamic attributes

D. global attributes

Answer optionc

Marks: 1

Analyze the followng code.


import java.awt.*; import javax.swing.*; public class Test{ public static void main(String[] args){ Component c = new JButton("OK"):
1925 JFrame frame = new JFrame("My Frame"); frame.add(c); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(c);
frame.setVisible(true);} }

A. You cannot assign a Jbutton to a variable of java.awt.component

B. You can only add c to a container because c's type is component

C. You can not add a Swing component directly to a Jframe using add© prior to JDK 1.4, but it is OK in JDK 1.5.

D. You can not create a Jframe using new Jframe("My Frame")

Answer optionc

Marks: 2

Analyze the followng code.


import java.awt.*;
import javax.swing.*;
public class Test extends JFrame
{ public Test()
{ setLayout(new FlowLayout());
1926 add( new JButton("Java"));
add( new JButton("Java"));
add( new JButton("Java")); add( new JButton("Java")); }
public static void main(String[] args)
{ JFrame frame = new Test();
frame.setSize(200,100); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true); } }

A. one button is displayed with the text"Java"

B. Two buttons are displayed with the same text "Java"

C. Three buttons are displayed with the same text "Java"

D. Four buttons are displayed with the same text "Java"

Answer optiond

Marks: 2

1927 The method ______________ creates a Icon Image for file c:\image\us.gif

A. new Image("c:\image\us.gif");
B. new Icon("c:\image\us.gif");

C. new ImageIcon("c:\\image\\us.gif");

D. new IconImage("c:\\image\\us.gif");

Answer optionc

Marks: 2

1928 Which of these constant value will change when the button at the end of scroll bar was clicked to increase its value?

A. BLOCK_DECREMENT

B. BLOCK_INCREMENT

C. UNIT_DECREMENT

D. UNIT_INCREMENT

Answer optiond

Marks: 2

1929 ______________ mehtod can be used to determine the type of adjustment event.

A. getType()

B. getEventType()

C. getAdjustmentType()

D. getEventObjectType()

Answer optionc

Marks: 2

1930 Class which allows us to get real time data about private and protected member of a class is____________________

A. java.security

B. java.lang.security

C. java.awt.image

D. java.io.security

Answer optiona

Marks: 2

1931 To create an Input Stream on a socket s, you use__________________________

A. InputStream in = new Input(s);

B. InputStream in = s.getInputStream();

C. InputStream in = s.ObtainInputStream();

D. InputStream in = s.getStream();

Answer optionb

Marks: 2

1932 The ______________ method executes an SQL statement that may return multiple results.

A. executeUpdate()

B. executeQuery()

C. execute()

D. noexecute()

Answer optionb

Marks: 2

1933 The ______________ method sets the query parameters of the PreparedStatement object.
A. putString()

B. insertString()

C. setString()

D. setToString()

Answer optionc

Marks: 2

ServletContext is 1. an Interface 2.A container which is used to store an object so that it is available for whole application
1934 3.A container which is used to store an object so that it is available for session only. 4.A container which is used to store an
object so that it is available for request only.

A. 1,2,3,4

B. 1,2

C. 1,3,4

D. 4

Answer optionb

Marks: 2

Analyze the followng code.


import javax.swing.*; public class Test extends JFrame { privateJButtonjbtOK = new JButton ("OK"); public static void
1935 main(String[] args) { JFrame frame = new Test(); frame.setTitle("Logic Error"); frame.setSize(200,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public Test() { jbtOK.setTootTipText("This is a
button"); add(new JButton("OK")); } }

A. The tool tip text is displayed when you move the mouse on the button

B. The tool tip text will be displayed if you replace add(new Jbutton("OK)

C. The tool tip text will be dispalyed if you swap the wo lines in the Test constructor.

D. The tool tip text will be dispalyed if you repplace add(jbtOK = new Jbutton(OK));

Answer optionb

Marks: 2

1936 The method_____________ gets the text of the label jlbl.

A. jlbl.text()

B. jlbl.getText()

C. jlbl.findText()

D. jlbl.retrieveText()

Answer optionb

Marks: 2

1937 ____________ creates a color object.

A. new color(0,0,0)

B. new color(0,266,0)

C. new Color(255,255,255)

D. new color(1,2,3)

Answer optionc

Marks: 2

1938 Which of these methods will invoked if a character is entered?

A. keyPressed()

B. keyReleased()

C. keyTyped()

D. keyEntered()
Answer optionc

Marks: 2

1939 The amount of the adjustment can be obtained from the following method?

A. getValue()

B. getAdjustmentType()

C. getAdjustmentValue()

D. getAdustmentAmount()

Answer optiona

Marks: 2

1940 Which of these are integer constants defined in Action Event class?

A. ALT_MASK

B. CTRL_MASK

C. SHIFT_MASK

D. All of the above

Answer optiond

Marks: 2

1941 The _______object allows you to execute parametrized queries.

A. ResultSet

B. parametrized

C. PreparedStatement

D. Condition

Answer optionc

Marks: 2

1942 Which of the following are the session tracking techniques

A. URL rewriting, using servlet object, using response object, using cookies

B. URL rewriting, using session object, using cookies, using hidden fields

C. URL rewriting, using request object, using response object, using session object

D. URL rewriting, using session object, using response object, using hidden fields

Answer optionb

Marks: 2

1943 The deployment descriptor describes

A. Web component request and response

B. Web component request settings

C. Web component setting

D. Web component response settings

Answer optionc

Marks: 2

1944 Generic servlet is

A. Protocol Independent

B. protocol dependent

C. protocol based
D. None of the above

Answer optiona

Marks: 2

1945 Which of the following methods can be used to remove java.awt.component object from display

A. hide()

B. dissapear()

C. remove()

D. delete()

Answer optionc

Marks: 1

1946 To use the swing components_______________package is imported

A. java.swing

B. javax.swing

C. javaj.swing

D. javas.swing

Answer optionb

Marks: 1

1947 In Swing , the content pane can be obtained via method __________________

A. addContentPane()

B. setContentPane()

C. getContentPane()

D. None of the above

Answer optionc

Marks: 1

1948 Which of these events is generated when a button is pressed?

A. ActionEvent

B. KeyEvent

C. WindowEvent

D. AdjustmentEvent

Answer optiona

Marks: 1

1949 Which of these methods are used to register a keyboard event listener?

A. KeyListener()

B. addListener()

C. addKeyListener()

D. eventkeyListener()

Answer optionc

Marks: 1

1950 The ___________________method executes an SQL statement that may return multiple results.

A. executeUpdate()

B. executeQuery()
C. execute()

D. noexecute()

Answer optionc

Marks: 1

1951 The __________________object allows you to execute parameterized queries.

A. setString()

B. settoString()

C. toString()

D. insertString()

Answer optiona

Marks: 1

1952 To add a component c to a Jpanel p,use____________

A. p.add ( c)

B. p.getContentPane( c )

C. p.insert( c )

D. p.append( c )

Answer optiona

Marks: 2

1953 Which of these class is used to create servers that listen for either local or remote client program?

A. httpServer

B. ServerSocket

C. HttpResponse

D. MimeHeader

Answer optionb

Marks: 2

Which of the following describes the correct sequence of the steps involved in making a connection with a database.1Loading the
1954 driver 2.Process the results 3.Making the connection with the database 4.Executing the SQL statements.

A. 1,3,4,2

B. 1,2,3,4

C. 2,1,3,4

D. 4,1,2,3

Answer optiona

Marks: 2

1955 A Java program cannot directly communicate with an ODBC driver because__________

A. ODBC written in C language

B. ODBC written in C# language

C. ODBC written in C++ language

D. ODBC written in Basic language

Answer optiona

Marks: 2

Java Servelet i)Is a key component of server side Java Development ii)is a small pluggable extension to a server that enhances
1956 functionality iii)runs only in Windows Operating System iv)allows developers to customize any java enabled server

A. i, ii & iii are ture


B. i, iii & iv are true

C. ii, iii & iv are true

D. i, ii & iv are true

Answer optionc

Marks: 2

1957 Suppose a Jframe uses the GridLayout(2,0).If you add six buttons to the frame,how many columns are displayed?

A. 1

B. 2

C. 3

D. 4

Answer optionc

Marks: 2

1958 Which of the follwing statements is for placing the frame's upper left corner to (200,100)?

A. frame.setLocation(100,100)

B. frame.setLocation(100,200)

C. frame.setLocation(200,100)

D. frame.setLocation(200,200)

Answer optionc

Marks: 2

1959 Choose the correct sequence for the following output

importjava.awt.*;
importjava.applet.*;
public class app1 extends Applet
{
public void init()
{
Textfieldtf = new TextField();
TextArea t1=new TextArea(3,20);
Checkbox c=new CheckboxGroup("a",true);
A. Checkbox c1=new Checkbox("b",false);
add(t1);
add(c);
add(tf);
add(c1);
}
}
/*<applet code=app1.class width=200 height=200>
</applet>*/

importjava.awt.*;
importjava.applet.*;
public class app1 extends Applet
{
public void init()
{
TextField tf = new TextField();
TextArea t1=new TextArea(3,20);
Checkbox c=new Checkbox("a",true);
B. Checkbox c1=new Checkbox("b",false);
add(tf);
add(t1);
add(c);
add(c1);
}
}
/*<applet code=app1.class width=200 height=200>
</applet>*/

importjava.awt.*;
importjava.applet.*;
public class app1 extends Applet
{
public void init()
{
TextField tf = new TextField();
TextArea t1=new TextField();
C. Checkbox c=new Checkbox("a",true);
Checkbox c1=new Checkbox("b",false);
add(tf);
add(t1);
add(c);
add(c1);
}
}
D. All of above

Answer optionb

Marks: 2

1960 To create an image icon for a file in c:\book\image\icon,use__________

A. new ImageIcon("c:\book\image\icon");

B. new ImageIcon('c:\book\image\icon');

C. new ImageIcon("c:\\book\\image\\icon");

D. new ImageIcon('c:\\book\\image\\icon');

Answer optionc

Marks: 2

For the following code select the method that can be used to handle event.
importjava.awt.event.*;
import java.awt.*;
importjava.applet.*;
public class checkbackg extends Applet implements ItemListener
{
Checkbox m1,m2,m3;
public void init()
{
m1=new Checkbox("A");
m2=new Checkbox("B");
m3=new Checkbox("C");
add(m1);
add(m2);
1961 add(m3);
m1.addItemListener(this);
m2.addItemListener(this);
}

public void __________________(ItemEvent ie)


{
if(ie.getSource()==m1)
setBackground(Color.red);
if(ie.getSource()==m2)
setBackground(Color.green);
}
}
/*<applet code=checkbackg.class height=150 width=150>
</applet>*/

A. actionPerformed(ActionEvent ae)

B. itemStateChanged(ActionEvent ie)

C. itemStateChanged(ItemEvent ie)

D. adjustmentPerformed(AdjustmentEvent ae)

Answer optionc

Marks: 2

1962 Which of these methods can be used to determine the type of adjustment event?

A. getType()

B. getEventType()

C. getAdjustmentType()

D. getEventObjectType()

Answer optiona

Marks: 2

Consider the following program


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
1963 {
URL url = new URL("http://www.msbte.com/download");
System.out.println("Protocol:"+ url1.getProtocol());
System.out.println("Port:"+ url1.getPort());
System.out.println("Host:"+ url1.getHost());
System.out.println("File:"+ url1.getFile());
}
}

A. Exception type is wrong.


B. Class should not be public.

C. Creation of object is not correct.

D. Use of created object not correct

Answer optiond

Marks: 2

1964 Which method returns the current result in multiple result statements?

A. getUpdateCount()

B. getUpdate()

C. getCount()

D. getUpCount()

Answer optiona

Marks: 2

1965 ______moves the cursor to the specified row

A. public boolean absolute(int row)

B. public boolean relative(int row)

C. public boolean getRow(int row)

D. public void currentRow()

Answer optiona

Marks: 2

Choose missing statements in following code from given options.

public class session1 extends HttpServlet


{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
HttpSession hs = request.getSession(true);
response.setContentType("text/html");
1966 PrintWriter pw = response.getWriter();
pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*;

B. import java.Vector.* ; import java.Thread.*; import javax.servlet.*;

C. import javax.servlet.http.*; import java.String.*; import java.Vector;

D. import javax.servlet.http.*; import java.Thread.*; import javax.Client.*;

Answer optiona

Marks: 2

What should we write at the place of _____________to get the proper output.
import java.io.*;
import javax.servlet.*;
public class GenericServletDemo extends GenericServlet
{
public void service(ServletRequest request ,____________ response) throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<HTML>");
1967 out.println("<HEAD><TITLE>hello page</TITLE></HEAD>");
out.println("<BODY>");
String name=(String) request.getParameter("user1");
String password=(String) request.getParameter("password1");
String phone=(String) request.getParameter("phone1");
out.println("Name="+name+"<br>");
out.println("Passsword="+password+"<br>");
out.println("Phone="+phone+"<br>");
out.println("</BODY></HTML>");
}
}
A. HttpRequest

B. ServletResponse

C. HttpResponse

D. none of the above

Answer optionb

Marks: 2

1968 Which of the following class defines accept() method?

A. Socket

B. URL

C. ServerSocket

D. URLConnection

Answer optionc

Marks: 1

1969 How does Tomcat execute a JSP?

A. As a CGI Script

B. As an independent process

C. By one of Tomcat's thread

D. None of the above

Answer optionc

Marks: 1

1970 Which constructor is used to create ServerSocket connected to port no 1254 and maxq length as 20.

A. ServerSocket(1254)

B. ServerSocket(1254,20)

C. ServerSockect(20)

D. None of the above

Answer optionb

Marks: 2

1971 Which of the following is true when a client requests connection to a server that has not yet started?

A. java.net.BindException occurs

B. java.net.ConnectionException occurs

C. the client is blocked until the server is started

D. the client encounters a fatal error and must be terminated

Answer optionb

Marks: 2

1972 Which object allows you to create parameterized queries?

A. ResultSet

B. PreparedStatement

C. Statement

D. Condition

Answer optionb

Marks: 2
1973 In setXXX() methods used for PreparedStatement the first argument specifies which value?

A. index of column

B. index of row

C. index of Question mark

D. index of Resultset

Answer optionc

Marks: 2

import java.sql.*;
class InsertPrepared{
public static void main(String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");

PreparedStatement stmt=con.prepareStatement("insert into Emp values(?,?)");


stmt.setInt(1,101);//1 specifies the first parameter in the query
1974 stmt.setString(2,"Ratan");

int i=stmt.executeUpdate();
System.out.println(i+" records inserted");

con.close();

}catch(Exception e){ System.out.println(e);}

}
}

A. error

B. 101 is inserted at first index position and Ratan is inserted at second index position into Emp

C. both a and b

D. None of the above

Answer optionb

Marks: 2

1975 Which is a component in AWT that can contain another components like buttons, textfields, labels etc.?

A. Window

B. Container

C. Panel

D. Frame

Answer optionb

Marks: 1

1976 In which places can put the event handling code

A. Same class

B. Other class

C. Annonymous class

D. All mentioned above

Answer optiond

Marks: 1

1977 Which package provides many event classes and Listener interfaces for event handling?

A. java.awt

B. java.awt.Graphics

C. java.awt.event

D. None of the above

Answer optionc
Marks: 1

1978 Which of these methods are used to register a mouse motion listener?

A. addMouse()

B. ddMouseListener()

C. addMouseMotionListner()

D. eventMouseMotionListener()

Answer optionc

Marks: 1

1979 Which type of Statement can execute parameterized queries?

A. PreparedStatement

B. ParameterizedStatement

C. ParameterizedStatement and CallableStatement

D. All kinds of Statements

Answer optiona

Marks: 1

1980 In which advantage of servlet, Servlets are managed by JVM so no need to worry about memory leak, garbage collection etc.?

A. Better performance

B. Portability

C. Robust

D. Secure

Answer optionc

Marks: 1

1981 Servlet technology is used to create web application?

A. true

B. false

C.

D.

Answer optiona

Marks: 1

1982 In HTTP Request method Get request is secured because data is exposed in URL bar?

A. true

B. false

C.

D.

Answer optionb

Marks: 1

1983 Swing is not a part of JFC (Java Foundation Classes) that is used to create GUI application?

A. TRUE

B. FALSE

C.

D.
Answer optionb

Marks: 2

1984 Which object can be constructed to show any number of choices in the visible window?

A. Labels

B. Choice

C. List

D. Checkbox

Answer optionc

Marks: 2

1985 What information is needed to create a TCP Socket?

A. The Local System’s IP Address and Port Number.

B. the Remote System's IPAddress and Port Number.

C. 1 & 2

D. none of the above

Answer optionc

Marks: 2

1986 Select The proper constructor of client Socket

A. Socket(String hostname,int port)

B. Socket(int port)

C. Socket()

D. none of the above

Answer optiona

Marks: 2

1987 What are the steps involved in establishing a connection?

A. loading the driver and .

B. making the connection

C. 1 & 2

D. none of the above

Answer optionc

Marks: 2

1988 Which will execute properly?

String url = "jdbc:odbc:Fred";


A. Connection con = DriverManager.getConnection(url, "Fernanda", "J8");

String url = "jdbc:odbc:Fred";


B. Connection con = driverManager.getConnection(url);

String url = "jdbc:odbc:Fred";


C. Connection con = getConnection(url, "Fernanda", "J8");

D. none of the above

Answer optiona

Marks: 2

1989 How can you load the drivers?

A. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

B. Class.Name("jdbc.odbc.JdbcOdbcDriver");
C. Class.forName("sun.jdbc");

D. Class.forName("sun.jdbc.odbc.Driver");

Answer optiona

Marks: 2

1990 The server removes the servlet at that time which method is called>

A. init()

B. end()

C. destroy()

D. service()

Answer optionc

Marks: 2

1991 Which method is used to load and initialize servlets?

A. init()

B. start()

C. destroy()

D. service()

Answer optiona

Marks: 2

1992 An HTTP Servlet handles client requests through its service ()method

A. false

B. true

C.

D.

Answer optionb

Marks: 2

1993 In which places can put the event handling code

A. Same class

B. Other class

C. Annonymous class

All mentioned above


D.

Answer optiond

Marks: 2

1994 Which is the container that doesn't contain title bar and MenuBars. It can have other components like button, textfield etc?

A. Window

B. Frame

C. Panel

D. Container

Answer optionc

Marks: 2

1995 Which of the following components generate action events?

A. Buttons
B. Labels

C. Check boxes

D. Windows

Answer optiona

Marks: 2

When two or more objects are added as listeners for the same event, which listener is first invoked to
1996 handle the event?

A. The first object that was added as listener.

B. The last object that was added as listener.

C. There is no way to determine which listener will be invoked first.

D. It is impossible to have more than one listener for a given event.

Answer optionc

Marks: 2

1997 Is it possible to get the Local host IP?

A. TRUE

B. FALSE

C.

D.

Answer optiona

Marks: 2

1998 A proxy server speaks the client side of a protocol to another server.

A. TRUE

B. FALSE

C.

D.

Answer optionb

Marks: 2

1999 The life cycle of a servlet is managed by

A. servelet context

B. servlet context

C. servlet container

D. the supporting protocol (such as http or https)

Answer optionc

Marks: 2

2000 A deployment descriptor describes

A. web component request objects

B. web component settings

C. web component response settings

D. none of the above

Answer optionb

Marks: 1

1. Which method is used to set the text of a Label object?


2001
A. setText( )

B. setLabel( )

C. setTextLabel( )

D. setLabelText( )

Answer optiona

Marks: 1

2002 Which method will cause a Frame to be displayed?

A. visible( )

B. setVisible( )

C. display( )

D. displayFrame( )

Answer optionb

Marks: 1

2003 Which layout should you use to organize the components of a container in a tabular form?

A. CardLayout

B. BorderLayout

C. FlowLayout

D. GridLayout

Answer optiond

Marks: 1

2004 Which of the following are passed as an argument to the paint( ) method?

A. A Canvas object

B. A Graphics object

C. An Image object

D. A paint object

Answer optionb

Marks: 1

2005 Which method is method to set the layout of a container?

A. startLayout( )

B. initLayout( )

C. layoutContainer( )

D. setLayout( )

Answer optiond

Marks: 1

2006 6. The Choice component allows multiple selection.

A. True.

B. False.

C.

D.

Answer optionb

Marks: 1
2007 Which of the following creates a List with 5 visible items and multiple selection enabled?

A. new List(5, true)

B. new List(true, 5)

C. new List(5, false)

D. new List(false,5)

Answer optiona

Marks: 1

2008 FocusListener has total ------ methods.

A. one

B. five

C. two

D. seven

Answer optionc

Marks: 1

2009 When character is entered which event will be generated?

A. Item Event

B. Action Event

C. Window Event

D. Text Event

Answer optiond

Marks: 1

2010 -----------method is used to find the type of event.

A. getSource()

B. getID()

C. Both

D. None of these

Answer optionb

Marks: 1

2011 TCP is a �������..........service.

A. connectionless

B. connection oriented

C. can not say

D. none ofthese

Answer optionb

Marks: 1

2012 the first part of an URL indicates the ���to be used

A. protocol

B. base address

C. site address

D. none of these

Answer optiona
Marks: 1

2013 JDBC stands for-----

A. Java Database Connectivity

B. java database components

C. java database controls

D. None of the above

Answer optiona

Marks: 1

2014 Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge?

A. Type1

B. Type 2

C. Type 3

D. Type 4

Answer optiona

Marks: 1

2015 For JDBC which of the following package is used

A. java.sql

B. java.jbl

C. java.net

D. all of above

Answer optiona

Marks: 1

2016 --------- interface allows storing result of a query?

A. statement

B. connectionstatement

C. ResultSet

D. none of the above

Answer optionc

Marks: 1

2017 What servlet processor was developed by Apache Foundation and Sun?

A. Apache Tomcat

B. Apache Web server

C. Sun servlet processor

D. None of the above is correct.

Answer optiona

Marks: 1

2018 what is JSP is basically used today?

A. To make controller

B. .to develop server pages

C. for writing business logic

D. for presentation
Answer optiond

Marks: 1

2019 which of the following methods are main methods in life cycle of servlet?

A. init()

B. service()

C. destroy()

D. all of above

Answer optiond

Marks: 1

1.A Frame�s background color is set to Color.Yellow, and a Button�s background color is to Color.Blue. Suppose the Button is added to
2020 a Panel, which is added to the Frame. What background color will be used with the Panel?

A. Color.Yellow

B. Color.Blue

C. Color.Green

D. Color.White

Answer optiona

Marks: 2

2021 Which method returns the preferred size of a component?

A. getPreferredSize( )

B. getPreferred( )

C. getRequiredSize( )

D. getLayout( )

Answer optiona

Marks: 2

3. An Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to change to another Layout
2022 Manager?

A. setLayoutManager(new GridLayout());

B. setLayout(new GridLayout(2,2));

C. setGridLayout(2,2,))

D. setBorderLayout();

Answer optionb

Marks: 2

4. Which of the following would create a text field able to display 10 characters (assuming a fixed size font) displaying the initial
2023 string "hello":

A. new TextField("hello", 10);

new TextField("hello");
B.

C. new textField(10);

D. new TextField();

Answer optiona

Marks: 2

2024 Which Package is used for handling security related issues in the programe.

A. java.security

B. java.lang.security
C. java.awt.image

D. java.io.security

Answer optiona

Marks: 2

2025 Which Method is used to know the full URL of an URL Object?

A. fullHostURL()

B. getHostURL()

C. ExternalForm()

D. toExternalForm()

Answer optiond

Marks: 2

2026 ��class is used to encapsulate IP address and DNS.

A. DatagramPacket

B. URL

C. InetAddress

D. Socket

Answer optionc

Marks: 2

2027 1.What is invoked via HTTP on the Web server computer when it responds to requests from a user's Web browser?

A. A Java application

B. A Java applet

C. A Java servlet

D. None of the above is correct.

Answer optionc

Marks: 2

2028 2.the doGet() extracts value of parameter's types and number by using

A. request.getParameter()

B. request.setParameter()

C. response.getParameter()

D. response.getAttribute()

Answer optiona

Marks: 2

2029 Identify correct syntyax of service() method of servlet class

A. void service(ServletRequest req,ServletResponse res)

B. void service(ServletRespone res,ServletRequest req)

C. void service(ServletRequestreq,ServletResponse res)

D. void service(ServletRequest req,ServletResponseres)

Answer optiona

Marks: 2
2. What is the result of executing the following Java class:
import java.awt.*;
public class FrameTest
extends Frame
{
public FrameTest()
{
add (new Button("First"));
2030 add (new Button("Second"));
add (new
Button("Third"));
pack();
setVisible(true);
}
public static void main(String args []) { new FrameTest();
}
}

A. Three buttons are displayed across a window.

B. A runtime exception is generated (no layout manager specified).

C. Only the first button is displayed.

D. Only the third button is displayed

Answer optiond

Marks: 2

3.Check the given code�.How many scrollbars are created�


import java.awt.*;
import java.applet.*;
/* <applet code=SCBarDemo height=300 width=200> </applet> */
public class SCBarDemo extends Applet
{ public void init()
{
2031 Scrollbar sc=new Scrollbar();
Scrollbar sc1=new Scrollbar(Scrollbar.VERTICAL);
Scrollbar sc2=new Scrollbar(Scrollbar.HORIZONTAL,0,1,50,100);
sc.setValue(50);
add(sc);
add(sc1);
}
}

A. Three scrollbars are created(sc,sc1,sc2)

B. Two scrollbars are created(sc,sc1)

C. Only one scrollbar is created(sc2)

D. None of these

Answer optionb

Marks: 2

4.What is the output of the following code:


import java.awt.*;
import javax.swing.*;
/*<applet code="JToggleDemo" height=100 width=100> </applet> */
public class JToggleDemo extends JApplet
{
public void init()
{
2032 Container c=getContentPane();
c.setLayout(new FlowLayout(FlowLayout.LEFT));
JToggleButton jb=new JToggleButton();
JToggleButton jb=new JToggleButton("ON/OFF");
c.add(jb);
c.add(jb1);
}
}

A. 2 toggle buttons are created

B. Only one toggle button is created

C. Compile time error

D. None of these

Answer optionc

Marks: 2
1.what is the output of the following code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=MMDemo height=300 width=200></applet> */
public class MMDemo extends Applet implements MouseMotionListener
{
String msg="";
public void init()
{
addMouseMotionListener(this);
2033 }
public void mouseMoved(MouseEvent me)
{
showStatus("Mouse Moved");
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,50,100);
}
}

A. Program is executed with mouseMoved() & mouseDragged() operations

B. Program is executed only with mouseMoved() operation

C. Program is executed only with mouseDragged() operation

D. Program is not executed

Answer optiond

Marks: 2

2.Select the missing statement in the program to get the following output
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
/*
<applet code="Jcombodemo" width=300 height=100>
</applet>
*/
public class Jcombodemo extends JApplet
implements ItemListener
{
JLabeljl;
ImageIconfrance, germany, italy, japan;
public void init()
{
Container contentPane = getContentPane();
2034 contentPane.setLayout(new FlowLayout());
JComboBoxjc = new JComboBox();
jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");
jc.addItemListener(this);
contentPane.add(jc);
contentPane.add(jl);
}
public void itemStateChanged(ItemEventie)
{
String s = (String)ie.getItem();
jl.setIcon(new ImageIcon(s + ".gif"));
}
} Y jl = new JLabel(new ImageIcon("star.gif")); jl = new JLabel("star.gif"); jl = new JLabel( ImageIcon("star.gif")); JLabel(new
ImageIcon("star.gif")); jl = new JLabel(new ImageIcon("star.gif"));

A. jl = new JLabel(new ImageIcon("star.gif"));

B. jl = new JLabel("star.gif");

C. jl = new JLabel( ImageIcon("star.gif"));

D. JLabel(new ImageIcon("star.gif"));

Answer optiona

Marks: 2

3.Select the missing statement in the below program import java.awt.*;


public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
Menu filemenu = new Menu("File");
2035 Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
MenuItem new1 = new MenuItem("New");
MenuItem open1 = new MenuItem("Open");
filemenu.add(new1);
filemenu.add(open1);
}
} mbr.add(view); mbr.add(menu); mbr.add(vieweditmenu); mbr.add(viewmenu); mbr.add(viewmenu);
A. mbr.add(view);

B. mbr.add(menu);

C. mbr.add(vieweditmenu);

D. mbr.add(viewmenu);

Answer optiond

Marks: 2

4.Consider the following output. Find the missing statement in the program.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/*
<applet code="SimpleKey1" width=300 height=100>
</applet>
*/
public class SimpleKey1 extends JApplet
implements KeyListener
{
String msg = "";
int X = 10, Y = 20;

public void init()


{
addKeyListener(this);
requestFocus();
}
2036
public void keyPressed(KeyEvent ke)
{
showStatus("Key Down");
}

public void keyReleased(KeyEvent ke)


{
showStatus("Key Up");

public void keyTyped(KeyEvent ke)


{
msg += ke.getKeyChar();
repaint();
}

public void paint(Graphics g)


{
g.drawString(msg, X, Y);
}
}

A. Missing Semicolon

B. }

C. {

D. ()

Answer optionb

Marks: 2

Consider the following program


What is the output of this program?

import java.net.*;
class networking {
2037 public static void main(String[] args) throws UnknownHostException {
InetAddress obj1 = InetAddress.getByName("msbte.com");
System.out.print(obj1.getHostName());
}
}

msbte
A.

B. msbte.com

C. www.msbte.com

D. None of the mentioned

Answer optionb

Marks: 2
1.Consider the following program.
What should be the correction done in the program to get correct output?
import java.sql.*;
class DBDemo1
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:EMPDSN"," "," ");
2038 Statement s=c.createStatement();
ResultSet rs=s.executeQuery("select *from EmpTable");
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();
}
}

A. Missing semicolon

B. Missing {

C. Missing }

D. Missing statement.

Answer optionc

Marks: 2

5.Consider the following program


Select the statement that should be added to the program to get correct output.
import java.sql.*;
public class DBDemo5
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
Statement s=c.createStatement( );
s.setString(1,args[0]);
2039 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.getDouble(3));
}
s.close();
c.close();
}
}

A. s.executeUpdate()

B. c.createStatement( )

C. s.close()

D. c.close()

Answer optiona

Marks: 2

1.Choose missing statements in following code from given options.

public class SessionDemo extends HttpServlet


{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
HttpSession hs = request.getSession(true);
response.setContentType("text/html");
2040 PrintWriter pw = response.getWriter();
pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*;

B. import java.Vector.* ; import java.Thread.*; import javax.servlet.*;

C. import javax.servlet.http.*; import java.String.*; import java.Vector;

D. import javax.servlet.http.*; import java.Thread.*; import javax.Client.*;


Answer optiona

Marks: 2

4.Consider the following program. Identify the missing statement from the output.
import java.net.*;
class URLDemo
{
public static void main(String args[]) throws MalformedURLException
{
URL netAddress= new URL(�http://www.sun.com: //index.html�); System.out.println(�Protocol :�+netAddress.getProtocol();
System.out.println(�Port :�+netAddress.getPort()); System.out.println(�Host :�+netAddress.getHost());
2041 System.out.println(�File :�+netAddress.getFile());
}
}

Output of the Program


Protocol :http
Host :www.sun.com
File :/index.html

A. Port :8080

B. Port :1024

C. Port: -1

D. None of the above

Answer optionc

Marks: 2

Consider the following program and identify the missing statement.

class URLDemo
{
public static void main(String args[]) throws MalformedURLException
{
2042 URL netAddress= new URL("http://www.sun.com:/index.html");
System.out.println("Protocol :"+netAddress.getProtocol());
System.out.println("Port :"+netAddress.getPort());
System.out.println("Host :"+netAddress.getHost());
System.out.println("File :"+netAddress.getFile());
}
}

A. Missing semicolon

B. Missing package statement

C. Missing initialization

D. None of the above

Answer optionb

Marks: 2

2043 ______Can be used to enter or display a String

A. label

B. button

C. checkboc

D. TextField

Answer optiond

Marks: 1

2044 The method_____gets the Contents of the TextField Jtf

A. Jtf.getText(s)

B. Jtf.getText()

C. Jtf.getString()

D. Jtf.findString()

Answer optionb

Marks: 1

2045 Which following method is method of TextArea

A. append()
B. setLable()

C. setValue()

D. getLable()

Answer optiona

Marks: 1

2046 To have GridLayout 3x5 in applet which command is used.

A. setLayout(GridLayout(3,5))

B. setLayout(new gridLayout())

C. setLayout(new GridLayout(3,5))

D. setLayout(GridLayout())

Answer optionc

Marks: 1

2047 Which Constructor is to create a checkable menu item

A. MenuItem()

B. CheckboxMenuItem()

C. CheckboxMenuItem(String s,boolean on)

MenuItem(String s,boolean b)
D.

Answer optionc

Marks: 1

2048 Which model defines standard and consistent mechanisms to generate and process events.

A. Event Handling Model

B. Event Delegation Model

C. Delegation Event Model

D. none of the above

Answer optionc

Marks: 1

2049 What is the highest-level event class of the event-delegation model?

A. The java.util.eventObject class

B. The java.lang.eventObject class

C. The java.awt.eventObject class

D. none of the above

Answer optiona

Marks: 1

2050 What event results from the clicking of a button?

A. The ActionEvent event is generated

B. The listenerEvent event is generated

C. The buttonEvent event is generated

D. The ActionEvent event is generated

Answer optiona

Marks: 1

2051 In which package are most of the AWT events that support the event-delegation model defined?
the
A. java.awt.event package

B. the
java.net package

the
C. java.util.awt.event package

D. none of the above

Answer optiona

Marks: 1

2052 What is the Proxy Server?

A. A proxy server speaks the client side of a protocol to another server

B. A proxy client speaks the client side of a protocol to another client

C. A proxy server speaks the server side of a protocol to another client side

D. A proxy server speaks the serverside of a protocol to another server

Answer optiona

Marks: 1

2053 What information is needed to create a TCP Socket?

A. The Local System’s IP Address and Port Number

B. The Local System’s IP Address

C. The Local System’s Port Number

D. none of the above

Answer optiona

Marks: 1

2054 what is URL instance represents

A. A URL instance represents the location of a resource

B. A URL instance represents the server address of a resource`

C. A URL instance represents the location of a client resource

D. none of the above

Answer optiona

Marks: 1

2055 Is it possible to get the Local host IP?

A. by using InetAddress's getLocalHost() method

B. by using InetAddress's printLocalHost() method

C. by using InetAddress's LocalHost() method

D. none of the above

Answer optiona

Marks: 1

2056 ________ is an open source DBMS product that runs on UNIX, Linux and Windows.

A. MYSQL

B. JSP/SQL

C. JDBC/SQL

D. non of the above

Answer optiona
Marks: 1

2057 Which of the following is not a valid attribute of a page directives?

A. language

B. extend

C. export

D. import

Answer optionc

Marks: 1

2058 Which of the following attributes are mandatory in <jsp:getProperty /> tag?

A. name, property

B. type, id

C. name, type

D. id, property

Answer optiona

Marks: 1

Which layout should you use to organize the components of a container in a


2059 tabular form?

A. card layout

B. border layout

C. grid layout

D. � flow Layout

Answer optionc

Marks: 2

2060 Package of drawString() method is____________

A. java.applet

B. java.httpx.servlet

C. java.swing

D. java.awt

Answer optiond

Marks: 2

2061 In java, gc() method is available in which package

A. java.lang package

B. java.util package

C. java.string package

D. java.lang package

Answer optiona

Marks: 2

Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to
2062 change to another Layout Manager?

A. setLayoutManager(new GridLayout());

setLayout(new GridLayout(2,2));
B.

C. setGridLayout(2,2,))
D. setLayout(LayoutManager layobj)

Answer optiond

Marks: 2

2063 To use the ActionListener interface it must be implemented by a class there are several ways to do that find in the following?

A. Creating a new class

B. using the class the graphical component

C. an anonymous inner class

D. All mentioned above

Answer optiond

Marks: 2

2064 What is DHCP?

A. dynamic hosy control protocol

B. Dynamic Host Configuration Protocol

C. Dynamic Host Control Protocol

D. none of the above

Answer optionb

Marks: 2

2065 What is URLConnection instance?

A. URLConnection instance represents a link for accessing or communicating with the resource at the location.

B. URLConnection instance represents an object that consist of the data we are searching for

C. URLConnection instance represents a data we are searching for

D. none of the above

Answer optiona

Marks: 2

The API doesn't list any constructors for InetAddress- How do I create an InetAddress
2066 instance?

InetAddress add1; InetAddress add2;


try{
A. add1 = InetAddress.getByName("java.sun.com");
add2 = InetAddress.getByName("199.22.22.22");
}catch(UnknownHostException e){}

InetAdd add1; InetAddress add2;


try{
B. add1 = InetAddress.getName("java.sun.com");
add2 = InetAddress.getName("199.22.22.22");
}catch(UnknownHostException e){}

C. All of the Above

D. none of the above

Answer optiona

Marks: 2

2067 How to implement the Servlet Interfcae

A. Servlets-->Generic Servlet-->HttpServlet-->MyServlet.

B. Servlets-->HttpServlet-->MyServlet.

C. Servlets-->Generic Servlet

D. none of the above

Answer optiona

Marks: 2
What information that the ServletResponse interface gives the servlet methods for replying to
2068 the client?

A. : It Allows the servlet to set the content length and MIME type of the reply

B. : It Allows the servlet to set the content type only

C. : It Allows the servlet to set the MIME type of the reply

D. none of the above

Answer optiona

Marks: 2

2069 When a servlet accepts a call from a client, it receives two objects- What are they?

A. ServeltRequest and ServletResponse

B. clientRequest and ServletResponse

C. Serveletresponce and client request

D. none of the above

Answer optiona

Marks: 2

What does the following line of code do?


2070 Textfield text = new Textfield(10);

A. Creates text object that can hold 10 rows of text.

B. Creates the object text and initializes it with the value 10.

C. The code is illegal.

D. Creates text object that can hold 10 columns of text.

Answer optiond

Marks: 2

2071 Which of the following applet tags is legal to embed an applet class named Test into a Web page?

< applet
A. class = Test width = 200 height = 100>

< applet>
B. code = Test.class width = 200 height = 100>

< applet
C. param = Test.class width = 200 height = 100>

< applet
D. code = Test.class width = 200 height = 100>

Answer optiond

Marks: 2

Consider the following program:


import myLibrary.*;
public class ShowSomeClass
2072 {
// code for the class...
}
What is the name of the java file containing this program?

A. myLibrary.java

B. ShowSomeClass.java

C. ShowSomeClass.class

D. ShowSomeClass

Answer optionb

Marks: 2

2073 Which method is invoked when a component is resized

A. void componentResized(ComponentEvent ce)


B. compoResized(ComponentEvent ce)

C. void componentMoved(ComponentEvent ce)

D. void componentsized(ComponentEvent ce)

Answer optiona

Marks: 2

2074 When a component loses keyboard focus ____________________this method is selected

A. void focusLost(FocusEvent fe)

B. void focusLoss(FocusEvent fe)

C. void lossfocus(FocusEvent fe)

D. non of the above

Answer optiona

Marks: 2

2075 method that is invoked when the state of an item changes.

A. void itemStateChanged(ItemEvent ie)

B. void StateChanged(ItemEvent ie)

C. void itemChanged(ItemEvent ie)

D. non of the above

Answer optiona

Marks: 2

2076 method is invoked when a character has been entered.

A. void keyTyped(KeyEvent ke)

B. void keyType(KeyEvent ke)

C. void Typed(KeyEvent ke)

D. non of the above

Answer optiona

Marks: 2

2077 How do I make a connection to URL?

URL url;
URLConnection connection;
A. try{ url = new URL("...");
conection = url.openConnection();
}catch (MalFormedURLException e) { }

try{ url = new URL("...");


B. conection = url.openConnection();
}catch (MalFormedURLException e) { }

URL url;
try{ url = new URL("...");
C. conection = url.openConnection();
}catch (MalFormedURLException e) { }

D. non of the above

Answer optiona

Marks: 2

What�s the difference between TYPE_SCROLL_INSENSITIVE , and


2078 TYPE_SCROLL_SENSITIVE?

A. a result set that is TYPE_SCROLL_INSENSITIVE does not reflect changes made while it is still open and one that is TYPE_SCROLL_SENSITIVE does the changes.

B. only result set that is TYPE_SCROLL_INSENSITIVE does not reflect changes made while it is still open.

C. both are same effect

D. non of the above


Answer optiona

Marks: 2

2079 How to call a Strored Procedure from JDBC

CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");


A. ResultSet rs = cs.executeQuery();

B. CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");

C. ResultSet rs = cs.executeQuery();

D. non of the above

Answer optiona

Marks: 2

2080 What is the correct signature of jspDestroy() method of HttpJspPage class?

A. void jspDestroy(HTTPRequest request, HTTPResponse response)

B. void jspDestroy(HTTPRequest request, HTTPResponse response) throws ServletException, IOException

C. non of the above

D. void jspDestroy()

Answer optiond

Marks: 2

2081 Is it possible to include files using absolute path in a JSP page using include directive?

A. Yes

B. No

C. both

D. none of above

Answer optiona

Marks: 2

2082 Which method will a web browser call on a new applet?

A. main method

B. destroy method

C. execute method

D. init method

Answer optiond

Marks: 1

2083 Which one of the following does not extends java.awt.Component

A. CheckBox

B. Canvas�

C. CheckbocGroup�

D. Label

Answer optionb

Marks: 1

2084 In Java an event is an _______which specifies the change of state in the source.

A. Class

B. Object

C. Int
D. String

Answer optionb

Marks: 1

2085 A checkbox is a control that consists of a

A. Combination of a small box

B. A label

C. Combination of a large box and a label

D. Both a & b

Answer optiond

Marks: 1

2086 Each menu is associated with a _________ list of menu items:

A. Checkbox

B. Drop-down

C. Choice

D. None of these

Answer optionb

Marks: 1

2087 Regular menus are placed at the __________ of the application window within a menu bar

A. Top

B. Bottom

C. Top-down

D. Botttom-up

Answer optiona

Marks: 1

2088 __________ constructs permission with specified name.

A. policy(Strng name)

B. Permission(String name)

C. access(String name)

D. control(String name)

Answer optionb

Marks: 1

2089 ________ classes in security implement message digest & Digital signatures and can authenticate java classes & other objects

A. access control

B. security

C. none of the above.

D. Authentication

Answer optiond

Marks: 1

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

A. fullHost()

B. getHost()
C. ExternalForm()

toExternalForm()
D.

Answer optiond

Marks: 1

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

A. ContentType()

B. contentType()

C. getContentType()

D. GetContentType()

Answer optionc

Marks: 1

2092 In order to run JSP .................... is required.

A. Mail Server

B. Applet viewer

C. Java Web Server

D. Database connection

Answer optionc

Marks: 2

2093 Which method will a web browser call on a new applet?

A. main method

B. destroy method

C. execute method

D. init method

Answer optiond

Marks: 2

2094 Which one of the following does not extends java.awt.Component

A. CheckBox

B. Canvas�

C. CheckbocGroup�

D. Label

Answer optionb

Marks: 2

2095 In Java an event is an _______which specifies the change of state in the source.

A. Class

B. Object

C. Int

D. String

Answer optionb

Marks: 2

2096 A checkbox is a control that consists of a

A. Combination of a small box


B. A label

C. Combination of a large box and a label

D. Both a & b

Answer optiond

Marks: 2

2097 A source generates an event and sends it to ___________ listeners that can handle the event

A. One

B. Two

C. One or more

D. None of these

Answer optionc

Marks: 2

2098 How many ports of TCP/IP are reserved for specific protocols?

A. 10

B. 1024

C. 2048

D. 512

Answer optionb

Marks: 2

2099 In Java an event is an _______which specifies the change of state in the source.

A. Class

B. Object

C. Int

D. String

Answer optionb

Marks: 2

2100 The Delegation Event Model is based on the concept of _____________

A. Source

B. Listener

C. Both a & b

D. None of these

Answer optionc

Marks: 2

2101 Which of the following is immediate base class of Frame.

A. JFrame

B. JWindow

C. Window

D. Container

Answer optionc

Marks: 1

2102 Which of the following package contains all the classes and methods required for event handling in Java.
A. java.awt

B. java.event

C. java.awt.event

D. All of these

Answer optionc

Marks: 1

2103 Which of the following class create checkable menu item.

A. CheckboxGroup

B. CheckboxMenu

C. CheckboxMenuItem

D. CheckableMenuItem

Answer optionc

Marks: 1

2104 All collection classes are available in__________________.

A. java.io

B. java.event

C. java.util

D. java.awt

Answer optionc

Marks: 1

2105 Which method returns Contenent pane type of object

A. getContainer()

B. getContent()

C. setContentPane()

D. getContentPane()

Answer optiond

Marks: 1

2106 Which of the following component are platform independent with respect to look and feel.

A. only awt component

B. only swing component

C. both (a) and (b)

D. Nither (a) nor (b)

Answer optionb

Marks: 1

2107 Which Layout Manager defines container in five different section.

A. GridLayout

B. GridbagLayout

C. CardLayout

D. BorderLayout

Answer optiond

Marks: 1
2108 Which of these is passive component

A. Label

B. Button

C. TextArea

D. Scrollbar

Answer optiona

Marks: 1

2109 Which of these of the following components are sources to generate ActionEvent

A. Button, TextField

B. Label, Button

C. Scrollbar, TextArea

D. Window

Answer optiona

Marks: 1

2110 What do you mean by URL.

A. Universal Resource Loaction

B. Unified Resource Locator

C. Uniform Resource Locator

D. Unique Resource Location

Answer optionc

Marks: 1

2111 getAllByName() method is defined in_______________ class

A. IPv4

B. IPv6

C. InetAddress

D. None of these

Answer optionc

Marks: 1

2112 Which class makes the server to always listen client requests.

A. Socket

B. ServerSocket

C. both (a) and (b)

D. Nither (a) nor (b)

Answer optionb

Marks: 1

Which package contains JDBC Classes


2113

A. java.jdbc

B. javax.jdbc

C. java.sql

D. javax.sql

Answer optionc
Marks: 1

2114 Which type of driver converts JDBC calls into the network protocol used by the DBMS directly?

A. Type-1

B. Type-2

C. Type-3

D. Type-4

Answer optiond

Marks: 1

2115 Dynamic interceptions of requests and responses to transform the information is done by

A. Servlet container

B. servlet config

C. servlet context

D. servlet filter

Answer optiond

Marks: 1

Which of the following is valid for DialogBoxes:


2116 Statement A: ModalDialog blocks user input to all other window in same application.
Statement B: ModalessDialog blocks user input to all other window in same application.

A. Both A and B

B. Only B

C. Only A

D. Nither (A) nor (B)

Answer optionc

Marks: 2

2117 What method is used to translate a mouse click on a specific point of the tree to tree path

A. getPathLocation(int x,int y)

B. getLocationPath(int x,int y)

C. getPathForLocation(int x,int y)

D. None of these

Answer optionc

Marks: 2

Select the missing statement in given code


import java.awt.*;
import java.applet.*;
/*
<applet code="ButtonDemo" width=300 height=100>
</applet>
*/
public class ButtonDemo extends Applet implements ActionListener
{
String msg = "";
int X = 20, Y = 20;
Button b;
public void init()
2118 {
. b=new Button("Click Here!!!");
}
public void actionPerformed(ActionEvent ae)
{
msg += b.getText();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, X, Y);
}
}

A. addListener(this);

B. addactionListener(this);
C. import java.awt.event.*;

D. Both (b) and ( C)

Answer optiond

Marks: 2

2119 ____________________ interface executes dynamic SQL statements.

A. Statement

B. Connection

C. ResultSet

D. PreparedStatement

Answer optiond

Marks: 2

2120 Identify correct syntax of doGet() method of servlet class

A. void doGet(HTTPRequest req, HTTPResponse res)

B. void doGet(HTTPResponse res, HTTPRequest req)

C. void doGet(HTTPServletRequest req, HTTPServletRequest req )

D. void doGet(HttpServletRequest req, HTTPServletResponse res)

Answer optiond

Marks: 2

Consider the following program. Find which statement contains error.

import java.awt.*;
import javax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTreeDemo extends JApplet
{
public void init() {
Container contentPane = getContentPane();
2121 contentPane.setLayout(new BorderLayout());
JTree tree = new JTree("Root");
DefaultMutableTreeNode chA=new DefaultMutableTreeNode("Child A");
DefaultMutableTreeNode chB=new DefaultMutableTreeNode("Child B");
tree.add(chA);
tree.add(chB);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(tree, v, h);
contentPane.add(jsp, BorderLayout.LEFT);
}
}

A. Error in statement in which JTree is created

B. importjava.applet.*;

C. Error in statement in which applet tag is declared

D. None of the above

Answer optionc

Marks: 2
Select the proper command to run the following code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/*
<applet code="JTreeEvents" width=400 height=500>
</applet>
*/

class JTreeEvents extends JApplet


{
JTree t;
JTextField tf;
public void init()
{
Container cp=getContentPane();
cp.setLayout(new BorderLayout());
DefaultMutableTreeNode top=new DefaultMutableTreeNode("Option");
DefaultMutableTreeNode a=new DefaultMutableTreeNode("A");

top.add(a);
DefaultMutableTreeNode a1=new DefaultMutableTreeNode("A1");
a.add(a1);

DefaultMutableTreeNode a2=new DefaultMutableTreeNode("A2");


a.add(a2);

DefaultMutableTreeNode b=new DefaultMutableTreeNode("B");


top.add(b);

2122 DefaultMutableTreeNode b1=new DefaultMutableTreeNode("B1");


b.add(b1);

DefaultMutableTreeNode b2=new DefaultMutableTreeNode("B2");


b.add(b2);

DefaultMutableTreeNode b3=new DefaultMutableTreeNode("B3");


b.add(b3);

t=new JTree(top);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;

JScrollPane jsp=new JScrollPane(tree,v,h);


cp.add(jtf,BorderLayout.SOUTH);
t.addMouseListerner(new MouseAdapter(){
public void mouseClicked(MouseEvent me){
doMouseClicked(me);
}
});
}
void doMouseclicked(MouseEvent me)
{
TreePath tp=t.getPathForLocation(me.getX(),me.getY());
if(tp!=null)
jtf.setText(tp.toString());
else
jtf.setText("");
}
}
}
}

A. Javac JTreeEvents.java

B. appletviewer JTreeEvents

C. appletviewer JTreeEvents.java

D. All of above

Answer optionc

Marks: 2

Observe the following code


import java.awt.*;
import java.applet.*;
public class LayoutDemo5 extends Applet
{
public void init()
{
int i,j,k,n=4;
setLayout(new BorderLayout());
Panel p1=new Panel();
2123 p1.setLayout(new FlowLayout());
p1.add(new TextField(20));
p1.add(new TextField(20));

add(p1,BorderLayout.EAST);
}
}
/*<applet code=LayoutDemo5.class width=300 height=400>
</applet>*/

What will be the output of the above program?

A. The output is obtained in Frame with two layouts: Frame layout and Flow Layout.

B. The output is obtained in Applet with Border Layout.

C. The output is obtained in Applet with two layouts: Frame layout and Border Layout.

D. The output is obtained in Applet with two layouts: Border layout and Flow Layout.
Answer optiond

Marks: 2

For the following code select the method that can be used to handle event.
import java.awt.*;
import java.awt.event.*;

class MenuItemAction extends Frame implements ActionListener


{
MenuBar mb;
Menu m;
MenuItem exit;

public MenuItemAction()
{
setTitle("ActionListener for MenuItem");

mb=new MenuBar();
m=new Menu("Menu");
exit=new MenuItem("Exit");
2124
exit.addActionListener(this);
m.add(exit);
mb.add(m);

setMenuBar(mb);
setSize(400,400);
setVisible(true);
}
public void _________________________
{
System.exit(0);
}
public static void main(String args[])
{
new MenuItemAction();
}
}

A. actionPerformed(ActionEvent ae)

B. Checkbox c=new Checkbox("a",true);

C. itemStateChanged(ItemEvent ie)

D. adjustmentPerformed(AdjustmentEvent ae)

Answer optiona

Marks: 2

Consider the following program


What will be displayed in the output?

import java.net.*;
class myAddress
{
public static void main (String args[])
{
try
2125 {
InetAddress[] address = InetAddress.getAllByName("www.test.com");
System.out.println(address);
}
catch (UnknownHostException e)
{
System.out.println("Could not find this computer's address.");
}
}
}

A. The internet address of the server

B. The internet address that represent all of the address the specified url resolve

C. The internet address of the host

D. The internet address of any other PC

Answer optionb

Marks: 2
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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN");
Statement s=c.createStatement();
2126 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));
}
s.close();
c.close();
}
}

A. Missing semicolon

B. add(t1);

C. Missing }

D. import java.sql.*;

Answer optiond

Marks: 2

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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=createStatement();
2127 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();
}
}

A. Error in main()

B. Error in "statement"

C. Error in connection statement

D. Error in close()

Answer optionb

Marks: 2

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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc");
Statement s=c.createStatement();
2128 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();
}
}

A. Missing semicolon

B. Missing Connection statement and Missing package statement.

C. Missing Exception

D. Missing package statement.

Answer optiond

Marks: 2
Consider the following program
Select the statement that should be added to the program to get correct output.
import java.sql.*;
public class SampleDemo
{
public static void main(String args[])throws SQLException
{
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
Statement s=c.createStatement( );
s.setString(1,args[0]);
2129 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.getDouble(3));
}
s.close();
c.close();
}
}

A. s.executeUpdate() Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

B. }

C. s.close() Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

D. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Answer optiona

Marks: 2

Choose missing statements in following code from given options.


<html> <body>
<Form name="Form1" action="AddServlet" method=post>
<INPUT TYPE= TEXT Name=First>
<INPUT TYPE= TEXT Name=Second>
<INPUT TYPE= SUBMIT VALUE="SUBMIT">
</Form>
</body> </html>
public class AddServlet extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse resp) throwsServletException, IOException
2130 {
String Snum1=res.getParameter("First");
int num1=Integer.parseInt(Snum1);
String Snum2=res.getParameter("Second");
int num2=Integer.parseInt(Snum2);
resp.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("The addition is: "+(num1+num2));
pw.close()
}
}

A. import java.io.*; import javax.servlet.*; import javax.servlet.http.*;

B. /*<applet code=app1.class width=200 height=200>

C. import javax.servlet.http.*; import java.String.*; import java.Vector;

D. import javax.servlet.http.*; import java.Thread.*; import javax.Client.*;

Answer optiona

Marks: 2

2131 AWTEvent class is used?

A. This class used to creates a group of check box controls.

B. This class creats AWT events.

C. This class encapsulates AWT events listeners.

D. This class encapsulates AWT events.

Answer optiond

Marks: 1

2132 Container class is sub class of�.

A. Component

B. Panel

C. Frame

D. Window
Answer optiona

Marks: 1

2133 Push button is an active control that has ��� appearance

A. one-dimentional

B. two-dimentional

C. three-dimentional

D. none of these

Answer optionc

Marks: 1

2134 An object is composed of :

A. Properties

B. Methods

C. Events

D. All of the above

Answer optiond

Marks: 1

2135 ��.class creates a single line edit control.

A. TextField

B. TollKit

C. TextArea

D. TextComponent

Answer optiona

Marks: 1

2136 Till now two models have been introduced in java for :

A. Receiving and processing event

B. deleting and processing events

C. receiving and processing events

D. modifying and receiving events

Answer optiona

Marks: 1

2137 The JDBC-ODBC bridge allows ����to be used as����. .

A. JDBC drivers,ODBC drivers

B. Drivers, Application

C. ODBC drivers,JDBC drivers

D. Application , drivers

Answer optiona

Marks: 1

2138 For execution of DELETE SQL query in JDBC, ............. method must be used.

A. executeQuery()

B. executeDeleteQuery()

C. executeUpdate()
D. executeDelete()

Answer optionc

Marks: 1

2139 A user types the URL http://www.msbte.com/result.php. Which HTTP request gets generated? Select the one correct answer

A. GET method

B. POST method

C. HEAD method

D. PUT method

Answer optiona

Marks: 1

2140 What is the purpose of JTable?

A. JTable object displays rows of data.

B. JTable object displays columns of data

C. JTable object displays rows and columns of data.

D. JTable object displays data in Tree form.

Answer optionc

Marks: 2
Select the missing statement in given code
importjava.awt.*;
importjava.applet.*;
/*
<applet code="mouse" width=300 height=100>
</applet>
*/
public class mouse extends Applet implements MouseListener, MouseMotionListener
{
String msg = "";
intmouseX = 0, mouseY = 0
public void init()
{
}
public void mouseClicked(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "Mouse clicked.";
repaint();
}
public void mouseEntered(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "Mouse entered.";
repaint();
}
public void mouseExited(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "Mouse exited.";
2141 repaint();
}
public void mousePressed(MouseEvent me)
{
mouseX = me.getX();
mouseY = me.getY();
msg = "Down";
repaint();
}
public void mouseReleased(MouseEvent me)
{
mouseX = me.getX();
mouseY = me.getY();
msg = "Up";
repaint();
}
public void mouseDragged(MouseEvent me)
{
mouseX = me.getX();
mouseY = me.getY();
msg = "*";
showStatus("Dragging mouse at " + mouseX + ", " + mouseY);
repaint();
}
public void mouseMoved(MouseEvent me)
{
showStatus("Moving mouse at " + me.getX() + ", " + me.getY());
}
public void paint(Graphics g)
{
g.drawString(msg, mouseX, mouseY);
}
}

A. addMouseMotionListener(this);

B. addMouseListener(this);

C. import java.awt.event.*;

D. all of above

Answer optiond

Marks: 2

2142 Select the proper method to retrieve the host name of local machine

A. static InetAddress getLocalHost( )throws UnknownHost Exception

B. static InetAddressgetByName(String hostName)throws UnknownHostException

C. static InetAddress[ ] getAllByName(String hostname throws UnknownHostException

D. string getHostAddress()

Answer optiona

Marks: 2

2143 Select the proper constructor of URL class

A. URL(String protocolName, String hostName, int port, String path)

B. URL(String urlSpecifier)

C. URL(String protocolName, String hostName, String path)


D. All of above

Answer optiond

Marks: 2

2144 PreparedStatement interface extends____________________ interface

A. Connection

B. Statement

C. ResultSet

D. Driver

Answer optionb

Marks: 2

Difference between doGet() and doPost() methods is___________________. Select any of given options
A. In doGet() the parameters are appended to the URL and sent along with header information.
2145 B. In doPost(),will send the information through a socket back to the webserver and it won't show up in the URL bar.
C. doGet() is a request for information;
D. doPost() provides information (such as placing an order) that the server is expected to remember

A. All above are valid differences

B. Only A and B

C. Only C and D

D. A, B, C are valid differences.

Answer optiona

Marks: 2

2146 Advantage of JSP over Servlet is____________

A. JSP is web page and servlets are Java programs

B. JSP is web page scripting language and servlets are Java programs

C. JSP is web page scripting language and servlets are simple programs

D. JSP is program and servlets are scripting language

Answer optionb

Marks: 2

Observe the following code


importjava.awt.*;
importjava.applet.*;
public class LayoutDemo5 extends Applet
{
public void init()
{
inti,j,k,n=4;
setLayout(new BorderLayout());
Panel p1=new Panel();
Panel p2=new Panel();

p1.setLayout(new FlowLayout());
p1.add(new TextField(20));
2147 p1.add(new TextField(20));

p2.setLayout(new GridLayout(5,3));
p2.add(new Button("OK"));
p2.add(new Button("Submit"));

add(p1,BorderLayout.EAST);
add(p2,BorderLayout.WEST);
}
}
/*<applet code=LayoutDemo5.class width=300 height=400>
</applet>*/

What will be the output of the above program?

A. The output is obtained in Frame with two layouts: Frame layout and Flow Layout.

B. The output is obtained in Applet with two layouts: Frame layout and Flow Layout.

C. The output is obtained in Applet with two layouts: Frame layout and Border Layout.

D. The output is obtained in Applet with two layouts: Border layout and Flow Layout.

Answer optiond
Marks: 2

Select the proper command to run the following code


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
/*
<applet code="combodemo11" width=300 height=100>
</applet>
*/
public class combodemo11 extends JApplet
{
2148 public void init()
{
Container co = getContentPane();
co.setLayout(new FlowLayout());
JComboBoxjc=new JComboBox();
jc.addItem("cricket");
jc.addItem("football");
jc.addItem("hockey");
jc.addItem("tennis");
co.add(jc);
}
}

A. Javac combodemo11.java

B. java combodemo11

appletviewer combodemo11.java
C.

D. All of above

Answer optionc

Marks: 2

Select the missing statement in the program to get the following output

importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
/*
<applet code="combodemo" width=300 height=100>
</applet>
*/
public class combodemo extends JApplet
implements ItemListener
{
JLabeljl;
ImageIconfrance, germany, italy, japan;
public void init()
{
2149 Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JComboBoxjc = new JComboBox();
jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");
jc.addItemListener(this);
contentPane.add(jc);
contentPane.add(jl);
}
public void itemStateChanged(ItemEventie)
{
String s = (String)ie.getItem();
jl.setIcon(new ImageIcon(s + ".gif"));
}
}

A. jl = new JLabel(new ImageIcon("star.gif"));

B. jl = new JLabel("star.gif");

C. jl = new JLabel( ImageIcon("star.gif"));

D. JLabel(new ImageIcon("star.gif"));

Answer optiona

Marks: 2
Select the missing statement in the program for following output
import java.awt.*;
public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
Menu filemenu = new Menu("File");
2150
Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
MenuItem new1 = new MenuItem("New");
MenuItem open1 = new MenuItem("Open");
filemenu.add(new1);
filemenu.add(open1);
}
}

A. mbr.add(view);

B. mbr.add(menu);

C. mbr.add(vieweditmenu);

D. mbr.add(viewmenu);

Answer optiond

Marks: 2

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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
2151 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();
}
}

A. Missing semicolon

B. Missing {

C. Missing }

D. Missing statement.

Answer optionc

Marks: 2

Choose missing statements in following code from given options.

public class session1 extends HttpServlet


{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
HttpSession hs = request.getSession(true);
response.setContentType("text/html");
2152 PrintWriter pw = response.getWriter();
pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*;

B. import java.Vector.* ; import java.Thread.*; import javax.servlet.*;

C. import javax.servlet.http.*; import java.String.*; import java.Vector;

D. import javax.servlet.http.*; import java.Thread.*; import javax.Client.*;

Answer optiona
Marks: 2

In following Java program fill statement showing ***.Select any one option fro given options

import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
2153 String data = request.getParameter("data");
Cookie cookie = ***************
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. new Cookie("MyCookie", data);

B. new Cookie("MyCookie", data1);

C. new Cookie("MyCookie", data2);

D. new Cookie("MyCookie", database);

Answer optiona

Marks: 2

2154 Which of the following are the subclasses of Window class

A. Frame,Dialog

B. Frame,Applet

C. Frame,Panel

D. Panel,Dialog

Answer optiona

Marks: 1

2155 Which of the following constructor is used for creating frame window with the title

A. Frame()

B. Frame(String title)

C. Frame(String title,int size)

D. None of the above

Answer optionb

Marks: 1

2156 To get the label associated with the Button which of the following method is used

A. getText()

B. getLabel()

C. getString()

D. None of the above

Answer optionb

Marks: 1

2157 To create radiobuttons in AWT which of the following constructor of Checkbox is used

A. Checkbox()

B. Checkbox(String str)

C. Checkbox(String str,boolean on)

D. Checkbox(String str,boolean on,CheckboxGroup cbg)

Answer optiond
Marks: 1

2158 To select a item from choice which of the following method is used

A. void select(int index)

B. void select(String item)

C. both a&b

D. none of the above

Answer optionc

Marks: 1

2159 To get the current value of scrolling which of the following method is used

A. int getMinimum()

B. int getMaximum()

C. void setValue(int newvalue)

D. int getValue()

Answer optiond

Marks: 1

2160 Which of the following method is used to create password type of textfield

A. void setEchoChar(char ch)

B. void setText(String text)

C. char getEchoChar()

D. void setChar(char ch)

Answer optiona

Marks: 1

2161 In swing components are added to

A. RootPane

B. GlassPane

C. ContentPane

D. MasterPane

Answer optionc

Marks: 1

2162 Events are supported by which of the following packages

A. java.util

B. java.awt

C. java.awt.event

D. all of the above

Answer optiond

Marks: 1

2163 Which integer constants are defined by WindowEvent?

A. WINDOW_ACTIVATED

B. WINDOW_CLOSED

C. WINDOW_ICONIFIED

D. ALL THE ABOVE


Answer optiond

Marks: 1

2164 When the size,position or visibility of a component is changed which event is generated

A. ContainerEvent

B. ComponentEvent

C. ActionEvent

D. FocusEvent

Answer optionb

Marks: 1

2165 Which of these are types of MouseEvents

A. MOUSE_CLICKED

B. MOUSE_PRESSED

C. MOUSE_RELEASED

D. all of the above

Answer optiond

Marks: 1

2166 ���� class is used to create TCP servers

A. Socket

B. ServerSocket

C. InetAddress

D. SocketAddress

Answer optionb

Marks: 1

2167 To get protocol used by the URL which of the following method is used

A. getPort()

B. getHost()

C. getProtocol()

D. getFile()

Answer optionc

Marks: 1

2168 ��.interface is used to handle precompiled SQL statements

A. Connection

B. Statement

C. PreparedStatement

D. CallableStatement

Answer optionc

Marks: 1

Which method is called at the end of the Servlet Life Cycle


2169

A. service()

B. init()

C. stop()
D. destroy()

Answer optiond

Marks: 1

2170 The service() method of servlet is called by which of the following

A. Servlet Container

B. Web browser

C. Client

D. Servlet

Answer optiona

Marks: 1

2171 Which components are used to generate following output

A. Label,TextArea,Button

B. TextField,TextArea,Button

C. Label,TextField,Button

D. Label,Choice,Button

Answer optionc

Marks: 2

2172 For the following output how frame is created

A. Frame is created as a standalone application

B. Frame is called within an applet

C. Frame is called within another frame

D. Frame is called from Dialog box

Answer optionb

Marks: 2

2173 Following output is generated using which layout manager

A. GridLayout

B. FlowLayout

C. BorderLayout

D. GridbagLayout

Answer optiond

Marks: 2

2174 Find out the correct steps to use JTree

A. Create an instance of JTree. Create a JScrollPane and specify the tree as the object to be scrolled. Add the tree to the scroll pane. Add the scroll pane t

B. Create an instance of JTree and add to rootpane

C. Create an instance of JTree and add it to scrollbar

D. None of the above

Answer optiona

Marks: 2
Select the missing statement in the given code
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=textevdemo width=400 height=400>
</applet>*/
public class textevdemo extends Applet implements TextListener
{
TextField f=new TextField("Hello");
2175 public void init()
{
f.addTextListener(this);
}
public void textValueChanged(TextEvent e)
{
showStatus("you are changeing text from textfield");
}
}

A. add();

B. add(f);

public static void main(String ar[])


{
C. add(f);
}

D. textevdemo.add(f);

Answer optionb

Marks: 2

To get the following output complete the code given bellow


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=mouseevdemo width=400 height=400>
</applet>*/
public class mouseevdemo extends Applet implements MouseListener
{String msg=" ";
public void init()
{
addMouseListener(this);
}
public void paint(Graphics g)
{
g.drawString(msg,20,100);
}
public void mouseEntered(MouseEvent e)
{
2176 msg="Mouse entered in applet area";
repaint();
}
public void mouseExited(MouseEvent e)
{
msg="Mouse exited from applet area";
repaint();
}
public void mousePressed(MouseEvent e)
{
msg="Mouse Pressed in applet area at"+e.getX()+" "+e.getY();
repaint();
}
public void mouseReleased(MouseEvent e)
{
msg="Mouse released at current position";
repaint();
}
}

public void mouseClicked(MouseEvent e)


{
A. showStatus("Mouse clicked in applet area for"+" "+e.getClickCount()+" no of times");
}

public void mouseClicked(MouseEvent e)


{
B. msg="Mouse clicked in applet area for"+" "+e.getClickCount()+" no of times");
}

public void mouseClicked(MouseEvent e)


{
C. msg=”Mouse clicked in applet area for"+" "+e.getClickCount()+" no of times";
repaint();
}

D. msg=” Mouse clicked in applet area for"+" "+e.getClickCount()+";

Answer optiona

Marks: 2
Select the proper output for following code
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=eventdemo width=400 height=400>
</applet>*/
public class eventdemo extends Applet implements MouseListener
{
Button toggle=new Button("off");
Button toggle1=new Button("on");
String msg,msg1;
public void init()
{
add(toggle);
add(toggle1);
toggle.addMouseListener(this);
toggle1.addMouseListener(this);
}
public void mouseEntered(MouseEvent e)
{
2177 if(e.getSource()==toggle)
{
msg=toggle.getLabel();
msg1=toggle1.getLabel();
toggle.setLabel(msg1);
toggle1.setLabel(msg);
}
else
{
msg1=toggle.getLabel();
msg=toggle1.getLabel();
toggle.setLabel(msg);
toggle1.setLabel(msg1);
}
}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
}

A. S1Q31O1.jpge

B. S1Q31O2.jpge

C. S1Q31O3.jpge

D. a)� � � � Error in above code

Answer optiona

Marks: 2

What will be displayed in output


import java.net.*;
class patrickURL {
public static void main(String args[]) throws
MalformedURLException {
URL hp = new URL("http://www.google.com/index.html");
2178 System.out.println("Protocol: " + hp.getProtocol());
System.out.println("Port: " + hp.getPort());
System.out.println("Host: " + hp.getHost());
System.out.println("File: " + hp.getFile());
}
}

A. Disply the protocol name,port no,host name,file name of the googles URL

B. Display the data of index.html page

C. Display the HTML source code of googles index page

D. Display error

Answer optiona

Marks: 2

2179 Select the Exception name that will be thrown if we do not provide URL in proper format

A. IOException

B. RunTimeException

C. MalformedURLException

D. GeneralException

Answer optionc

Marks: 2

2180 The executeQuery method returns

A. Connection object
B. ResultSet object

C. Statement object

D. PreparedStatement object

Answer optionb

Marks: 2

2181 Select the method used for loading and registering the driver

A. DriverManager.getConnection()

B. Class.forName(String driver)

C. Driver.register(String driver)

D. None of the above

Answer optionb

Marks: 2

2182 Select the true statement for JSP and Servlet

A. Servlets run faster than JSP

B. JSP is a web page scripting language

C. JSP programs are compiled to servlets

D. All of the above

Answer optiond

Marks: 2

2183 HttpServlet class extends which class

A. HttpServletRequest

B. HttpServletResponse

C. GenericServlet

D. Servlet

Answer optionc

Marks: 1

2184 Which of the following methods belongs to HttpServlet class

A. doGet()

B. doPost()

C. doDelete()

D. all of the above

Answer optiond

Marks: 2

Select the missing statement in given code


import java.awt.*;
import javax.swing.*;
/*<applet code="toggle" width=400 height=400>
</applet>*/
public class toggle extends JApplet
{
2185
JToggleButton t=new JToggleButton(new ImageIcon("Desert.jpg"));
public void init()
{
t.setPressedIcon(new ImageIcon("Tulips.jpg"));
}
}

A. Container c=getContentPane();

B. c.add(t);

C. both a&b
D. nothing is missing

Answer optionc

Marks: 2

Complete the code to generate following output


import java.awt.*;
import javax.swing.*;
/*<applet code=jscroll width=400 height=400>
</applet>*/
public class jscroll extends JApplet
{
2186 JScrollPane js;
ImageIcon i=new ImageIcon("Koala.jpg");
JLabel l=new JLabel(i);
public void init()
{
c.add(js);
}
}

Container c=getContentPane();
A. js=new JScrollPane(l,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

B. js= new JScrollPane(l,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

C. Container c=getContentPane();

D. C.add(l);

Answer optiona

Marks: 2

2187 Select proper code for given output

import java.awt.*;
import java.applet.*;
/*<applet code="checkboxdemo" width=400 height=400>
</applet>*/
public class checkboxdemo extends Applet
{
Checkbox c1,c2;
CheckboxGroup cb=new CheckboxGroup();
A. public void init()
{
c1=new Checkbox("Male",cb,true);
c2=new Checkbox("Female",cb,false);
add(c1);
add(c2);
}
}

import java.applet.*;
/*<applet code="checkboxdemo" width=400 height=400>
</applet>*/
public class checkboxdemo extends Applet
{
Checkbox c1,c2;
public void init()
B. {
c1=new Checkbox("Male”);
c2=new Checkbox("Female”);
add(c1);
add(c2);
}
}

import java.awt.*;
/*<applet code="checkboxdemo" width=400 height=400>
</applet>*/
public class checkboxdemo extends Applet
{
Checkbox c1,c2;
Checkbox cb=new Checkbox ();
C. public void init()
{
c1=new Checkbox("Male",cb,true);
c2=new Checkbox("Female",cb,false);
add(c1);
add(c2);
}
}

import java.awt.*;
import java.applet.*;
/*<applet code="checkboxdemo" width=400 height=400>
</applet>*/
public class checkboxdemo extends Applet
{
Checkbox c1,c2;
D. public void init()
{
c1=new Checkbox("Male",cb,true);
c2=new Checkbox("Female",cb,false);
add(c1);
add(c2);
}
}

Answer optiona
Marks: 2

Observe the following code


import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*<applet code=carddemo width=400 height=400>
</applet>*/
public class carddemo extends Applet implements ActionListener
{
Button card1=new Button("Show card1");
Button card2=new Button("Show card2");
Panel main,p1,p2;
Label l1,l2;
CardLayout c;
public void init()
{c=new CardLayout();
main=new Panel();
p1=new Panel();
p2=new Panel();
main.setLayout(c);
l1=new Label(" ");
2188 l2=new Label(" ");
l1.setBackground(Color.RED);
l2.setBackground(Color.GREEN);
p1.add(l1);
p2.add(l2);
main.add(p1,"card1");
main.add(p2,"card2");
add(main);
add(card1);add(card2);
card1.addActionListener(this);
card2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==card1)
c.show(main,"card1");
else
c.show(main,"card2");
}
}
What will be the output of the above program

A. The output is obtained in Applet having two Buttons with caption Show card1& Show card2.when these buttons are pressed the respected card will be shown

B. The output is obtained in Frame having two Buttons with caption Show card1& Show card2.when these buttons are pressed the respected card will be shown

C. The output is obtained in Applet showing colors Red or Green in background

D. The output is obtained in Frame showing colors Red or Green in background

Answer optiona

Marks: 2

Consider the following output. And find out the missing statement in the given code
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code=textevdemo width=400 height=400>
</applet>*/
public class textevdemo extends Applet implements TextListener
2189 {
TextField f=new TextField("Hello");
public void init()
{
add(f);
f.addTextListener(this);
}
}

public void textChanged(TextEvent e)


{
A. showStatus("you are changeing text from textfield");
}

public void textValueChanged(TextEvent e)


{
B. showStatus("you are changeing text from textfield");
}

public void valueChanged(TextEvent e)


{
C. showStatus("you are changeing text from textfield");
}

public void actionPerformed(ActionEvent e)


{
D. showStatus("you are changeing text from textfield");
}

Answer optionb

Marks: 2
Select the missing statement in the given code to generate following output
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class windowevent extends Frame implements WindowListener
{
String msg=" ";
windowevent(String title)
{
super(title);
setSize(400,400);
setVisible(true);
addWindowListener(this);
}
public void windowActivated(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
msg="Deactivated";
repaint();
}
public void windowOpened(WindowEvent e)
2190 {
}
public void windowClosed(WindowEvent e)
{
}
public void windowClosing(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowDeiconified(WindowEvent e)
{
}
public void paint(Graphics g)
{
g.drawString(msg,100,100);
}
public static void main(String ar[])
{
windowevent d=new windowevent("WindowEvent demo");
}
}

msg="Activated";
A. repaint();

B. msg=”Activated”;

C. repaint();

D. nothing is missing

Answer optiona

Marks: 2

2191 For getting bellow output what must be the sequence of controls to be added to window

A. List then Choice then TextArea

B. TextArea then Choice then List

C. Choice then List then TextArea

D. List then List then TextArea

Answer optionc

Marks: 2

Consider the following program.What correction should be done to get the correct output
import java.lang.sql.*;
class stud1
{
public static void main(String ar[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:studdsn");
Statement s1=con.createStatement();
ResultSet res;
System.out.println("Before insertion");
res=s1.executeQuery("select * from student");
while(res.next())
2192 {
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
Statement st=con.createStatement();
st.executeUpdate("insert into student values('Joshi',10,75)");
System.out.println("inserted");
System.out.println("After insertion");
res=s1.executeQuery("select * from student");
while(res.next())
{
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
}
}

A. Instead of executeQuery() method it should be execute()


B. The package should be java.sql

C. In while loop the methods should be set not the get methods

D. No correction should be done

Answer optionb

Marks: 2

Consider the following program what correction should be done to get the correct output
import java.sql.*;
class stud
{
public static void main(String ar[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:studdsn");
Statement s1=con.createStatement();
ResultSet res;
System.out.println("Before updation");
res=s1.executeUpdate("select * from student");
while(res.next())
2193 {
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
Statement st=con.createStatement();
st.executeUpdate("update student set Name='john' where Roll_No=2");
System.out.println("updated");
System.out.println("After updation");
res=s1.executeQuery("select * from student");
while(res.next())
{
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
}
}

A. createStatement(select * from student) should be this one

B. res= s1.executeQuery("select * from student")should be there instead of executeUpdate

C. Semicolon missing

D. res.next method should be removed

Answer optionb

Marks: 2

Consider the following program and find out the error


import java.sql.*;
class stud2
{
public static void main(String ar[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:studdsn");
Statement s1=con.createStatement();
ResultSet res;
System.out.println("Before deletion");
res=s1.executeQuery("select * from student");
while(res.next())
{
2194
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
Statement st=con.createStatement();
st.executeUpdate("delete from student set Roll_No=2");
System.out.println("deleted");
System.out.println("After deletion");
res=s1.executeQuery("select * from student");
while(res.next())
{
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
}
}

A. Error in exception handling

B. Error in Loop

C. Error in main method

D. Error in deletion query

Answer optiond

Marks: 2
Consider the following program and select the code that should get added to get the following output
import java.sql.*;
class stud5
{
public static void main(String ar[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:studdsn");
Statement s1=con.createStatement();
ResultSet res;
System.out.println("Before insertion");
res=s1.executeQuery("select * from student");
while(res.next())
{
2195 System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}
PreparedStatement st=con.prepareStatement("insert into student values(?,?,?) ");
st.setString(1,"Sayali");
st.setInt(2,45);
st.setInt(3,70);
st.executeUpdate();
st.setString(1,"Katta");
st.setInt(2,43);
st.setInt(3,70);
st.executeUpdate();
System.out.println("After insertion");
res=s1.executeQuery("select * from student");
}
}

A. System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));

while(res.next())
{
B. System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
}

res.next();
C. System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));

D. Nothing should get added

Answer optionb

Marks: 2

Consider the following program structure and find out the missing statement from given options
Login.html
<html>
<form name="xyz" action="http://localhost:8080/programs/Login" method="post">
<input type="textbox" name="name" value="">
<input type="password" name="pass" value="">
<input type="submit" value="Login">
</form>
</html>

Login.java

import java.io.*;
import javax.servlet.*;
2196
import javax.servlet.http.*;
public class Login extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
String
String pass=req.getParameter("pass");
if(name.equals("sesp") && pass.equals("sesp"))
pw.println("Login successful");
}
}

A. name=res.getParameter(“name”);

B. name=req.getParameter(“name”);

C. name=req.getInitParameter(“name”);

D. name=res.getInitParameter(“name”);

Answer optionb

Marks: 2

Consider the following program and replace the ***** with the correct option
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class greet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
2197 {
res.***********("text/html");
PrintWriter pw=res.getWriter();
String name=req.getParameter("name");
pw.println("<h1>Hello</h1>"+name);
}
}

A. getContentType()
B. setContentType()

C. setType()

D. getType()

Answer optionb

Marks: 2

Consider the following program and find out the missing statement
import javax.servlet.*;
import java.io.*;
public class image extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
2198 {
res.setContentType("image/jpeg");
pw.println("<html>");
pw.println("<img src='Sunset.jpg' width=600 height=800>");
pw.println("</html>");
}
}

A. PrintWriter pw=res.getWriter();

B. Cookie pw=res.getCookies();

C. InputStream pw=res.getInputStream();

D. String pw;

Answer optiona

Marks: 2

2199 What is the correct form of web.xml file

<servlet>
<servlet-name>third</servlet-name>
<servlet-class>image</servlet-class>
</servlet>
A. <servlet-mapping>
<servlet-name>third</servlet-name>
<url-pattern>/image</url-pattern>
</servlet-mapping>

<web-app>
<servlet>
<servlet-name>third</servlet-name>
<servlet-class>image</servlet-class>
</servlet>
B. <servlet-mapping>
<servlet-name>third</servlet-name>
<url-pattern>/image</url-pattern>
</servlet-mapping>
</web-app>

<servlet-mapping>
<servlet-name>third</servlet-name>
C. <url-pattern>/image</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>third</servlet-name>
D. <servlet-class>image</servlet-class>
</servlet>

Answer optionb

Marks: 2

Find out the correct option to be replaced at ***** in given program

addcook.html

<html>
<form name="aa" action="http://localhost:8080/programs/addcook" method="post">
Enter value for MyCookie
<input type="textbox" name="data">
</form>
</html>

addcook.java

import java.io.*;
2200 import javax.servlet.*;
import javax.servlet.http.*;
public class addcook extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter w=res.getWriter();
String data=req.getParameter("data");
Cookie c=**********("MyCookie",data);
res.addCookie(c);
w.println("<b>"+"Cookie has been set to:"+data);
}
}
A. new Cookie

B. setCookie

C. getCookie

D. new Cookies

Answer optiona

Marks: 2

2201 Which is highest Level of class in event deligation hierarchy?

A. EventObject

B. EventListener

C. Event

D. AWTEvent

Answer optiona

Marks: 1

2202 text area that is 80 character-widths wide and 10 character-heights tall can be created with which syntax?

A. new TextArea(80, 10)

B. new TextArea(10, 80)

C. new TextArea(10)

D. new TextArea(80)

Answer optionb

Marks: 1

2203 Default Layout of Dialog class

A. FlowLayout

B. GridLayout

C. BorderLayout

D. Null Layout

Answer optionc

Marks: 1

2204 The MouseMotion Listener contain how many methods

A. 1

B. 2

C. 3

D. 4

Answer optionb

Marks: 1

2205 Which event is generated when keyboard input occurs?

A. ActionEvent

B. ItemEvent

C. AdjustmentEvent

D. KeyEvent

Answer optiond

Marks: 1
2206 How many JDBC driver types does Sun define?

A. 1

B. 2

C. 3

D. 4

Answer optiond

Marks: 1

2207 Which JDBC driver type is the JDBC ODBC bridge?

A. Type 1

B. Type 2

C. Type 3

D. Type 4

Answer optiona

Marks: 1

2208 Which html tag can be used to send the request to servlet?

A. form

B. input

C. body

D. head

Answer optiona

Marks: 1

2209 The getSession() method with 'true' as its parameter [ getSession(true) ] it will return the appropriate session object when

A. the session is completed

B. the session object is passed to another method

C. the session does not exists

the session is existing


D.

Answer optiond

Marks: 1

2210 To create control in AWT which class will be used

A. Checkbox

B. RadioButton

C. JCheckBox

D. JRadioButton

Answer optiona

Marks: 2

import java.applet.*;
import java.awt.*;
/*
<applet code="Demo" width=200 height=200>
</applet>
*/
public class Demo extends Applet{
public void init(){
2211 Button button1 = new Button("Button 1");
Button button2 = new Button("Button 2");
button1.setBackground(Color.red);
button2.setBackground(Color.green);
add(button1);
add(button2);
}
}
A. The code will give error at compile time

B. The code will give error at run time

C. creates both buttons in red color

D. create Button1 in red color and Button2 in green color

Answer optiond

Marks: 2

import javax.swing.*;
/*
<applet code="Demo" width=500 height=500></applet>*/
public class Demo extends Japplet
{
public void init()
2212 {
Jlabel l = new Jlabel("Sample");
add(l);
l.setIcon("images/copy.gif");
}
}

A. Label will be displayed with only image

B. Label will be displayed with only caption

C. Label will be displayed with both image and icon

D. Error will be generated No such method

Answer optionb

Marks: 2

2213 To display output message on applet window which method is used

A. showOutput()

B. showStatus()

C. drawString

D. None of These

Answer optionc

Marks: 2

2214 Which is correct code to get output?

public class Test extends Applet implements KeyListener


{
String msg="";
public void init()
{
addKeyListener(this);
}
public void keyPressed(KeyEvent k)
{
showStatus("KeyPressed");
}
public void keyReleased(KeyEvent k)
A. {
showStatus("KeyRealesed");
}
public void keyTyped(KeyEvent k)
{
msg = msg+k.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, 20, 40);
}
}
public class Test extends Applet implements KeyListener
{
String msg="";
public void init()
{
addKeyListener(this);
}
public void keyPressed(KeyEvent k)
{
}
public void keyReleased(KeyEvent k)
B. {
}
public void keyTyped(KeyEvent k)
{
msg = msg+k.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, 20, 40);
}
}

public class Test extends Applet implements KeyListener


{
String msg="";
public void init()
{
addKeyListener(this);
}

public void keyReleased(KeyEvent k)


{
showStatus("KeyRealesed");
C. }
public void keyTyped(KeyEvent k)
{
msg = msg+k.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, 20, 40);
}
}

public class Test extends Applet implements KeyListener


{
String msg="";
public void init()
{
addKeyListener(this);
}
public void keyPressed(KeyEvent k)
{
showStatus("KeyPressed");
}
public void keyReleased(KeyEvent k)
{
D. msg = "KeyRealesed";
repaint();
}
public void keyTyped(KeyEvent k)
{
msg = msg+k.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, 20, 40);
}
}

Answer optiona

Marks: 2

2215 JButtons generate what type of event?

A. ActionEvent

B. MouseEvent

C. WindowEvent

D. Both ActionEvent & MouseEvent

Answer optiond

Marks: 2

2216 Which of the following type of JDBC driver, is also called Type 3 JDBC driver?

A. JDBC-ODBC bridge plus ODBC driver

B. Native API partly Java Driver

C. JDBC Net pure Java Driver

D. Native Protocol pure java driver


Answer optionc

Marks: 2

2217 Which of the following is used to call stored procedures on the database?

A. Statement

B. PreparedStatement

C. CallableStatement

D. None of These

Answer optionc

Marks: 2

2218 Which of the following manages a list of database drivers in JDBC?

A. DriverManager

B. JDBCDriver

C. Connection

D. Statement

Answer optiona

Marks: 2

2219 What is javax.servlet.Servlet?

A. interface

B. abstract class

C. concrete class

D. None of These

Answer optiona

Marks: 2

2220 Which of the following code is used to get cookies in servlet?

A. response.getCookies()

B. request.getCookies()

C. Cookies.getCookies()

D. None of These

Answer optionb

Marks: 2

import java.awt.*;
import javax.swing.*;

/*
<applet code="SwingExample" width=200 height=200>
</applet>
*/

public class SwingExample extends JApplet{


2221
public void init(){
this.getContentPane().setLayout(new FlowLayout());
JTextField field = new JTextField(20);
Color color = Color.GRAY;
field.setBackground(color);
add(field);
}
}

A. Creates text field with 20 character width

B. Creates textfield with 20 character width and background color gray

C. Gives error cannot set background color to text field

D. Creates textfield with 20 charcater width and set applet background color gray.
Answer optionb

Marks: 2

import java.applet.*;
import java.awt.*;
/*
<applet code="ButtonExample" width=100 height=200>
</applet>
*/

public class ButtonExample extends Applet{


2222 public void init(){
Button Button1 = new Button("Ok");
Button Button2 = new Button("Cancel");
add(Button1);
add(Button2);
Button2.setEnabled(false);
}
}

A. Creates 2 Buttons on Applet. Method setEnabled won't effect

B. Creates 2 Buttons. Button1 is accessible. Button2 is not accessible

C. Gives error setEnabled can't be applied to Button class

D. None of These

Answer optionb

Marks: 2

2223 To create output with given text which code is correct?

public void paint(Graphics g){


Font myFont = new Font("Courier", Font.BOLD,20);
A. g.setFont(myFont);
g.drawString("Bold Font Example", 10, 50);
}

public void paint(Graphics g){


g.drawString("Bold Font Example", 10, 50);
Font myFont = new Font("Courier", Font.BOLD,20);
B. g.setFont(myFont);

public void paint(Graphics g){


g.drawString("Bold Font Example", 10, 50);
C. Font myFont = new Font("Courier", Font.BOLD,20);
g.setFont(myFont);
}

public void paint(Graphics g){


g.drawString("Bold Font Example", 10, 50);
D.
}

Answer optiona

Marks: 2

public class Demo extends Applet


{
public void init()
{
Button N = new Button("NORTH");
Button S = new Button("SOUTH");
Button E = new Button("EAST");
Button W = new Button("WEST");
Button C = new Button("CENTER");
setLayout(new BorderLayout());
2224 setBackground(Color.red);
setForeground(Color.white);
add("North", N);
add("South", S);
add("Center", C);
add("West", W);
add("East", E);
}
}
What will be output after executing this code?

A. S1Q45O1.jpeg

B. S1Q45O2.jpeg

C. S1Q45O3.jpeg

D. S1Q45O4.jpeg

Answer optiona

Marks: 2
2225 Which of the following statements about anonymous inner classes is false?

A. They are declared without name

B. They typically appears in method declartion

C. They are declared with annonymous keyword

D. They can access their top level members

Answer optionc

Marks: 2

import java.awt.*;
import java.applet.*;
public class myapplet extends Applet {
public void paint(Graphics g) {
2226 g.drawString("A Simple Applet", 0, 0);
}
}
What will be displayed in applet window?

A. Blank window

B. Only trailing part of string

C. Error 0,0 coordinates does not exists

D. A simple applet at the center of applet window

Answer optionb

Marks: 2

import java.net.InetAddress;
import java.net.UnknownHostException;

public class GetIP {


public static void main(String[] args) {
InetAddress address = null;
try {
address = InetAddress.getByName
("www.javatutorial.com");
2227 }
catch (UnknownHostException e) {
System.exit(0);
}
System.out.println(address.getHostName());
System.exit(0);
}
}
To display the Host address which method should be used instead of address.getHostName()

A. address.getAddress();

B. address.getHostAddress()

C. address.getIPAddress()

D. address.getIP()

Answer optionb

Marks: 2

2228 Which of the following is used generally used for altering the databases?

A. boolean execute()

B. ResultSet executeQuery()

C. int executeUpdate()

D. None of These

Answer optionc

Marks: 2

PreparedStatement updateemp = con.prepareStatement


2229 ("insert into emp values(?,?,?)");

A. The query can be executed using updateemp.executeUpdate() directly

B. Before executing the query need to set values for ? Using setXXX() methods

C. The query can be executed using updateemp.execute() directly


D. The query can be executed using updateemp.executeQuery() directly

Answer optionb

Marks: 2

String sqlInsert = "insert into books values (3001, 'Gone Fishing', 'Kumar', 11.11, 11)";
int countInserted = stmt.executeUpdate(sqlInsert);
2230 System.out.println(countInserted + " records inserted.\n");
What will be output if I execute the code 2 times ?

A. records inserted

B. 1 records inserted

C. null records inserted

D. 2 records inserted

Answer optionb

Marks: 2

2231 Enumeration paramNames = request.getParameterNames();

A. Reads all parameters of request

B. Reads first parameter of request

C. read last parameter of request

D. None of These

Answer optiona

Marks: 2

2232 Which of the following is not a jsp directive?

A. include

B. page

C. scriplet

D. useBeans

Answer optionc

Marks: 2

2233 out is an instance of which class?

A. javax.servlet.jsp.JspWriter

B. javax.servlet.jsp.PrintWriter

C. javax.servlet.Writer

D. javax.servlet.jsp.jspWriter

Answer optiona

Marks: 2

2234 Removing all the controls from the applet can be achieved by?

A. Using remove( ) method

B. Using removeAll( ) method

C. Using removeAllControls( ) method

D. It is not possible to remove all controls using single method

Answer optionb

Marks: 1

2235 The TreeNode is

A. A class
B. An interface

C. A variable

D. nothing

Answer optionb

Marks: 1

2236 Which of the following style is not supported by Font class?

A. Font.UNDERLINE

B. Font.ITALIC

C. Font.PLAIN

D. Font.BOLD

Answer optiona

Marks: 1

2237 An event is generated when the internal state of the event source is ___________.

A. Not changed

B. Changed

C. Either changed or not.

D. None of these

Answer optionb

Marks: 1

2238 _________is superclass of MouseEvent class.

A. ComponentEvent

B. ContainerEvent

C. ItemEvent

D. InputEvent

Answer optiond

Marks: 1

2239 What is the last part of URL

A. Protcol

B. File Path

C. Port Number

D. Host Name

Answer optionb

Marks: 1

2240 if the calling thread does not have permission to access the specified package then it throws_________________

A. IOException

B. multipleException

C. NullPointerException

D. SecurityException

Answer optiond

Marks: 1

2241 Which of the following method is used to insert data into table?
A. executeQuery()

B. executeInsertQuery()

C. executeUpdate()

D. execute()

Answer optionc

Marks: 1

2242 Which of the following method is not part of servlet life cycle?

A. init()

B. Service()

C. destroy()

D. wait()

Answer optiond

Marks: 1

2243 You want to construct a text area that is 80 character-widths wide and 10 character-heights tall. What code you use?

A. new TextArea(80, 10)

B. new TextArea(10, 80)

C. new TextArea(40, 80)

D. new TextArea(80, 40)

Answer optionb

Marks: 2

2244 How many ports of TCP\IP are reserved for specific protocol.

A. 10

B. 1024

C. 2048

D. 512

Answer optionb

Marks: 2

Suppose that you want to have an object 'eh' to handle the TextEvent of a TextArea object.How should you add eh as the event handler
2245 to it.

A. t.addTextListener(eh)

B. eh.addTextListener(t)

C. addTextListener(eh,t)

D. addTextListener(t,eh)

Answer optiona

Marks: 2

2246 KeyEvent is generated in which sequence.

A. Key typed,pressed,released

B. Key released,typed,pressed

C. Key pressed,typed,released.

D. Key pressed,released,typed

Answer optionc

Marks: 2
2247 Servlet classes specific to your application are placed in which directory on Tomcat Server.

A. /lib/

B. /WEB-INF/classes/

C. /classes/

D. /WEB-INF/lib/

Answer optiond

Marks: 2

Choose the correct ouput for the following program?


import java.awt.*;
import java.applet.*;

public class LayoutDemo extends Applet


{
Button b1,b2,b3,b4;
public void init()
{
b1=new Button("BANANA");
2248 b2=new Button("ORANGE");
b3=new Button("MANGO");
b4=new Button("APPLE");
setLayout(new BorderLayout());
add(b1,BorderLayout.EAST);
add(b2,BorderLayout.SOUTH);
add(b3,BorderLayout.NORTH);
add(b4,BorderLayout.WEST);
}
}

A. S1Q42O1.jpeg

B. S1Q42O2.jpeg

C. S1Q42O3.jpeg

D. None of above

Answer optiona

Marks: 2

Observe the following program and point out which statement contains error.

impor tjava.awt.*;
import javax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTableDemo extends JApplet
{
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] colHeads = { "emp_Name", "emp_id", "emp_salary" };
2249 final Object[][] data = {
{ "Ramesh", "111", "50000" },
{ "Sagar", "222", "52000" },
{ "Virag", "333", "40000" },
{ "Amit", "444", "62000" },
{ "Anil", "555", "60000" },
};
JTable table = new JTable(data,colHeads );
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPanejsp = new JScrollPane(table,,h,v);
contentPane.add(jsp, BorderLayout.CENTER);
}
}

A. Error in statement in which JTable is created

B. Error in statement in which JScrollPane is created

C. Error in statement in which applet tag is declared

D. None of the above

Answer optionb

Marks: 2
Select the missing statement in the program to get the following output

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
/*
<applet code="JTreeEvents" width=400 height=200>
</applet>
*/
public class JTreeEvents extends JApplet
{
JTree tree;
JTextField jtf;
public void init()
{
Container contentPane=getContentPane();
contentPane.setLayout(new BorderLayout());
DefaultMutableTreeNode top=new DefaultMutableTreeNode("Options");
DefaultMutableTreeNode a=new DefaultMutableTreeNode("A");
top.add(a);
DefaultMutableTreeNode a1=new DefaultMutableTreeNode("A1");
a.add(a1);
DefaultMutableTreeNode a2=new DefaultMutableTreeNode("A2");
DefaultMutableTreeNode b=new DefaultMutableTreeNode("B");
top.add(b);
DefaultMutableTreeNode b1=new DefaultMutableTreeNode("B1");
b.add(b1);
DefaultMutableTreeNode b2=new DefaultMutableTreeNode("B2");
2250
b.add(b2);
DefaultMutableTreeNode b3=new DefaultMutableTreeNode("B3");
b.add(b3);
tree=new JTree(top);
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(tree,v,h);
contentPane.add(jsp,BorderLayout.CENTER);
jtf=new JTextField("",20);
contentPane.add(jtf,BorderLayout.SOUTH);
tree.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent me)
{
doMouseClicked(me);
}
});
}
void doMouseClicked(MouseEvent me)
{
TreePath tp=tree.getPathForLocation(me.getX(),me.getY());
if(tp!=null)
jtf.setText(tp.toString());
else
jtf.setText("");

}
}

A. a.add(a2);

B. top.add(a2);

C. a1.add(a2);

D. a.add(a1);

Answer optiona

Marks: 2

2251 Identify the correct code for following output.

import java.awt.*;
public class MenuDemo extends Applet
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
Menu filemenu = new Menu("File");
A. Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
mbr.add(viewmenu);
CheckboxMenuItem new1 = new CheckboxMenuItem("New");
CheckboxMenuItem open1 = new CheckboxMenuItem("Open",true);
filemenu.add(new1);
filemenu.add(open1);
}
}
import java.awt.*;
public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
Menu filemenu = new Menu("File");
B. Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
mbr.add(viewmenu);
CheckboxMenuItem new1 = new CheckboxMenuItem("New");
CheckboxMenuItem open1 = new CheckboxMenuItem("Open",true);
filemenu.add(new1);
filemenu.add(open1);
}
}

import java.awt.*;
public class MenuDemo extends Applet
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
Menu filemenu = new Menu("File");
C. Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
mbr.add(viewmenu);
MenuItem new1 = new MenuItem("New");
MenuItem open1 = new MenuItem("Open",true);
filemenu.add(new1);
filemenu.add(open1);
}
}

import java.awt.*;
public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
Menu filemenu = new Menu("File");
D. Menu editmenu = new Menu("Edit");
Menu viewmenu = new Menu("View");
mbr.add(filemenu);
mbr.add(editmenu);
mbr.add(viewmenu);
MenuItem new1 = new MenuItem("New");
MenuItem open1 = new MenuItem("Open",true);
filemenu.add(new1);
filemenu.add(open1);
}
}

Answer optionb

Marks: 2

2252 Identify the correct code for following output.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ComboDemo extends JApplet implements ActionListener


{
JTextField jtf;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
jtf=new JTextField(20);
JComboBox jc=new JComboBox();
jc.addItem("BLUE");
jc.addItem("RED");
A. jc.addItem("GREEN");
jc.addItem("YELLOW");
jc.addItem("PINK");
jc.addItemListener(this);
c.add(jtf);
c.add(jc);
}

public void itemStateChanged(ItemEvent ie)


{
String s =(String)ie.getItem();
jtf.setText("Selected Color:"+s);
}

}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ComboDemo extends JApplet implements ItemListener


{
JTextField jtf;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
jtf=new JTextField(20);
JComboBox jc=new JComboBox();
jc.add("BLUE");
jc.add("RED");
B. jc.add("GREEN");
jc.add("YELLOW");
jc.add("PINK");
jc.addItemListener(this);
c.add(jtf);
c.add(jc);
}

public void itemStateChanged(ItemEvent ie)


{
String s =(String)ie.getItem();
jtf.setText("Selected Color:"+s);
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ComboDemo extends JApplet implements ItemListener


{
JTextField jtf;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
jtf=new JTextField(20);
JComboBox jc=new JComboBox();
jc.addItem("BLUE");
jc.addItem("RED");
C. jc.addItem("GREEN");
jc.addItem("YELLOW");
jc.addItem("PINK");
jc.addItemListener(this);
c.add(jtf);
}

public void itemStateChanged(ItemEvent ie)


{
String s =(String)ie.getItem();
jtf.setText("Selected Color:"+s);
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ComboDemo extends JApplet implements ItemListener


{
JTextField jtf;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
jtf=new JTextField(20);
JComboBox jc=new JComboBox();
jc.addItem("BLUE");
jc.addItem("RED");
D. jc.addItem("GREEN");
jc.addItem("YELLOW");
jc.addItem("PINK");
jc.addItemListener(this);
c.add(jtf);
c.add(jc);
}

public void itemStateChanged(ItemEvent ie)


{
String s =(String)ie.getItem();
jtf.setText("Selected Color:"+s);
}

Answer optiond

Marks: 2
For the following code select the appropriate method to fill in given blank space.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class ButtonDemo extends Applet implements ActionListener
{
String msg="";
Button add,modify,delete;
public void init()
{
add=new Button("ADD");
modify=new Button("MODIFY");
delete=new Button("delete");

add(add);
add(modify);
add(delete);
add.addActionListener(this);
modify.addActionListener(this);
delete.addActionListener(this);
}

2253 public void actionPerformed(ActionEvent ae)


{
String str=ae._____________________;
if(str.equals("ADD"))
{
msg="You pressed ADD button";

}
else if(str.equals("MODIFY"))
{
msg="You pressed MODIFY button";
}
else
{
msg="You pressed DELETE button";
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, 6, 100);
}
}

A. getCommand()

B. getAction()

C. getActionCommand()

D. ObtainAction()

Answer optionc

Marks: 2

Select the missing statement in the program to get the following output.
import java.sql.*;
class Demo1
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:student"," "," ");
int r1=11;
2254 String s1="suhas";
String str="insert into studTable values(?,?);
PreparedStatement ps=c.prepareStatement(str);
ps.setInt(1,r1);
ps.executeUpdate();
System.out.println("Data inserted:");
s.close();
c.close();
}
}

A. ps.setString(2,s1);

B. ps.setInt(2,s1);

C. c.setString(2,s1);

D. ps.setInt(1,s2);

Answer optiona

Marks: 2
Consider the following program.Find which statement contains error.
import java.io.*;
class Demp1
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:student"," "," ");
2255 String str="insert into studTable values(11,'ramesh');
Statement s=c.createStatement(str);
s.executeUpdate();
System.out.println("Data inserted:");
s.executeUpdate();
s.close();
c.close();
}
}

A. Error in connection statement

B. Error in insert query

C. Error in package

D. Error in close()

Answer optionc

Marks: 2

Select the proper code for the problem statement given below:
2256 Problem statement:
Develop a program to change the name of student to "suhas" where rollNo=1 in the table studTable.

import java.sql.*;
import java.io.*;
public class updatedemo
{
public static void main(String[] args)
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try
{
Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
System.out.println("driver loaded");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
A. System.out.println("Conncetion Created");
String s1="update studTable set name='sneha' where rollNo=1";
PreparedStatement p1=con.prepareStatement(s1);
p1.executeUpdate();
System.out.println("updated table");
p1.close();
con.close();
}
catch(Exception e)
{

}
}
}

import java.sql.*;
import java.io.*;
public class updatedemo
{
public static void main(String[] args)
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("driver loaded");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
B. System.out.println("Conncetion Created");
String s1="update studTable set name='sneha' where rollNo=1";
PreparedStatement p1=con.prepareStatement(s1);
p1.executeUpdate();
System.out.println("updated table");
p1.close();
con.close();
}
catch(Exception e)
{

}
}
}
import java.sql.*;
import java.io.*;
public class updatedemo
{
public static void main(String[] args)
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("driver loaded");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
C. System.out.println("Conncetion Created");
String s1="update table studTable set name='sneha' where rollNo=1";
PreparedStatement p1=con.prepareStatement(s1);
p1.executeUpdate();
System.out.println("updated table");
p1.close();
con.close();
}
catch(Exception e)
{

}
}
}

import java.sql.*;
import java.io.*;
public class updatedemo
{
public static void main(String[] args)
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("driver loaded");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
D. System.out.println("Conncetion Created");
String s1="update studTable set name='sneha' where rollNo=1";
PreparedStatement p1=con.prepareStatement(s1);
p1.execute();
System.out.println("updated table");
p1.close();
con.close();
}
catch(Exception e)
{

}
}
}

Answer optiona

Marks: 2

For the following code identify the correct syntax of service () method of servlet class.

import java.io.*;
import javax.servlet.*;
public class HelloServlet extends GenericServlet
{
public void service(___________________)throws ServletException, IOException
2257 {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello");
pw.close();
}
}

A. void service(ServletRequest req,ServletResponse res)

B. void service(ServletResponse res,ServletRequest req)

C. void service(ServletResponse req,ServletResponse res)

D. void service(ServletRequest req,ServletRequest res)

Answer optiona

Marks: 2
Consider the following program. Identify which statement contains error.

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class FactorialServlet extends HttpServlet
{
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
int fact=1;
2258 int f1 = res.getParameter("number");
int num=Integer.parseInt(f1);
res.setContentType("text/html");
PrintWriter out = res.getWriter();
for(int i=1;i<=num;i++)
{
fact=fact*i;
}
out.println("The factorial of number is");
out.println(fact);
out.close();
}
}

A. Error in package

B. Error in doGet() method

C. Error in for loop

D. Error in getParameter() method return value of request parameter.

Answer optiond

Marks: 2

Assume that you need to write a JSP page that adds numbers from one to ten and then print the output.

<% int sum=0;


for(int i=1;i<=10;i++) { %>
2259 <%sum=sum+i; %>
<% } %>
YYY
Which statement must be added at the location of YYY to print the sum of ten numbers.

A. <% sum %>

B. <% sum; %>

C. <%=sum %>

D. <%=sum; %>

Answer optionc

Marks: 2

2260 . A frame�s __________ designates the area of the frame excluding the title, menu bar, and the border

A. ContentPane

B. actionListener

C. EventListener

D. layout manager

Answer optiona

Marks: 1

2261 Which of these methods cannot be called on JLabel object?

A. setIcon()

B. getText()

C. setLabel()

D. setBorderLayout()

Answer optiond

Marks: 1

2262 What is the immediate super class of Applet class?

A. object
B. panel

C. window

D. component

Answer optionb

Marks: 1

2263 Which is a component in AWT that can contain another components like buttons, textfields, labels etc.?

A. Window

B. Container

C. Panel

D. Frame

Answer optionb

Marks: 1

2264 Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram?

A. getData()

B. getBytes()

C. ) getArray()

D. recieveBytes()

Answer optiona

Marks: 1

2265 Permission objects are immutable

A. TRUE

B. FALSE

C.

D.

Answer optiona

Marks: 1

2266 Which of the following are class? 1.ServletContext 2.Servlet 3.GenericServlet 4.HttpServlet

A. 1,2,3,4

B. 1,2

C. 3,4

D. 1,4

Answer optionc

Marks: 1

2267 When doFilter() method of servlet gets called?

A. The doFilter() method is called when the filter first created

B. The doFilter() method is called whenever the servlet being filtered is invoked

C. Both of above

D. None of above

Answer optionb

Marks: 1

2268 Which of the following code is used to delete an attribute from a HTTP Session object in servlets?
A. sessin.removeAttribute(Name)

B. sessin.alterAttribute(Name)

C. sessin.updateAttribute(Name)

D. None of above

Answer optiona

Marks: 1

2269 Which Layout is used in the following output?

A. BorderLayout

B. FlowLayout

C. GridLayout

D. GridBagLyout

Answer optiona

Marks: 2

2270 What class represents the size of a component?

A. Dimension

B. Size

C. Component

D. Control

Answer optiona

Marks: 2

2271 What class provides methods for creating and displaying basic dialog boxes?

A. Jwindow

B. Jframe

C. Jcomponent

D. JOptionPane

Answer optiond

Marks: 2

2272 You can create a JList using __________.

A. new JList()

B. new JList(new String[]{"red", "green", "blue"})

C. new JList(new Vector())

D. � new JList(new DefaultListModel());

Answer optiona

Marks: 2

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

A. DatagramPacket

B. URL

C. InetAddress

D. ContentHandler

Answer optionc

Marks: 2
2274 Select the proper method to retrieve the host name of local machine

A. static InetAddressgetLocalHost( )throws UnknownHostException

B. static InetAddressgetByName(String hostName)throws UnknownHostException

C. static InetAddress[ ] getAllByName(String hostname throws UnknownHostException

D. string getHostAddress()

Answer optiona

Marks: 2

2275 Which of the following is a following statement is a prepared statements ?

A. Insert into department values(?,?,?)

B. � Insert into department values(x,x,x).

C. SQLSetConnectOption(conn, SQL AUTOCOMMIT, 0)

D. SQLTransact(conn, SQL ROLLBACK)

Answer optiona

Marks: 2

2276 Which of the following header must be included in java program to establish database connectivity using JDBC ?

A. � Import java.sql.*;

B. Import java.sql.odbc.jdbc.*;

C. Import java.jdbc.*

D. Import java.sql.jdbc.*;

Answer optiona

Marks: 2

2277 Which of the following is used to access large objects from a database ?

A. setBlob()

B. � getBlob()

C. getClob()

D. All of the mentioned

Answer optiond

Marks: 2

2278 What are the mechanisms available in ServletContextListener interface?

A. contextInit(), contextService(), contextDestroyed()

B. contextInitialized((),contextDestroyed()

C. contextInitialized(), contextService(), contextDestroyed()

D. None of the above

Answer optionb

Marks: 2
2. Consider the following program. Find which statement contains error.

importjava.awt.*;
importjavax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTableDemo extends JApplet
{
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] colHeads = { "emp_Name", "emp_id", "emp_salary" };
2279 final Object[][] data = {
{ "Ramesh", "111", "50000" },
{ "Sagar", "222", "52000" },
{ "Virag", "333", "40000" },
{ "Amit", "444", "62000" },
{ "Anil", "555", "60000" },
};
JTable table = new JTable(data);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPanejsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}

A. A.� � � � � Error in statement in which JTable is created

B. A.� � � � � Error in statement in which JScrollPane is created

C. A.� � � � � Error in statement in which applet tag is declared

D. A.� � � � � None of the above

Answer optiona

Marks: 2

2280 What is a listener in context to event handling?

A. A listener is a variable that is notified when an event occurs.

B. A listener is a object that is notified when an event occurs.

C. A listener is a method that is notified when an event occurs

D. None of above

Answer optionb

Marks: 2

2281 Which of these methods are used to register a keyboard event listener?

A. KeyListener()

B. addKistener()

C. addKeyListener()

D. eventKeyboardListener()

Answer optionc

Marks: 2

2282 What is the return type of getAddress() method of DatagramPacket class?

A. DatagramPacket

B. DatagramSocket

C. InetAddress

D. ServerSocket

Answer optionc

Marks: 2

2283 Which JDBC driver Type(s) can you use in a three tier architecture and if the web server and the DBMS are running on the same machine

A. Type-1

B. Type-2

C. Type3 and 4
D. All of above

Answer optiond

Marks: 2

2. 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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
2284 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();
}
}

A. Missing Semicolon

B. Mising {

C. Mising }

D. Missing Statement

Answer optiond

Marks: 2

4. 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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
2285 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();
}
}

A. Missing Semicolon

B. Missing {

C. Missing }

D. Missing package statement

Answer optiond

Marks: 2

2286 The getSession() method with 'true' as its parameter [ getSession(true) ] it will return the appropriate session object when

A. he session is completed

B. the session object is passed to another method

C. the session does not exists

D. he session is existing

Answer optiond

Marks: 2

2287 Dynamic interception of requests and responses to transform the information is done by

A. servlet container

B. servlet config

C. servlet context
D. servlet filter

Answer optiond

Marks: 1

2288 Which Container method is used to cause a container to be laid out and redisplayed?

A. setValidate()

B. redisplay()

C. validate( )

D. setRedisplay()

Answer optionc

Marks: 1

2289 Which of the following methods are invoked by the AWT to support paint and repaint operations?

A. paint( )

B. repaint( )

C. draw( )

D. draw( )

Answer optiona

Marks: 1

2290 Which of these interfaces define four methods?

A. ComponentListener

B. ContainerListener

C. ActionListener

D. InputListener

Answer optiona

Marks: 1

2291 Which of these are constants defined in WindowEvent class?

A. WINDOW_ACTIVATED

B. WINDOW_CLOSED

C. WINDOW_DEICONIFIED

D. All of the mentioned

Answer optiond

Marks: 1

2292 A set of rules that governs data communication

A. protocol

B. Standards

C. RFCs

D. Functions

Answer optiona

Marks: 1

2293 _______ method returns true if this object has the same Internet address as other.

A. boolean equals(Object other)

B. boolean isequals(Object other)


C. boolean equals()

D. None of these

Answer optiona

Marks: 1

2294 Java.Net package consist of interface

A. ContentHandlerFactory

B. SocketImplfactory

C. SocketOption

D. All of these

Answer optiond

Marks: 1

2295 API stands for

A. application project interface

B. application programming interface

C. all the above

D. none of the above

Answer optionb

Marks: 1

In the following JDBC drivers which


2296 is known as partially java driver?

JDBC-ODBC
A. bridge driver

Native-API
B. driver

Network
C. Protocol
driver

D. Thin driver

Answer optionb

Marks: 1

2297 what is servlet

A. it is server side program written in java

B. it is client side program

C. both a & b

D. none of the above

Answer optiona

Marks: 1

2298 which are the servlet life cycle method

A. init(),

B. destroy()

C. service(),

D. all the above

Answer optiond

Marks: 1

2299 A deployment descriptor describes


A. web component response settings

B. web component settings

C. web component request objects

D. All of the above

Answer optionb

Marks: 1

Suppose a Panel is added to a Frame and a Button is added to the Panel If the Frame's font is set to 12-point TimesRoman, the Panel's
2300 font is set to 10-point TimesRoman, and the Button's font is not set, what font will be used to dispaly the Button's label?

A. 12-point TimesRoman

B. 11-point TimesRoman

C. 10-point TimesRoman

D. 9-point TimesRoman

Answer optionc

Marks: 2

2301 If a progam consist of three classes,then after comilation how many class file (s) is are created by compiler

A. Asingle

B. Three

C. Uncountable

D. Zero

Answer optionb

Marks: 2

2302 Java does not support multiple inheritance,some of the ability of multiple inheritance are available

A. Implementing interface

B. Creating aliases

C. importing classes

D. Using public rather than protected or private modifier

Answer optiona

Marks: 2

2303 ������� methods will be invoked if a character is entered

A. keyPressed()

B. keyReleased()

C. keyTyped()

D. keyEntered()

Answer optionc

Marks: 2

2304 The constructor which is used to create client socket is ____________

A. Socket(Inet Address, IP Address, int port)

B. ServerSocket(int port)

C. ServerSocket(int port, int maxQueue)

D. Socket()

Answer optiona

Marks: 2
2305 __________ methods return currently installed policy handler

A. public policy getPolicy()

B. Public static Policy GetPOLICY()

C. public Policy Policy()

D. public static Policy getPolicy()

Answer optiond

Marks: 2

2306 class is necessary to implement datagram

A. DatagramPacket

B. DatagramSocket

C. Both of above

D. None of above

Answer optionc

Marks: 2

2307 in which layer two tier model are divided into two parts

A. application layer & session layer

B. application layer & presentation layer

C. application layer &database layer

D. all the above

Answer optionc

Marks: 2

2308 What are types of JDBC driver?

A. JDBC-ODBC bridge

B. JDBC native API

C. pure java JDBC network

D. all the above

Answer optiona

Marks: 2

2309 Which is correct syntax of add cookie method

A. request.addCookie(C1);

B. cookiename.addCookie();

C. cookienameaddcookie();

D. all the above

Answer optiona

Marks: 2

Given the following code, what is the effect of a being 5? public class Test
{ public void add(int a)
{
loop: for (int i = 1; i < 3; i++)
2310 { for (int j = 1; j < 3; j++) { if (a == 5)
{
break loop;}
Systemoutprintln(i * j);}}}}

A. Generate a runtime error

B. B Throw an ArrayIndexOutOfBoundsException

C. Print the values: 1, 2, 2, 4


D. Produces no output

Answer optiond

Marks: 2

What does the following code draw? g.setColor(Color.black);


g.drawLine(10, 10, 10,50);
2311 g.setColor(ColorRED);
g.drawRect(100, 100, 150, 150);

A. A red vertical line that is 40 pixels long and a red square with sides of 150 pixels

B. A black vertical line that is 40 pixels long and a red square with sides of 150 pixels

C. A black vertical line that is 150 pixels long and a red square with sides of 150 pixels

D. A red vertical line that is 50 pixels long and a red square with sides of 150 pixels

Answer optionb

Marks: 2

2312 Which of these methods is defined in MouseMotionAdapter class?

A. mouseDragged()

B. mousePressed()

C. mouseReleased()

D. mouseClicked()

Answer optiona

Marks: 2

2313 To handle mouse events, you must implement the ------------------

MouseListner interface
A.

B. The MouseClickListner

C. The MouseRotateListner

D. The ActiomListner interface

Answer optiona

Marks: 2

2314 The constructor that defines by the text event class is:

A. TextEvent(Object source,int event_type)

B. textevent (Object source,int event_type)

C. textevent(object source,float event_type)

D. d)textevent(Object source,string_type)

Answer optionb

Marks: 2

2315 Till now two models have been introduced in java for:

A. Receiving and processing events

B. Deleting and Processing events

C. Receiving and Deleting

D. Modifying and Rceiving

Answer optiona

Marks: 2

2316 which are the syntax of close() method in conection interface methode

A. conectionclose();
B. closeconection()

C. close()

D. all the above

Answer optiona

Marks: 2

What programming language(s) or


scripting language(s)
2317 does Java Server Pages
(JSP) support?

A. VBScript only

B. Jscript only

C. Java only

All of the
D. above
are supported

Answer optionc

Marks: 2

The method getWriter returns an object of type PrintWriter


This class has println methods to generate output
2318 Which of these classes define the getWriter method?
Select the one correct answer

A. HttpServletRequest

B. HttpServletResponse

C. ServletConfig

D. ServletContext

Answer optionb

Marks: 2

When using HTML forms which of the following


2319 is true for POST method? Select the one
correct answer

A. POST allows users to bookmark URLs with parameters

B. The POST method should not be used when large amount of data needs to be transferred

C. POST allows secure data transmission over the http method

D. POST method sends data in the body of the request

Answer optiond

Marks: 2

A user types the URL


http://wwwjavapreparecom/scwd/indexhtml
2320 Which HTTP request gets generated
Select the one correct answer

A. GET method

B. POST method

C. HEAD method

D. PUT method

Answer optiona

Marks: 2

Choose correct ansewrs


1 Servlet is a Java technology based Web component
2321 2 Servlet servlets are platform-independent
3 Servlet has run on Web server which has a containers
4 Servlets interact with Web clients via a request/response using HTTP protocol

A. 1,2,3,4
B. 1,2,3

C. 1,3,4

D. None

Answer optiona

Marks: 2

2322 The following specifies the advantages of 1) It is lightweight. 2) It supports pluggable look and feel.

A. Swing

B. AWT

C. Both A & B

D. None of the above

Answer optiona

Marks: 1

2323 To add a component we have to use

A. include()

B. add()

C. register()

D. insert()

Answer optionb

Marks: 1

2324 Which class can be used to represent a checkbox with a textual label that can appear in a menu

A. MenuBar

B. MenuItem

C. CheckboxMenuItem

D. CheckBox

Answer optionc

Marks: 1

The Following steps are required to perform 1) Implement the Listener interface and overrides its methods
2325 2) Register the component with the Listener

A. Exception Handling

B. String Handling

C. Event Handling

D. None of the above

Answer optionc

Marks: 1

2326 What is an event in delegation event model used by Java programming language?

A. An event is an object that describes a state change in a source.

B. An event is an object that describes a state change in processing.

C. An event is an object that describes any change by the user and system.

D. An event is a class used for defining object, to create events.

Answer optiona

Marks: 1

2327 Which of these events will be notified if scroll bar is manipulated?


A. ActionEvent

B. ComponentEvent

C. AdjustmentEvent

D. WindowEvent

Answer optionc

Marks: 1

______ object is responsible for determining whether code executing in the java runtime environment has permission to perform
2328 security sensetive operation.

A. Policy

B. AccessControl

C. Authentication

D. None of the above

Answer optiona

Marks: 1

2329 Which of these method returns the size in bytes of the content associated with the resource?

A. getExpiration( )

B. getContentLength( )

C. getContentType()

D. GetContentType()

Answer optionb

Marks: 1

2330 Whiche of these methods of DatagramSocket returns the number of the local port?

A. getLocalPort( )

B. getInetAddress( )

C. GetPort()

D. getPort( )

Answer optiona

Marks: 1

2331 Which of the following is not a component/class of JDBC API?

A. Statement

B. ResultSet

C. SQLException

D. ConnectionPool

Answer optiond

Marks: 1

2332 If user wants to deal with database stroed procedure then which interface is used?

A. Statement

B. PreparedStatement

C. CallableStatement

D. All of the mentioned

Answer optionc

Marks: 1
2333 A _________ is stored on a client and contains state information.

A. session attributes

B. URL

C. Servlets

D. cookie

Answer optiond

Marks: 1

2334 The _______________ interface enables a servle t to obtain information about a client request.

A. HttpServletRequest

B. HttpServletResponse

C. HttpServletSession

D. HttpSessionBinding

Answer optiona

Marks: 1

2335 ___________ implements the Servlet and ServletConfig interfaces.

A. HttpServlet

B. GenericServlet

C. HttpServletSession

D. HttpServletResponse

Answer optionb

Marks: 1

2336 ______________ interface allows servlets to get initialization parameters.

A. Servlet

B. ServletConfig

C. ServletRequest

D. ServletContext

Answer optionb

Marks: 1

These four methods commonly used in?


1)public void add(Component c)
2337 2)public void setSize(int width,int height)
3)public void setLayout(LayoutManager m)
4)public void setVisible(boolean)

A. Graphics class

B. Component class

C. Both A & B

D. None of the above

Answer optionb

Marks: 2

2338 In Graphics class Which method is used to set the graphics current color to the specified color?

public abstract void setFont(Font font)


A.

B. public abstract void setColor(Color c)

C. public abstract void drawString(String str, int x, int y)

D. None of the above


Answer optionb

Marks: 2

2339 By which method You can set or change the text in a Label?

A. setText()

B. getText()

C. Both A & B

D. None of the above

Answer optiona

Marks: 2

2340 When the key is released, a ____________event is generated.

A. KEY_TYPED

B. KEY_RELEASED

C. KEY_PRESSED

D. All of the mentioned

Answer optionb

Marks: 2

2341 Select the correct syntax of adjustmentValueChanged( ) method.

A. void adjustmentvaluechanged(AdjustmentEvent ae)

B. void adjustmentValueChanged(AdjustmentEvent ae)

C. String adjustmentvalueChanged(AdjustmentEvent ae)

D. int adjustmentValueChanged(AdjustmentEvent ae)

Answer optionb

Marks: 2

2342 The Java HttpURLConnection class is http specific URLConnection. It works for HTTP protocol only.

A. True

B. False

C.

D.

Answer optiona

Marks: 2

2343 Identify the factory methods of InetAddress Class:

static InetAddress[ ] getAllByName(String hostName)


A. throws UnknownHostException

static InetAddress getByName(String hostName)


B. throws UnknownHostException

static InetAddress getLocalHost( )


C. throws UnknownHostException

D. All of the mentioned

Answer optiond

Marks: 2

Which of the following type of JDBC driver should be used when you are accessing one type of database, such as Oracle, Sybase, or
2344 IBM?

A. Type 1

B. Type 2
C. Type 3

D. Type 4

Answer optiond

Marks: 2

2345 Identify the method which does not defined by HttpServletRequest.

A. Cookie[ ] getCookies( )

B. String getHeader(String field)

String getPathInfo( )
C.

D. void sendError(int c) throws IOException

Answer optiond

Marks: 2

2346 Identify the method which does not defined by HttpServletResponse.

A. void addCookie(Cookie cookie)

B. String encodeURL(String url)

C. HttpSession getSession( )

D. void setHeader(String field, String value)

Answer optionc

Marks: 2

2347 Identify the methods which is defined by Cookie.

A. String getPath( )

B. boolean getValue( )

C. void getName()

D. All of the mentioned

Answer optiond

Marks: 2

Write the correct statement:


/*
<applet code="ShowFonts" width=550 height=60>
</applet>
*/
import java.applet.*;
import java.awt.*;
public class ShowFonts extends Applet {
public void paint(Graphics g) {
2348 String msg = "";
String FontList[];
GraphicsEnvironment ge =
GraphicsEnvironment.____________________;
FontList = ge.getAvailableFontFamilyNames();
for(int i = 0; i < FontList.length; i++)
msg += FontList[i] + " ";
g.drawString(msg, 4, 16);
}
}

A. getLOCALEnvironment()

B. getLocalEnvironment()

C. getLocalGraphicsEnvironment()

D. getLocalGraphicsEnvironment()

Answer optionc

Marks: 2

Which control does defined the following methods?


void append(String str)
2349 void insert(String str, int index)
void replaceRange(String str, int startIndex, int endIndex)
A. Button

B. TextField

C. TextArea

D. Textarea

Answer optionc

Marks: 2

2350 Identify the correct code for following output:

import java.awt.*;
import java.applet.*;
/*
<applet code="GridLayoutDemo" width=300 height=200>
</applet>
*/
public class GridLayoutDemo extend Applet {
static final int n = 4;
public void init() {
setLayout(new GRIDLayout(n, n));
A. setFont(new Font("SansSerif", Font.BOLD, 24));
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
int k = i * n + j;
if(k > 0)
add(new Button("" + k));
}
}
}
}

import java.awt.*;
import java.applet.*;
/*
<applet code="GridLayoutDemo" width=300 height=200>
</applet>
*/
public class GridLayoutDemo extends Applet {
static final int n = 4;
public void init() {
setLayout(new GridLayout(n, n));
B. setFont(NEW Font("SansSerif", FONT.BOLD, 24));
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
int k = i * n + j;
if(k > 0)
add(new Button("" + k));
}
}
}
}

import java.awt.*;
import java.applet.*;
/*
<applet code="GridLayoutDemo" width=300 height=200>
</applet>
*/
public class GridLayoutDemo {
static final int n = 4;
public void init() {
setLayout(new GridLayout(n, n));
C. setFont(new Font("SansSerif", Font.BOLD, 24));
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
int k = i * n + j;
if(k > 0)
add(new Button("" + k));
}
}
}
}

import java.awt.*;
import java.applet.*;
/*
<applet code="GridLayoutDemo" width=300 height=200>
</applet>
*/
public class GridLayoutDemo extends Applet {
static final int n = 4;
public void init() {
setLayout(new GridLayout(n, n));
D. setFont(new Font("SansSerif", Font.BOLD, 24));
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
int k = i * n + j;
if(k > 0)
add(new Button("" + k));
}
}
}
}

Answer optionb

Marks: 2
Write correct method in blank space:
public void init()
{
yes = new Button("Yes");
no = new Button("No");
maybe = new Button("Undecided");
2351 add(yes);
add(no);
add(maybe);
yes._____________(this);
no.______________ (this);
maybe.________________(this);
}

A. addItemListener

B. addActionListener

C. addactionlistner

D. AddActionListner

Answer optionb

Marks: 2

1. Select correct Adapter class from given option for ******.


import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code="adapterdemo" width=300 height=100>
</applet>
*/
public class adapterdemo extends Applet
{
public void init()
2352 {
addMouseListener(new A());
}

class A extends *********


{
public void mousePressed(MouseEvent me)
{
showStatus("Mouse Pressed ");
}
}
}

A. MouseMotionAdapter

B. MouseAdapter

C. KeyListener

D. All

Answer optionb

Marks: 2

Identify the correct parameter for following method:

2353 Socket(String ___________, int port)


throws UnknownHostException,
IOException

A. port address

B. hostName

C. protocol

D. Actual file path

Answer optionb

Marks: 2

2354 After loaded the driver, user can establish the connection using_______ method.

A. getConnection(String url)

B. getConnection(String url, Properties prop)

C. getConnection(String url, String user, String password)

D. All of the above

Answer optiond
Marks: 2

Filling the correct statement:


import java.sql.*;
public class createT
{
public static void main(String a[])
{
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String url="jdbc:odbc:java";
Connection con=DriverManager.getConnection(url);
System.out.println(" Connection to DataBase created");
Statement stmt=con.createStatement();
String query = "create table employee1(emp_id int,emp_name char)";
2355 PreparedStatement ps = con.prepareStatement(query)
__________________________________
System.out.println("table created");
ps.close();
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}

}
}

A. ps.executeUpdate();

B. ps.executeQuery();

C. ps.Update()

D. ps.EXECUTEUPDATE()

Answer optiona

Marks: 2

Fill the correct data in following part of the code: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


2356 Connection con=_______________________("jdbc:odbc:mydsn");
Statement stmt=con.createStatement();

A. DriverManager.getStatement

B. DriverManager.getConnection

C. DriverManager.setConnection

D. DriverManager.Connection

Answer optionb

Marks: 2

2. In following Java program fill statement showing ******.Select any one option from given options

import java.io.*;
import java.util.*;
import javax.servlet.*;

public class PostParametersServlet


extends GenericServlet {
public void service(ServletRequest request,
ServletResponse response)
throws ServletException, IOException {
// Get print writer.
PrintWriter pw = response.getWriter();
2357 3. SOFTWARE DEVELOPMENT
4. USING JAV// Get enumeration of parameter names
a) Enumeration e = request.getParameterNames();
;
// Display parameter names and values.
while(e.hasMoreElements()) {
String pname = (String)e.nextElement();
pw.print(pname + " = ");
String pvalue = *******;
pw.println(pvalue);
}
pw.close();
}
}

A. request.getParameterName(pname)

B. request.GetParametername(pname)

C. Request.GetparameterName(pname)
D. request.getParametername(pname)

Answer optiona

Marks: 2

4. Consider the following program. Identify the missing word ****.


<html>
<body>
<center>
<form name="Form1"
action="http://****/examples/servlet/ColorGetServlet">
<B>Color:</B>
<select name="color" size="1">
2358 <option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
</select>
<br><br>
<input type=submit value="Submit">
</form>
</body>
</html>

A. localhost:8080

B. localhost:0808

C. locallhost:8080

D. localhost:80800

Answer optiona

Marks: 2

2359 Which of the following is the method of label class?

A. public void getText()

B. public String getText()

C. public void setLabel(String Label)

D. public String getLabel()

Answer optionb

Marks: 1

2360 TextComponent is subclass of ______________ class.

A. container

B. window

C. component

D. none of these

Answer optionc

Marks: 1

2361 Which of the components exist in dual state?

A. TextField

B. TextArea

C. Checkbox

D. Label

Answer optionc

Marks: 1

2362 Which is the window that does not contain a title bar, menu bar or borders.

A. panel

B. container

C. frame
D. none of these

Answer optiona

Marks: 1

2363 ______________ automatically arranges your controls within a window using some type of algorithm.

A. JVM

B. Layout Manager

C. Java Tools

D. none of these

Answer optionb

Marks: 1

2364 If mode of dialog box is true then the dialog box is of _______ type.

A. Modal

B. Modaless

C. Active

D. none of these

Answer optiona

Marks: 1

2365 Which of the following is fileDialog class constructor?

A. public Filedialog()

B. public FileDialog(String BoxName)

C. public FileDialog(Frame parent)

D. public FileDialog(Frame parent, String BoxName)

Answer optiond

Marks: 1

2366 Which of the following is not a constructor of radio button?

A. public JRadioButton(boolean state,Icon i,String str)

B. public JRadioButton(Icon i)

C. public JRadioButton(Icon i, String str)

D. public jRadioButton(Icon i, boolean state)

Answer optionc

Marks: 1

2367 The_____interface is used to handle the menu event

A. ContainerListener

B. ActionListener

C. FocusListener

D. WindowListener

Answer optionb

Marks: 1

2368 Identify the correct syntax of Socket Class constructor

Socket(int port,String hostName)


A.

B. Socket(String hostName, int port)


C. Socket(int HostName, InetAddress ip)

D. Socket(int HostName, int port)

Answer optionb

Marks: 1

2369 which exception can be thrown by all factory methods of Inetaddress Class?

A. UnknownHostException

B. IOException

C. HostNotFoundException

D. none of the above

Answer optiona

Marks: 1

2370 Which of the following is also called as Type-I driver

A. Native-API Partly-Java driver

B. JDBC-ODBC Bridge driver

C. JDBC-Net Pure-Java driver

D. Native Protocol 100% Pure-Java driver

Answer optionb

Marks: 1

2371 which of the following method is used for SELECT query?

A. execute()

B. execute(String sql);

C. executeUpadate()

D. executeQuery(String sql);

Answer optiond

Marks: 1

2372 which of the following are interfaces?

A. ServletContext

B. ServletException

C. GenericServlet

D. HttpServelet

Answer optiona

Marks: 1

2373 _____ is the first phase of servlet lifer cycle

A. service

B. initialization

C. destroy

D. both ii and iii

Answer optionb

Marks: 1

2374 JSP is bacically used for

A. to make controller
B. to develop server pages

C. for writing business logic

D. for developing simple java program

Answer optionb

Marks: 1

Identify the missing statement in the following program:


import java.awt.*;
import java.awt.event.*;
public class JTxtFld extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
2375 contentPane.setLayout(new FlowLayout());
JTextField tf;
JTextArea ta=new JTextArea();
tf = new JTextField("TYPE HERE");
contentPane.add(tf);

}
}

A. import javax.swing.*;

B. contentPane.add(ta);

import javax.swing.*;
C. contentPane.add(tf);

D. none of these

Answer optionc

Marks: 2

Find out the error in the following program:


import java.awt.*;
import java.applet.*;
public class Choiceapp extends Applet {

Choice ch;
public void init() {

ch=new Choice();
2376 ch.add("AURANGABAD");
ch.add("PUNE");
ch.add("NAGPUR");
ch.add("MUMBAI");
ch.addItem("NASHIK",0);
add(ch);

A. add method does not exist

B. addItem method does not exist

C. addItem has only one argument i.e. String type

D. none of these

Answer optionc

Marks: 2

Assuming you have a class which implements the ActionListener interface,which method should
2377 be used to register this with a button?

A. addListener(*).

B. addActionListener(*).

C. addButtonListener(*).

D. setListener(*).

Answer optionb

Marks: 2
Which package is missing in given program.
import java.io.*;
class MyServer{
public static void main(String args[])throws Exception{
ServerSocket ss=new ServerSocket(3333);
Socket s=ss.accept();
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

String str="",str2="";
2378 while(!str.equals("stop")){
str=din.readUTF();
System.out.println("client says: "+str);
str2=br.readLine();
dout.writeUTF(str2);
dout.flush();
}
din.close();
s.close();
ss.close();
}
}

A. import java.io.*;

B. import java.event.*;

C. import java.net.*;

D. import java.applet.*;

Answer optionc

Marks: 2

Find the correct way to throw the exception.

import java.net.*;
public class URLDemo {
public static void main(String argts[])
2379 {
URL netAddress= new URL("http://www.msbte.com//index.html");
System.out.print("port:"+InetAddress.getPort());
}
}

A. throw MalformedURLexception

B. throw malformedURLException

C. throws MalformedURLException.

D. throws MalFormedUrlException

Answer optionc

Marks: 2

Select the correct option that can be used to create a result set in
2380 which the cursor can move in both the directions.

A. TYPE_SCROLL_SENSITIVE

B. CONCUR_READ_ONLY

C. TYPE_FORWARD_ONLY

D. CLOSE_CURSORS_AT_COMMIT

Answer optiona

Marks: 2

Which one of the following methods is used to execute INSERT,


2381 UPDATE, and DELETE statements in a Java application?

A. executeInsert()

B. executeDelete()

C. executeQuery()

D. executeUpdate()

Answer optiond

Marks: 2
Find the error in the following program:
import java.awt.*;
import java.applet.*;
/*
<Applet code = GLayoutMan width = 300 height = 100>
</Applet>
*/
public class GLayoutMan
{
public void init()
{
2382 Font f=new Font("VEDDENA", Font.BOLD, 25);
setFont(f);

setLayout(new GridLayout(2,2,10,10));
add(new Button("Red"));
add(new Button ("White"));
add(new Button ("Green"));
add(new Button ("Blue"));
add(new Button ("Black"));
}
}

A. java.awt.event is not imported

B. compilation error

C. Applet class is not extended

D. none of these

Answer optionc

Marks: 2

2383 A user want�s to create an Applet with menubar consisting three menu items and one checkable menu item select correct coding?

import java.awt.*;
import java.applet.*;
class Demo extends Applet
{

MenuBar mbr=MenuBar();
Menu m=new Menu(“File”);
MenuItem i1=new MenuItem(“New”);
A. MenuItem i2=new MenuItem(“Run”);
MenuItem i3=new MenuItem(“build”);
CheckBoxMenuItem i4=new CheckBoxMenuItem(“compile”);
M.add(i1);
M.add(i2);
M.add(i3);
M.add(i4);
Mbr.add(m);
}

import java.awt.*;
import java.applet.*;
class Demo extends Applet
{
public void init(){
MenuBar mbr=MenuBar();
Menu m=new Menu(“File”);
MenuItem i1=new MenuItem(“New”);
MenuItem i2=new MenuItem(“Run”);
B. MenuItem i3=new MenuItem(“build”);
CheckBoxMenuItem i4=new CheckBoxMenuItem(“compile”);
M.add(i1);
M.add(i2);
M.add(i3);
M.add(i4);
Mbr.add(m);
}
}

. import java.awt.*;
import java.applet.*;
class Demo extends Applet
{
public void init(){
MenuBar mbr=MenuBar();
setMenuBar(mbr);
Menu m=new Menu(“File”);
MenuItem i1=new MenuItem(“New”);
C. MenuItem i2=new MenuItem(“Run”);
MenuItem i3=new MenuItem(“build”);
CheckBoxMenuItem i4=new CheckBoxMenuItem(“compile”);
M.add(i1);
M.add(i2);
M.add(i3);
M.add(i4);
Mbr.add(m);
} }
import java.awt.*;
import java.applet.*;
class Demo extends Applet
{
public void init(){
MenuBar mbr=MenuBar();
setMenuBar(mbr);
Menu m=new Menu(“File”);
MenuItem i1=new MenuItem(“New”);
D. MenuItem i2=new MenuItem(“Run”);
MenuItem i3=new MenuItem(“build”);
CheckBoxMenuItem i4=new CheckBoxMenuItem(“compile”);
M.add(i1);
M.add(i2);
M.add(i3);
M.add(i1);
Mbr.add(m);
}
}

Answer optionc

Marks: 2

import java.awt.*;
class Demo extends Frame
{
public static void main(String args[]){
Frame f=new Frame();
2384 f.setVisible(true);
f.setSize(150,200);
}
}
In the above program how can a user hide the frame window

A. using void setHide();

B. using Void makeHidden(1);

C. using setVisible(false);

D. using hide(false);

Answer optionc

Marks: 2

Select correct output for following program:


package eventhandle;
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
public class CheckBack extends Applet implements ItemListener
{
Checkbox m1,m2,m3;
public void init()
{
m1=new Checkbox("A");
m2=new Checkbox("B");
m3=new Checkbox("C");
add(m1);
2385 add(m2);
add(m3);
m1.addItemListener(this);
m2.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==m1)
setBackground(Color.red);
if(ie.getSource()==m2)
setBackground(Color.green);
}
}
/*<applet code=checkbackg.class height=150 width=150>
</applet>*/

A. S1Q48O1.jpeg

B. S1Q48O2.jpeg

C. S1Q48O3.jpeg

D. S1Q48O4.jpeg

Answer optionb

Marks: 2

Which of the following classes is the topmost class in the event delegation
2386 class heirarchy?

A. java.util.EventListener

B. java.util.EventObject

C. java.awt.AWTEvent
D. java.awt.event.AWTEvent

Answer optionb

Marks: 2

2387 Identify the correct syntax

A. public void actionPerformed(ActionEvent ae)

B. public void ActionPerformed(ActionEvent ae)

C. public void actionPerformed(Action ae)

D. all are correct

Answer optiona

Marks: 2

whether we will get the output for bleow given code?


import java.net.*;
class InetAddressTest
{
public static void main(String args[]) throws UnknownHostException
{
2388 InetAddress Address = getLocalHost();
System.out.println(Address);

}
}

A. TRUE

B. FALSE

C.

D.

Answer optionb

Marks: 2

What is the output of this program?


import java.net.*;
class networking {
public static void main(String[] args) throws Exception {
2389 URL obj = new URL("http://www.orientpressltd.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType());
}
}

A. html

B. text

C. html/text

D. text/html

Answer optiond

Marks: 2

This is an example of prepared statement interface that ?


PreparedStatement stmt=con.prepareStatement("select * from emp");
ResultSet rs=stmt.executeQuery();
2390 while(rs.next()){
System.out.println(rs.getInt(1)+" "+rs.getString(2));
}

A. deletes the record

B. retrieve the record

C. updates the record

inserts the record


D.

Answer optionb

Marks: 2

2391 Which of the following are the methods of statement interface?


A. public ResultSet executeQuery(String sql)

B. public int executeUpdate(String sql)

C. public boolean first()

D. Both i & ii

Answer optiond

Marks: 2

A JSP page needs to generate an xml file. Which attribute of page directive may be used to specify that the JSP page is generating an
2392 XML file

A. contentType

B. generateXML

C. type

D. outputXML

Answer optiona

Marks: 2

2393 Which of the following statements about GUI components is wrong ?

A. Swing exists since version 1.2 of the jdk

B. You can not place AWT components on Swing containers

C. AWT stands for Abstract Window Toolkit

D. The AWT classes are deprecated

Answer optiond

Marks: 1

2394 AWT is used for GUI programming in java?

A. true

B. false

C.

D.

Answer optiona

Marks: 1

2395 Swing is not a part of JFC (Java Foundation Classes) that is used to create GUI application?

A. true

B. false

C.

D.

Answer optionb

Marks: 1

These two ways are used to create a Frame By creating the object of Frame class (association)
2396 by extending Frame class (inheritance)

A. True

B. False

C.

D.

Answer optiona

Marks: 1
2397 Which are passive controls that do not support any interaction with the user?

A. Choice

B. List

C. Labels

D. Checkbox

Answer optionc

Marks: 1

2398 The ActionListener interface is used for handling action events,For example,it's used by

A. Jbutton

B. JCheckbox

C. JMenuItem

D. All of these

Answer optiond

Marks: 1

2399 Which of these methods will be invoked if a character is entered?

A. keyPressed()

B. keyReleased()

C. keyTyped()

D. keyEntered()

Answer optionc

Marks: 1

2400 ���� supports fast, connectionless, unreliable transport of packets.

A. TCIP/IP

B. UDP

C. Both a and b

D. None of these

Answer optionb

Marks: 1

2401 Which of the following class is used for accessing the attributes of a remote URL resource?

A. URL

B. Socket

C. ServerSocket

D. URLConnection

Answer optiond

Marks: 1

2402 URL class consists of four components? those are:

A. Protocol , hostname , port number, File path

B. Protocol , hostname IP address, port number, File path

C. Both a and b

D. None of the above

Answer optionc
Marks: 1

2403 In which of the following type of ResultSet, the cursor can only move forward in the result set?

A. ResultSet.TYPE_FORWARD_ONLY

B. ResultSet.TYPE_SCROLL_INSENSITIVE

C. ResultSet.TYPE_SCROLL_SENSITIVE

D. None of the above.

Answer optiona

Marks: 1

2404 which method from the following is called multiple times at life cycle of servlet

A. init()

B. service()

C. destroy()

D. none of the above

Answer optionb

Marks: 1

2405 Which of the following are session tracking techniques?

A. URL rewriting using session objects, response object, using hidden fields

B. URL rewriting using session objects, cookies object, using hidden fields

C. URL rewriting using servlet objects, response object, using cookies object

D. URL rewriting using request objects, response object, using cookies

Answer optionb

Marks: 1

Below four methods commonly used in?


2406 1. public void add(Component c) 2. public void setSize(int width,int height)
3. public void setLayout(LayoutManager m) 4. public void setVisible(boolean)

A. Graphics class

B. Component class

C. Both i &ii

D. None of the above

Answer optionb

Marks: 2

2407 Which components are needed to get below shown output

A. TextField, Label

B. List, Button

C. Choice, Button

D. Button, TextField

Answer optionc

Marks: 2

2408 constants used at what var in method void setDefaultCloseOperation(int what) of class Jframe

A. JFrame.DISPOSE_ON_CLOSE

B. JFrame.HIDE_ON_CLOSE

C. JFrame.DO_NOTHING_ON_CLOSE
D. all of these

Answer optiond

Marks: 2

2409 constants used in FileDialog(Frame parent, String boxName, int how) for how

A. FileDialog.SAVE

B. FileDialog.LOAD

C. Both i &ii

D. none of these

Answer optionb

Marks: 2

2410 We use inner class concept in event handling in java by Adapter classes

A. TRUE

B. FALSE

C.

D.

Answer optiona

Marks: 2

The event Delegation Model consist of following steps


2411 1. Componet generates events.
2. Event object is preapred and passed to registered listener who will handle the event.

A. only 1 follows

B. only 2 follows

C. Both 1 and 2

D. nither 1 or 2

Answer optionc

Marks: 2

which options are correct with respect to Proxy servers


1. To bypass the security
2412 2. act as Firewall
3. To secure the Main Server from outside attackers.

A. all follows

B. only 1, 2 follows

C. only 1 follows

D. none follows

Answer optiona

Marks: 2

which methods from given below are used to create instance of InerAddress Class
2413 1. InetAddress getLocalHost() 2. InetAddress getAddress

A. 1

B. both 1 and 2

C. 2

D. none is used

Answer optiona

Marks: 2

2414 Select methods of URLConnection class.


A. int getContentLength( )

B. String getContentType( )

C. long getExpiration( )

D. All of these

Answer optiond

Marks: 2

select the correct difference between TCP and UDP protocol


1. TCP is connection oriented and UDP is connectionless protocol
2415 2. TCP is faster than UDP
3. TCP has variable path and UDP has fixed path

A. 1

B. 2

C. 3

D. all

Answer optiona

Marks: 2

2416 Which of the following is correct about ResultSet class of JDBC?

A. ResultSet holds data retrieved from a database after you execute an SQL query using Statement objects.

B. It acts as an iterator to allow you to move through its data.

C. The java.sql.ResultSet interface represents the result set of a database query.

D. All of the above.

Answer optiond

Marks: 2

Which of the following points are correct regarding DriverManger

2417 1. The DriverManager class acts as an interface between user and drivers.
2. It keeps track of the drivers that are available and handles establishing a connection between a database and the appropriate
driver.

A. only 1 follows

B. only 2 follows

C. Both i &ii follows

D. none follows

Answer optionc

Marks: 2

Which of the following points are correct :


1. Servlet has three life cycle methods init(), service(), destroy()
2418 2. init() and destroy() called once and service() called multiple times
3.client's state information is stored in cookies at server side

A. only 1 and 2

B. all 1, 2, 3

C. none follows

D. only 3 follows

Answer optiona

Marks: 2

Which of the following points are correct regarding the doGet()


1. Parameters are appended to the URL
2419 2.doGet() is faster as compare to doPost()
3. one can send unlimited data through doGet() method

A. only 1 follows

B. only 2 and 3 follows


C. only 1 and 2 follows

D. none of the above follows

Answer optionc

Marks: 2

Select output for given code

import java.awt.event.*;
import java.awt.*;
import java.applet.*;
public class checkbackg extends Applet implements ItemListener
{
Checkbox m1,m2,m3;
public void init()
{
m1=new Checkbox("A");
m2=new Checkbox("B");
m3=new Checkbox("C");
add(m1);
2420 add(m2);
add(m3);
m1.addItemListener(this);
m2.addItemListener(this);
}
public void itemStateChanged(ItemEventie)
{
if(ie.getSource()==m1)
setBackground(Color.red);
if(ie.getSource()==m2)
setBackground(Color.green);
}
}
/*<applet code=�checkbackg.class� height=150 width=150></applet>*/

A. S1Q42O1.jpg

B. S1Q42O2.jpg

C. S1Q42O3.jpg

D. S1Q42O4.jpg

Answer optionb

Marks: 2

import java.awt.*;
import java.applet.*;
/* <applet code="demo.class" height=300 width=300> </applet> */
public class demo extends Applet
{
TextField t1,t2,t3;
Button b1,b2,b3,b4;
Label l1,l2,l3;
public void init()
{
t1= new TextField(5);
t2= new TextField(5);
2421 t3= new TextField(5);
l1= new Label("First Number");
l2= new Label("Second Number");
l3= new Label("Third Number");
b1= new Button("Addition");
b2= new Button("Substraction");
b3= new Button("Multiplication");
b4= new Button("Division");
setLayout(new GridLayout(5,2));
add(l1);add(t1);add(l2);add(t2);add(l3);add(t3);
add(b1);add(b2);add(b3);add(b4);
}
}

A. S1Q43O1.jpg

B. S1Q43O2.jpg

C. S1Q43O3.jpg

D. S1Q43O4.jpg

Answer optiona

Marks: 2

2422 Select the Layout manager used in following output

A. FlowLayout

B. CardLayout

C. GridLayout

D. BorderLayout
Answer optionc

Marks: 2

2423 Select the code for the following output

import java.awt.*;

/* <applet code="demo.class" height=300 width=300> </applet> */


public class demo extends Applet
{

List l;
public void init()
{
l=new List();
l.addItem("Windows");
A. l.addItem("Linux");
l.addItem("Mac");
Choice c=new Choice();
c.addItem("india");
c.addItem("pak");
c.addItem("bangla");
add(c);

add(l);
}
}

import java.applet.*;
public class demo extends Applet
{

List l;
public void init()
{
l=new List();
l.addItem("Windows");
l.addItem("Linux");
B. l.addItem("Mac");
Choice c=new Choice();
c.addItem("india");
c.addItem("pak");
c.addItem("bangla");
add(c);

add(l);
}
}

import java.awt.*;
import java.applet.*;
/* <applet code="demo.class" height=300 width=300> </applet> */
public class demo extends Applet
{

List l;
public void init()
{
l=new List();
C. Choice c=new Choice();
c.addItem("Windows");
c.addItem("Linux");
c.addItem("Mac");
l.addItem("india");
l.addItem("pak");
l.addItem("bangla");
add(c);
add(l);
}
}

import java.awt.*;
import java.applet.*;
/* <applet code="demo.class" height=300 width=300> </applet> */
public class demo extends Applet
{

List l;
public void init()
{
l=new List();
l.addItem("Windows");
D. l.addItem("Linux");
l.addItem("Mac");
Choice c=new Choice();
c.addItem("india");
c.addItem("pak");
c.addItem("bangla");
add(c);

add(l);
}
}

Answer optiond

Marks: 2

2424 Select the code for the following output


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Rdemo extends Applet implements ActionListener
{
JRadioButton r1,r2,r3;
ButtonGroup br=new ButtonGroup();
public void init()
{
r1=new JRadioButton("red");
r2=new JRadioButton("green");
r3=new JRadioButton("blue");
br.add(r1);
br.add(r2);
br.add(r3);
A. setLayout(new FlowLayout());
r1.addActionListener(this);
r2.addActionListener(this);
r3.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==r1)
setBackground(Color.RED);
if(ae.getSource()==r2)
setBackground(Color.GREEN);
if(ae.getSource()==r3)
setBackground(Color.BLUE);
}
}
/*<applet code=Rdemo.class width=300 height=300>
</applet>*/

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Rdemo extends Applet implements ActionListener
{
JRadioButton r1,r2,r3;
ButtonGroup br=new ButtonGroup();
public void init()
{
r1=new JRadioButton("red");
r2=new JRadioButton("green");
r3=new JRadioButton("blue");
add(r1);
add(r2);
add(r3);
br.add(r1);
B. br.add(r2);
br.add(r3);
setLayout(new FlowLayout());

}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==r1)
setBackground(Color.RED);
if(ae.getSource()==r2)
setBackground(Color.GREEN);
if(ae.getSource()==r3)
setBackground(Color.BLUE);
}
}
/*<applet code=Rdemo.class width=300 height=300>
</applet>*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Rdemo extends Applet implements ActionListener
{
JRadioButton r1,r2,r3;
ButtonGroup br=new ButtonGroup();
public void init()
{
r1=new JRadioButton("red");
r2=new JRadioButton("green");
r3=new JRadioButton("blue");
add(r1);
add(r2);
add(r3);
br.add(r1);
br.add(r2);
br.add(r3);
setLayout(new FlowLayout());
r1.addActionListener(this);
r2.addActionListener(this);
r3.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==r1)
setBackground(Color.RED);
if(ae.getSource()==r2)
setBackground(Color.GREEN);
if(ae.getSource()==r3)
setBackground(Color.BLUE);
}
}
/*<applet code=Rdemo.class width=300 height=300>
</applet>*/
C. import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Rdemo extends Applet implements ActionListener
{
JRadioButton r1,r2,r3;
ButtonGroup br=new ButtonGroup();
public void init()
{
r1=new JRadioButton("red");
r2=new JRadioButton("green");
r3=new JRadioButton("blue");
add(r1);
add(r2);
add(r3);
br.add(r1);
br.add(r2);
br.add(r3);
setLayout(new FlowLayout());
r1.addActionListener(this);
r2.addActionListener(this);
r3.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==r1)
setBackground(Color.RED);
if(ae.getSource()==r2)
setBackground(Color.GREEN);
if(ae.getSource()==r3)
setBackground(Color.BLUE);
}
}
/*<applet code=Rdemo.class width=300 height=300>
</applet>*/

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Rdemo extends Applet implements ActionListener
{
JRadioButton r1,r2,r3;
ButtonGroup br=new ButtonGroup();
public void init()
{
r1=new JRadioButton("red");
r2=new JRadioButton("green");
r3=new JRadioButton("blue");
add(r1);
add(r2);
add(r3);
br.add(r1);
D. br.add(r2);
br.add(r3);
setLayout(new FlowLayout());
r1.addActionListener(this);
r2.addActionListener(this);
r3.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==r1)
setBackground(Color.RED);
if(ae.getSource()==r2)
setBackground(Color.GREEN);
if(ae.getSource()==r3)
setBackground(Color.BLUE);
}
}

Answer optiona

Marks: 2
2425 Select the code for the following output

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*<applet code="InnerClassDemo.class" width=200 height=100>
</applet>*/
public class InnerClassDemo
{
public void init()
{
addMouseListener(new MyMouseAdapter());
}
A. class MyMouseAdapter extends MouseAdapter
{
public void mousePressed(MouseEvent me)
{
showStatus("Moving mouse at 67, 13");
}
}
public void paint(Graphics g)
{
g.drawString("Mouse entered",10,10);
}
}

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*<applet code="InnerClassDemo.class" width=200 height=100>
</applet>*/
public class InnerClassDemo extends Applet
{
public void init()
{
addMouseListener(new MyMouseAdapter());
}
B. class MyMouseAdapter extends MouseAdapter
{
public void mousePressed(MouseEvent me)
{
showStatus("Moving mouse at 67, 13");
}
}
public void paint(Graphics g)
{
g.drawString("Mouse entered",10,10);
}
}

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*<applet code="InnerClassDemo.class" width=200 height=100>
</applet>*/
public class InnerClassDemo extends Applet
{
public void init()
{
addMouseListener(new MyMouseAdapter());
}
C. class MyMouseAdapter
{
public void mousePressed(MouseEvent me)
{
showStatus("Moving mouse at 67, 13");
}
}
public void paint(Graphics g)
{
g.drawString("Mouse entered",10,10);
}
}

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*<applet code="InnerClassDemo.class" width=200 height=100>
</applet>*/
public class InnerClassDemo extends Applet
{
public void init()
{
//addMouseListener(new MyMouseAdapter());
}
D. class MyMouseAdapter extends MouseAdapter
{
public void mousePressed(MouseEvent me)
{
showStatus("Moving mouse at 67, 13");
}
}
public void paint(Graphics g)
{
g.drawString("Mouse entered",10,10);
}
}

Answer optionb

Marks: 2

2426 Select the code for the following output


import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Check extends Applet implements ActionListener{
String str1,str2;
Checkbox c1,c2,c3,c4;
public void init()
{
c1=new Checkbox("win/xp");
c2=new Checkbox("win/NT");
c3=new Checkbox("win/PROF");
c4=new Checkbox("win/UNIX");
add(c1);
add(c2);
add(c3);
add(c4);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
A. c4.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
if(c1.getState()==true)
{
str1="WIN/XP:true";
str2="win/xp:true";
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(str1,150,100);
g.drawString(str2,150,120);
}
}
/*<applet code=Check.class width=300 height=300>
</applet>*/

import java.awt.*;

public class Check extends Applet implements ItemListener


{
String str1,str2;
Checkbox c1,c2,c3,c4;
public void init()
{
c1=new Checkbox("win/xp");
c2=new Checkbox("win/NT");
c3=new Checkbox("win/PROF");
c4=new Checkbox("win/UNIX");
add(c1);
add(c2);
add(c3);
add(c4);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
B. c4.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
if(c1.getState()==true)
{
str1="WIN/XP:true";
str2="win/xp:true";
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(str1,150,100);
g.drawString(str2,150,120);
}
}
/*<applet code=Check.class width=300 height=300>
</applet>*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Check extends Applet implements ItemListener
{
String str1,str2;
Checkbox c1,c2,c3,c4;
public void init()
{
c1=new Checkbox("win/xp");
c2=new Checkbox("win/NT");
c3=new Checkbox("win/PROF");
c4=new Checkbox("win/UNIX");
add(c1);
add(c2);
add(c3);
add(c4);
c1.addItemListener(this);
c2.addItemListener(this);
C. c3.addItemListener(this);
c4.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
if(c1.getState()==true)
{
str1="WIN/XP:true";
str2="win/xp:true";
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(str1,150,100);
g.drawString(str2,150,120);
}
}
/*<applet code=Check.class width=300 height=300>
</applet>*/

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Check extends Applet implements ItemListener
{
String str1,str2;
Checkbox c1,c2,c3,c4;
public void init()
{
c1=new Checkbox("win/xp");
c2=new Checkbox("win/NT");
c3=new Checkbox("win/PROF");
c4=new Checkbox("win/UNIX");
add(c1);
add(c2);
add(c3);
add(c4);

D. }
public void itemStateChanged(ItemEvent ie)
{
if(c1.getState()==true)
{
str1="WIN/XP:true";
str2="win/xp:true";
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(str1,150,100);
g.drawString(str2,150,120);
}
}
/*<applet code=Check.class width=300 height=300>
</applet>*/

Answer optionc

Marks: 2
Select output for given code
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FlagDemo extends JApplet implements ActionListener
{
JButton b1,b2,b3;
JTextArea t1;
String s1,s2,s3;
public void init()
{ setLayout(new FlowLayout());
ImageIcon clock=new ImageIcon("index.jpg");
ImageIcon clock1=new ImageIcon("srilanka.jpg");
ImageIcon clock2=new ImageIcon("aust.jpg");
b1=new JButton(clock);
b2=new JButton(clock1);
b3=new JButton(clock2);
t1=new JTextArea("Info",5,5);
add(b1);
add(b2);
add(b3);
add(t1);
b1.addActionListener(this);
2427 b2.addActionListener(this);
b3.addActionListener(this);

}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
s1="India officially the Republic of India is a country in South Asia.";
t1.setText(s1);
}
else if(ae.getSource()==b2)
{
s2="Sri Lanka officially the Democratic Socialist Republic of Sri Lanka";
t1.setText(s2);
}
else
{
s3="Australia officially the Commonwealth of Australia is an Oceanian country";
t1.setText(s3);
}
repaint();
}
}

A. compile time error

B. run time error

C. no errors

D. none of the above

Answer optionc

Marks: 2

2428 Select code for the following output


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="SBDemo" width=300 height=200>
</applet>
*/
public class SBDemo extends Applet implements AdjustmentListener, MouseMotionListener
{
String msg = "";
Scrollbar vertSB, horzSB;
public void init()
{
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
vertSB = new Scrollbar(Scrollbar.VERTICAL,10, 1, 0, height);
horzSB = new Scrollbar(Scrollbar.HORIZONTAL,0, 1, 0, width);
add(vertSB);
add(horzSB);

vertSB.addAdjustmentListener(this);
horzSB.addAdjustmentListener(this);
addMouseMotionListener(this);
A. }
public void mouseDragged(MouseEvent me)
{
int x = me.getX();
int y = me.getY();
vertSB.setValue(y);
horzSB.setValue(x);
repaint();
}

public void mouseMoved(MouseEvent me)


{
}

public void paint(Graphics g)


{
msg = "Vertical: " + vertSB.getValue();
msg += ", Horizontal: " + horzSB.getValue();
g.drawString(msg, 6, 160);
g.drawString("*", horzSB.getValue(),
vertSB.getValue());
}
}

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="SBDemo" width=300 height=200>
</applet>
*/
public class SBDemo extends Applet implements AdjustmentListener, MouseMotionListener
{
String msg = "";
Scrollbar vertSB, horzSB;
public void init()
{
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
vertSB = new Scrollbar(Scrollbar.VERTICAL,10, 1, 0, height);
horzSB = new Scrollbar(Scrollbar.HORIZONTAL,0, 1, 0, width);
add(vertSB);
add(horzSB);

vertSB.addAdjustmentListener(this);
B. horzSB.addAdjustmentListener(this);
addMouseMotionListener(this);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
repaint();
}

public void mouseDragged(MouseEvent me)


{
int x = me.getX();
int y = me.getY();
vertSB.setValue(y);
horzSB.setValue(x);
repaint();
}

public void mouseMoved(MouseEvent me)


{
}
}
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="SBDemo" width=300 height=200>
</applet>
*/
public class SBDemo extends Applet implements AdjustmentListener, MouseMotionListener
{
String msg = "";
Scrollbar vertSB, horzSB;
public void init()
{
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
vertSB = new Scrollbar(Scrollbar.VERTICAL,10, 1, 0, height);
horzSB = new Scrollbar(Scrollbar.HORIZONTAL,0, 1, 0, width);
add(vertSB);
add(horzSB);

addMouseMotionListener(this);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
C. repaint();
}

public void mouseDragged(MouseEvent me)


{
int x = me.getX();
int y = me.getY();
vertSB.setValue(y);
horzSB.setValue(x);
repaint();
}

public void mouseMoved(MouseEvent me)


{
}

public void paint(Graphics g)


{
msg = "Vertical: " + vertSB.getValue();
msg += ", Horizontal: " + horzSB.getValue();
g.drawString(msg, 6, 160);
g.drawString("*", horzSB.getValue(),
vertSB.getValue());
}
}

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="SBDemo" width=300 height=200>
</applet>
*/
public class SBDemo extends Applet implements AdjustmentListener, MouseMotionListener
{
String msg = "";
Scrollbar vertSB, horzSB;
public void init()
{
int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
vertSB = new Scrollbar(Scrollbar.VERTICAL,10, 1, 0, height);
horzSB = new Scrollbar(Scrollbar.HORIZONTAL,0, 1, 0, width);
add(vertSB);
add(horzSB);

vertSB.addAdjustmentListener(this);
horzSB.addAdjustmentListener(this);
addMouseMotionListener(this);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
D. {
repaint();
}

public void mouseDragged(MouseEvent me)


{
int x = me.getX();
int y = me.getY();
vertSB.setValue(y);
horzSB.setValue(x);
repaint();
}

public void mouseMoved(MouseEvent me)


{
}

public void paint(Graphics g)


{
msg = "Vertical: " + vertSB.getValue();
msg += ", Horizontal: " + horzSB.getValue();
g.drawString(msg, 6, 160);
g.drawString("*", horzSB.getValue(),
vertSB.getValue());
}
}

Answer optiond

Marks: 2
select the result of the following code
import java.sql.*;
import java.io.*;
public class DBDemo
{
public static void main(String []args)throws Exception
{
String sql;
2429 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:stud";
Connection con=DriverManger.getConnection(url);
Statement st=con.createStatement();
sql="update stud_table set name='John' where percentage>=86";

st.close();
}
}

A. compile time error

B. run time error

C. tabel updated successfully

D. none of the above

Answer optiona

Marks: 2

What msg will consist of, after successfull execution of the following code
import java.sql.*;
import java.io.*;
public class DBDemo
{
public static void main(String []args)throws Exception
{
String sql;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
2430 String url="jdbc:odbc:stud";
Connection con=DriverManger.getConnection(url);
Statement st=con.createStatement();
sql="delete from stud_table where percentage>=86";
Object msg=st.execute(sql);
System.out.print(msg);
st.close();
}
}

A. 1

B. 0

C. no of rows affected

D. none of the above

Answer optionc

Marks: 2

What is initial position to which rs object points to before makes use of next() from the given table
import java.sql.*;
import java.io.*;
public class DBDemo
{
public static void main(String []args)throws Exception
{
String sql;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
2431 String url="jdbc:odbc:stud";
Connection con=DriverManger.getConnection(url);
Statement st=con.createStatement();
sql="delete from stud_table where percentage>=86";
ResultSet rs=st.executeQuery(sql);
rs.next();
System.out.print(msg);
st.close();
}
}

A. first record

B. last record

C. before first record

D. none of the above

Answer optionc

Marks: 2

2432 Select the correct code to insert record to the stud_table


import java.sql.*;
import java.io.*;
public class DBDemo
{
public static void main(String []args)throws Exception
{
String sql;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
A. String url="jdbc:odbc:stud";
Connection con=DriverManger.getConnection(url);
Statement st=con.createStatement();
sql="insert into stud_table values (1,'ramesh','pune')";
Object msg=st.execute(sql);
System.out.print(msg);
st.close();
}
}

import java.sql.*;
import java.io.*;
public class DBDemo
{
public static void main(String []args)throws Exception
{
String sql;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:stud";
B.
Connection con=DriverManger.getConnection(url);
Statement st=con.createStatement();
sql="insert into stud_table (roll,name,city) values (1,'ramesh','pune')";
Object msg=st.execute(sql);
System.out.print(msg);
st.close();
}
}

C. Both A & B

D. none of the above

Answer optionc

Marks: 2

2433 Which of the following java code is correct to display the text "Wel-come to servlet!!"

import java.io.*;
import javax.servlet.*;
public class Demo extends GenericServlet
{
public void service(ServletRequest request,ServletResponse response)
{
try
A. {
response.setContentType("text/html");
PrintWriter pw=new PrintWriter();
pw.println("<B>Wel-come to Servlet!!");
pw.close();
}
}
}

import java.io.*;
import javax.servlet.*;
public class Demo extends GenericServlet
{
public void service(ServletRequest request,ServletResponse response)
{
try
B. {
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<B>Wel-come to Servlet!!");
pw.close();
}
}
}

import java.io.*;
import javax.servlet.*;
public class Demo extends GenericServlet
{
public void service(ServletRequest request,ServletResponse response)
{
try
C. {
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<B>Wel-come to Servlet!!");
pw.close();
}
}
}
import java.io.*;
import javax.servlet.*;
public class Demo extends GenericServlet
{
public void service(ServletRequest request,ServletResponse response)
{
try
D. {
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<B>Wel-come to Servlet!!");
pw.close();
} catch(Exception e
}
}

Answer optiond

Marks: 2

2434 Select the correct servlet code for adding the cookies

import java.io.*;
import javax.servlet.*;
public class AddCookie extends HTTPServlet
{
public void doPost(HTTPServletRequest request,HTTPServletResponse response)throws Exception
{
String data=request.getParameter("Name");
A. Cookie cookie=new Cookie("MyCookie",data);
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<B>My cookie is set");
pw.close();
}
}

import java.io.*;
import javax.servlet.*;
public class AddCookie extends HTTPServlet
{
public void doPost(HTTPServletRequest request,HTTPServletResponse response)throws Exception
{
String data=request.getParameter("Name");
B. Cookie cookie=new Cookie("MyCookie",data);
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<B>My cookie is set");
pw.close();
}
}

import java.io.*;
public class AddCookie extends HTTPServlet
{
public void doPost(HTTPServletRequest request,HTTPServletResponse response)throws Exception
{
String data=request.getParameter("Name");
Cookie cookie=new Cookie("MyCookie",data);
C. response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<B>My cookie is set");
pw.close();
}
}

import java.io.*;
import javax.servlet.*;
public class AddCookie
{
public void doPost(HTTPServletRequest request,HTTPServletResponse response)
{
String data=request.getParameter("Name");
D. Cookie cookie=new Cookie("MyCookie",data);
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<B>My cookie is set");
pw.close();
}
}

Answer optionb

Marks: 2

2435 Select the correct code for display the session id using servlet
//Java code

import java.io.*;
import javax.servlet.*;
public class MySession extends HTTPServlet
{
public void doPost(HTTPServletRequest request,HTTPServletResponse response)throws Exception
{
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
HTTPSession myses=request.getSession();
String id=myses.getId();
A. pw.println("<B>My cookie is set"+id);
pw.close();
}
} //web.xml file

<servlet>
<servlet-name>sID</servlet-name>
<servlet-class>MySession<servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sID</servlet-name>
<url-pattern>/MySession</url-pattern>
</servlet-mapping>

//Java code

import java.io.*;
import javax.servlet.*;
public class MySession
{
public void doPost(HTTPServletRequest request,HTTPServletResponse response)throws Exception
{
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
HTTPSession myses=request.getSession();
String id=myses.getId();
B. pw.println("<B>My cookie is set"+id);
pw.close();
}
} //web.xml file

<servlet>
<servlet-name>sID</servlet-name>
<servlet-class>sID<servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sID</servlet-name>
<url-pattern>/MySession</url-pattern>
</servlet-mapping>

//Java code

import java.io.*;
import javax.servlet.*;
public class MySession extends HTTPServlet
{
public void doPost(HTTPServletRequest request,HTTPServletResponse response)throws Exception
{
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
C. HTTPSession myses=request.getSession();
String id=myses.getId();
pw.println("<B>My cookie is set"+id);
pw.close();
}
} //web.xml file

<servlet>
<servlet-name>sID</servlet-name>
<servlet-class>MySession<servlet-class>
</servlet>

//Java code

import java.io.*;
import javax.servlet.*;
public class MySession extends HTTPServlet
{
public void doPost(HTTPServletRequest ,HTTPServletResponse )throws Exception
{
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
HTTPSession myses=request.getSession();
String id=myses.getSessionId();
D. pw.println("<B>My cookie is set"+id);
pw.close();
}
} //web.xml file

<servlet>
<servlet-name>sID</servlet-name>
<servlet-class>MySession<servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sID</servlet-name>
<url-pattern>/MySession</url-pattern>
</servlet-mapping>

Answer optiona

Marks: 2

2436 Which object is needed to group Checkboxes to make them exclusive?

A. CheckboxGroup
B. Checkbox

C. RadioButton

D. TextField

Answer optiona

Marks: 1

2437 Which Package provides many event classes & listener interfaces for event handling?

A. java.awt

B. java.awt.Graphics

C. java.awt.event

D. None of the above

Answer optionc

Marks: 1

2438 Which methods are commonly used in ServerSocket class?

A. public OutputStream getOutputStream()

B. public Socket accept()

C. public synchronized void close()

D. None of the above

Answer optionb

Marks: 1

2439 Which maintains a cursor pointing to a particular row of data initially ,cursor points to before the first row ?

A. Connection interface

B. Statement interface

C. Resultset interface

D. None of the above

Answer optionc

Marks: 1

2440 The ----------- method sets the query parameters of the PrepareStatement object

A. putString()

B. insertString

C. setString()

D. setToString()

Answer optionc

Marks: 1

2441 The ----------------- object allows you to execute parameterized queries.

A. Resultset

B. Parameterized

C. PreparedStatement

D. Condition

Answer optionc

Marks: 1

2442 Which is the methods of generated Servlet?


A. jspInit()

B. jspService()

C. jspDestroy()

D. All of the above

Answer optiond

Marks: 1

2443 How Many techniques are used in session Tracking?

A. 4

B. 3

C. 2

D. 5

Answer optiona

Marks: 1

Consider the following program.


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

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
/*
<applet code =�combodemo1� width=300 height=100>
</applet>
*/
Public class combodemo1 extends JApplet
2444 {
Public void init()
{
Container co=getContentPane();
co.setLayout(new FlowLayout())
JComboBox jc=new JComboBox();
jc.addItem(�Apple�);
jc.addItem(�Mango�);
jc.addItem(�Orange�);
jc.addItem(�Banana�);
co.add(jc);
}
}

A. Missing{

B. Missing )

C. Missing;

D. Missing statement

Answer optionc

Marks: 2

2445 Which layout manager will provide output in rows and columns?

A. a FlowLayout

B. a GridLayout

C. a BorderLayout

D. any Layout

Answer optionb

Marks: 2

2446 The default layout out of a contentPane in a JFrame is______________

A. FlowLayout

B. GridLayout

C. BorderLayout

D. None
Answer optionc

Marks: 2

2447 The Component class and MenuComponent class are the _______________which represent the GUI Components.

A. Subclasses

B. Superclasses

C. Both a & b

D. None of these

Answer optionb

Marks: 2

2448 Which of the following is the highest class in the event-delegation model?

A. java.util.EventListener

B. java.util.EventObject

C. java.awt.AWTEvent

D. java.awt.event.AWTEvent

Answer optionb

Marks: 2

In following Java program fill statement showing ***.Select any one option from given options.

class URLDemo
{
public static void main(String args[]) throws MalformedURLException
{
2449 ******************
System.out.println(""Protocol :""+netAddress.getProtocol());
System.out.println(""Port :""+netAddress.getPort());
System.out.println(""Host :""+netAddress.getHost());
System.out.println(""File :""+netAddress.getFile());
}
}

A. URL netAddress=new URL(http://www.sun.com.8080//index.html);

B. URL netAddress=new URL(http://www.sun.com.//index.html);

C. URL netAddress=new URL(http://www.sun.com//*.html);

D. URL net=new URL(http://www.sun.com.8080//index.html)

Answer optiona

Marks: 2

2450 Which driver is efficient and always preferable for using JDBC applications

A. Type-4 driver

B. Type-3 driver

C. Type-2 driver

D. Type-1 driver

Answer optiona

Marks: 2

2451 To invoke an applet packaged as a JAR file

<applet code=AppletClassName.class
archive="JarFileName.jar"
A. width=width height=height>
</applet>

<applet code=AClassName.class
archive="JarFileName.jar"
B. width=width height=height>
</applet>

<applet code=AppletClassName.class
archive="JarFileName.jar"
C. width=400 height=200>
</applet>
<applet code=AppletClassName.class
archive="JarFileName"
D. width=400 height=200>
</applet>

Answer optiona

Marks: 2

2452 How do you indicate where a component will be positioned using FlowLayout?

A. North, South, East, West

B. Assign a row/column grid reference

C. Pass a X/Y percentage parameter to the add method

D. Do nothing, the FlowLayout will position the component

Answer optiond

Marks: 2

2453 Which of these are valid adapter classes.

A. ActionAdapter

B. AdjustmentAdapter

C. KeyAdapter

D. TextAdapter

Answer optionc

Marks: 2

2454 What is the return type of the method getSource() defined in EventObject class.

A. int

B. long

C. Object

D. Component

Answer optionc

Marks: 2

2455 Which of the following type of JDBC driver, talks with the server-side middleware that then talks to database?

A. JDBC-ODBC Bridge plus ODBC driver

B. Native-API, partly Java driver

C. JDBC-Net, pure Java driver

D. Native-protocol, pure Java driver

Answer optionc

Marks: 2

Choose missing statements in following code from given options.

public class cookies servlet extends HTTPServlet


{
public void doGet(HTTPServletRequest reg,HTTPServletResponse res) throws
ServletException, IOexception {
Cookie token=null
res.setContentType("text/html");
Printwriter pw=res.getwriter();
pw.println("<html><body>");
2456 String s=request.getParameter("name");
token=new Cookie("MyCookie",s);
res.addCookie(token);
pw.println(""Information collected by the Cookie:"");
pw.println(""Cookie Name:""+token.getName());
pw.println(""Cookie Value:""+token.getValue);
pw.println(""</body></html>"");

pw.close();
}
}

A. import java.io.*;
B. import javax.servlet.http.*;

C. import javax.servlet.*;

D. All of the above.

Answer optiond

Marks: 2

2457 Which of the following is true about service() method of servlet?

A. The servlet container (i.e. web server) calls the service() method to handle requests coming from the client.

B. Each time the server receives a request for a servlet, the server spawns a new thread and calls service.

C. The service() method checks the HTTP request type (GET, POST, PUT, DELETE, etc.) and calls doGet, doPost, doPut, doDelete, etc. methods as appropriate.

D. All of the above.

Answer optiond

Marks: 2

2458 A JSP is transformed into a(n):

A. Neither JSP or Applet

B. Either JSP or Applet

C. Java Servlet

D. Java Applet

Answer optionc

Marks: 1

2459 J2ME is a product from _____________.

A. Microsoft

B. Sun Micro system.

C. AT&T.

D. Borland.

Answer optionb

Marks: 1

2460 The classes and interfaces defined in AWT are contained within the ______ package.

A. java.awt.*

B. java.sql.*

C. java.io.*

D. java.int

Answer optiona

Marks: 1

2461 Which layout having Positions the components into five regions:east, west, north, south, center

A. flowlayout

B. gridlayout

C. BorderLayout

D. gridbaglayout

Answer optionc

Marks: 1

2462 EventObject class belongs to:


A. java.awt

B. java.util

C. java.lang

D. java.sql

Answer optionb

Marks: 1

2463 An event is an ______that describes a state change in a source.

A. Class

B. Object

C. Method

D. None of these

Answer optionb

Marks: 1

2464 In Java, events are all the activities that occur between

A. Process and thread

B. user and hardware

C. application and OS

D. user and application

Answer optiond

Marks: 1

2465 Which of these package contains classes and interfaces for networking?

A. java.net.*

B. java.sql.*

C. java.network.*

D. java.util.*

Answer optiona

Marks: 1

2466 How many states are there in Servlet life cycle?

A. 2

B. 3

4
C.

D. 1

Answer optionb

Marks: 1

2467 The init parameter name and value pairs that are defined in web.xml file are handled by ______________ Object.

A. ServletContext

B. ServletRequest

C. ServletConfig

D. ServletResponse

Answer optionc

Marks: 1
2468 Which are the following components act as a button in a swing.

A. JButton

B. JCheckbox,

C. JToggleButton,JRadioButton

D. All of these

Answer optiond

Marks: 2

2469 The CardLayout class defines the following constructors:

A. Cardlayout(),CardLayout(int horz)

B. Cardlayout() ,CardLayout(int horz, int vert)

C. CardLayout() ,Cardlayout(int vert)

D. Cardlayout(int horz, int vert)

Answer optionb

Marks: 2

What wii be the output for following code fragments.


import java.awt.*;
class F1
{ public static void main(String[] args)
{
Frame f1=new Frame("This is first frame");
2470 f1.setSize(300,200);
f1.setVisible(false);
}

Frame Window having title as This is first frame


A. and 300X200 in width

B. Only Frame appears With No Title

C. Frame with only three buttons

D. NO OUTPUT

Answer optiond

Marks: 2

What will be the ouput of the following Program


import java.awt.*;
import java.applet.*;
/*<applet code="App" height="" width="200"></applet> */
public class App extends Applet
2471 {
public void paint(Graphics g)
{
g.drawString("Welcome Applet ",50,100);
}
}

A. Applet with Welcome Applet

B. Applet with No Output

C. Warning: <applet> tag requires height attribute.

D. Compiler Error

Answer optiona

Marks: 2

2472 The Delegation Event Model defines a ______________ approach to handle events:

A. Logical

B. Physical

C. both logical and physical

D. None of these

Answer optionc
Marks: 2

2473 How many types of JDBC drivers available?

A. 4

B. 1

C. 2

D. 5

Answer optiona

Marks: 2

2474 In DriverManager class which method is used to establish the connection with the specified url?

A. public static void deregisterDriver(Driver driver)

B. public static void registerDriver(Driver driver)

C. public static Connection getConnection(String url)

public static Connection getConnection(String url,


D. String userName,String password)

Answer optionc

Marks: 2

2475 Which are various AWT controls from following?

A. Labels, Push buttons, Check boxes, Choice lists.

B. Text components, Threads, Strings, Servelts, Vectors

C. Labels, Strings, JSP, Netbeans, Sockets

D. Push buttons, Servelts, Notepad, JSP

Answer optiona

Marks: 2

2476 Which of the following methods are defined on the Graphics class?

A. add(Component);

B. setVisible(boolean);

C. setLayout(Object);

D. drawLine(int, int, int, int)

Answer optiond

Marks: 2

2477 Swing Components are_______________________

A. Platform dependent

B. Platform Independent

C. Platform oriented

D. None of above

Answer optionb

Marks: 2

2478 Which of the following are valid return types, for listener methods?

A. Boolean.

B. Void.

C. the type of event handled.

D. Component.
Answer optionb

Marks: 2

2479 Which method is invoked when user perform the action?

A. void getACtionCommand()

B. void actionPerformed()

C. void ActiovEvent(EventObject o)

D. addActionListerner()

Answer optionb

Marks: 2

What will be the output of the following program


import java.net.*;

class networking {

public static void main(String[] args) throws UnknownHostException {

InetAddress obj1 = InetAddress.getByName("google.com");

2480 InetAddress obj2 = InetAddress.getByName("google.com");

boolean x = obj1.equals(obj2);

System.out.print(x);

A. true

B. false

C. 0

D. 1

Answer optiona

Marks: 2

2481 Which of the following required to be closed to close database operations?

A. Resultset

B. Connection

C. Statement

D. All of above

Answer optiond

Marks: 2

2482 Which of the following type of JDBC driver is the fastest one?

A. Type 4

B. Type 2

C. Type 3

D. Type 1

Answer optiona

Marks: 2

2483 Which of the following executes the any kind of SQL statement?

A. Resultset executeQuery()

B. boolean execute()

C. int executeUpdate()

D. None of the above


Answer optionb

Marks: 2

2484 Session attributes are stored on _______________

A. Client

B. Web Server

C. client and web server

D. proxy server

Answer optionb

Marks: 1

2485 API stands for_______________

A. Application programming Infrastructure

B. Application Programming Interface

C. Advance Programming Interface

D. None of the above

Answer optionb

Marks: 1

2486 Which is these classes can be added to any Container class using the add method in container class?

A. Button,RadioButton,TextField,List

B. FlowLayout,Menu

C. Menubar

D. CheckboxMenuItem

Answer optiona

Marks: 1

2487 Which of the following is the valid constructor of JTable?

A. JTable(Object data)

B. JTable(Object rows[], Object columns[])

C. JTable(Object data[][], Object columnHeads[])

D. JTable(Object columnHeads[],Object data[])

Answer optionc

Marks: 1

2488 Which of the following constructor of Menu?

A. Menu(ChechboxMenuItem c)

B. Menu(String optionName,boolean removable)

C. Menubar

D. Menu(Checkbox c)

Answer optionb

Marks: 1

2489 Which of the following is not a constructor of JRadioButton

A. JRadioButton(Icon i)

B. JRadioButton(Icon I,Boolean State)

C. JRadioButton(Icon I,Jbutton b)
D. JRadioButton(String s1,Icon i)

Answer optionc

Marks: 1

2490 Which is swing Components?

A. ImageIcon,Japplet,CheckBoxGroup

B. ImageIcon,JChoiceBox,Jbutton

C. JApplet,JButton,JTabbedPane

D. Japplet,Jbutton,JTabbedPane,JTreePane

Answer optionc

Marks: 1

2491 If scroll bar is manupulated______________event will be notified.

A. AdjustmentEvent

B. EventClass

C. ActionEvent

D. ItemEvent

Answer optiona

Marks: 1

2492 ____________method are used to register a mouse motion listener

A. addMouse()

B. addMouseListener()

C. addMouseMotionListner()

D. eventMouseMotionListener()

Answer optionc

Marks: 1

2493 DNS is______________

A. Data Network Service

B. Domain Name Service

C. Domain Network Service

D. Domain Network System

Answer optionb

Marks: 1

2494 Which packages contain the JDBC classes?

A. java.jdbc and javax.jdbc

B. java.jdbc and java.jdbc.sql

C. java.sql and javax.sql

D. java.rdb and javax.rdb

Answer optionc

Marks: 1

The Java __________ specification defines an application programming interface for communication between the Web server and the
2495 application program.

A. Servlet

B. Server
C. Program

D. Randomrize

Answer optiona

Marks: 1

2496 The doGet() method in the example extracts values of the parameter�s type and number by using __________

A. request.getParameter()

B. request.setParameter()

C. responce.getParameter()

D. responce.getAttribute()

Answer optiona

Marks: 1

2497 Which components are used in the following output?

A. Button,RadioButton,TextField,List

B. Button,Choice,TextField,List

C. Button,Choice,TextArea,ComboBox

D. Button,Choice,TextField,ComboBox

Answer optionb

Marks: 2

Select the missing statement in given code


import java.awt.*;
import java.applet.*;
import javax.swing.*;
public class table extends JApplet
{
public void init()
{
String s[]={"srno","name","rollno"};
2498 Object data[][]={{"1","abc","01"},{"2","xyz","0"}};
int v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane p=new JScrollPane(it,v,h);
Container co=getContentPane();
co.add(p,BorderLayout.CENTER);
}
}
/*<applet code=table width=300 height=300></applet>*/

JTable it=new JTable(data,s);


int v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
A. int h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane p=new JScrollPane(it,v,h);

JTable it=new JTable(data,s);


B. int v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;

JTable it=new JTable(data,s);


int v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
C. JScrollPane p=new JScrollPane(it,v,h);
addWindowListener(new MyAdapter());
addMpouseListener(new MyAdapter());

D. JTable it=new JTable(data,s);

Answer optiond

Marks: 2

2499 Which method is used to display icon on componet

A. rollOverIcon(ImageIcon i)

B. setIcon(ImageIcon i)

C. displayIcon(ImageIcon i)

D. removeIcon(IImageIcon i)

Answer optionb

Marks: 2
Select the missing statement in given code
import java.applet.*;
import java.awt.event.*;
import java.awt.*;

public class adapter extends Frame {


public adapter(){
setSize(200,300);
setVisible(true);
}
2500 public static void main(String aa[])
{
new adapter();
}

class MyAdapter extends WindowAdapter {


public void windowClosing(WindowEvent me) {
System.exit(0);
}
}
}

A. addWindowListener(new MyAdapter());

B. addMouseListener()

addWindowListener(new MyAdapter());
C. addMpouseListener(new MyAdapter());

D. addMyAdapter(this);

Answer optiona

Marks: 2

2501 When the message "no suitable driver" occurs?

A. when the driver is not registered by Class.forName() method

B. When the username,password and database does not match

C. When the JDBC database URL passed is not constructed properly

D. When the type 4 driver is use

Answer optionc

Marks: 2

Find the error of following code


import java.sql.*;

public class dbAccess


{
public static void main(String[] args)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:ab", "", "");
2502 Statement s = conn.createStatement();
String s1="insert into Table1 values('akash','201')";
s.executeUpdate(s1);

s.close();
conn.close();

}
}

A. line no4 JDBC driver not loaded properly

B. no error data inser into database

C. class not found exception Class.forName must be catch or thrown exception

D. sql package not imported properly

Answer optionc

Marks: 2

Select the missing statement in given code


import java.io.*;
import javax.servlet.*;
public class HelloServlet extends GenericServlet {
public void service(ServletRequest request,ServletResponse response)
{
2503 response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

A. public void service(ServletRequest request,ServletResponse response)throws ServletException, IOException


B. import javax.servlet.httpservlet.*;

C. public void doGet(ServletRequest request,ServletResponse response)throws ServletException, IOException

D. public void dopost(ServletRequest request,ServletResponse response)throws ServletException, IOException

Answer optiona

Marks: 2

Consider the following program.


What should be the correction done in the program to get correct output?
import java.awt.*;
import java.swing.*;
/*
<applet code="JComboBoxDemo" width=300 height=100>
</applet>
*/
2504 public class JComboBoxDemo extends JApplet {

JComboBox jcb;
String flags[] = { "France", "Germany", "Italy", "Japan" };
public void init() {
jcb = new JComboBox(flags);
add(jcb);
}
}

A. Class should not be public.

B. package not imported correctly

C. Jcombobox class not use correctly

D. Jcombobox should be added to content pane

Answer optionb

Marks: 2

For the following code select the Listener that can be used to handle event.
importjava.awt.event.*;
import java.awt.*;
importjava.applet.*;
public class checkbackg extends Applet implements -----------------
{
Checkbox m1,m2,m3;
public void init()
{
m1=new Checkbox("A");
m2=new Checkbox("B");
m3=new Checkbox("C");
add(m1);
add(m2);
2505 add(m3);
m1.addItemListener(this);
m2.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==m1)
setBackground(Color.red);
if(ie.getSource()==m2)
setBackground(Color.green);
}
}
/*<applet code=checkbackg.class height=150 width=150>
</applet>*/

A. ActionLstener

B. ItemListener

C. AdjustmentListener

D. FocusListener

Answer optionb

Marks: 2
Consider the following program.
What should be the correction done in the program to get correct output?
import java.sql.*;

public class dbAccess


{
public static void main(String[] args)throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:ab", "", "");
2506
Statement s = conn.createStatement();
String s1="update Table1 set name1='akash' where rollno='1'";
s.executeQuery(s1);

s.close();
conn.close();

}
}

try{ }
A. catch(Exception e){}

B. s.executeQuery(s1);

C. s.executeUpdate(s1)

D. s.execute(s1)

Answer optionc

Marks: 2

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.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
Connection con =s.createStatement();
s.setString(1,args[0]);
2507 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.getDouble(3));
}
s.close();
c.close();
}
}

A. Connection con =s.createStatement();

B. ResultSet rs=s.executeQuery("select* from db3");

C. PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");

s.setString(1,args[0]);
D. s.setString(2,args[1]);
s.setString(3,args[2]);

Answer optiona

Marks: 2

Consider the following program.


fiind error
import java.sql.*;

public class dbAccess


{
public static void main(String[] args)throws Exception
{
Class.forName("sun:jdbc:odbc:JdbcOdbcDriver");
2508 Connection conn = DriverManager.getConnection("jdbc:odbc:ab", "", "");
Statement s = conn.createStatement();
String s1="update Table1 set name1='akash' where rollno='1'";
s.executeUpdate(s1);
s.close();
conn.close();

}
}

A. Missing semicolon

B. exception in main class notfound sun:jdbc:odbc:JdbcOdbcDriver

C. exception in main class notfound jdbc:odbc:ab

D. program is correct
Answer optionb

Marks: 2

Consider the following program. Identify which package should be imported.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ColorPostServlet extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)throws ServletException, IOException
{
2509 String color = request.getParameter("color");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>The selected color is: ");
pw.println(color);
pw.close();
}
}

import java.io.*;
A. import javax.servlet.*;

import java.io.net.*;
B. import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
C. import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
D. import javax.servlet.*;
import javax.servlet.service*;

Answer optionc

Marks: 2

Consider the following html and servlet programs.


Supose you choose Blue color and click on sumit button then What should be the output of servlet program?
<html>
<body>
<center>
<form name="Form1"
action="http://localhost:8080/servlets-examples/servlet/ColorGetServlet">
<B>Color:</B>
<select name="color" size="1">
<option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
</select>
<br><br>
<input type=submit value="Submit">
</form>
</body>
</html>
2510

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ColorGetServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String color = request.getParameter("color");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>The selected color is: ");
pw.println(color+" color");
pw.close();
}
}

A. The selected color is:Blue

B. The selected color is:Blue color

C. The selected color is:Red

D. The selected color is:Green

Answer optionb

Marks: 2
In following Java program fill statement showing ***.Select any one option fro
given options
import java.io.*;
import javax.servlet.*;
public class HelloServlet extends *****************{
public void service(ServletRequest request,
ServletResponse response)
2511 throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

A. Genericserver

B. GenericServlet

C. Applet

D. Frame

Answer optionb

Marks: 2

Consider the following program. Identify the missing statement


import java.io.*;
import java.util.*;
import javax.servlet.*;
public class DateServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)throws ServletException, IOException {
HttpSession hs = request.getSession(true);
// Get writer.
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
2512 pw.print("<B>");
// Display date/time of last access.
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
// Display current date/time.
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. iimport java.awt.*;

B. import javax.servlet.http.*;

C. response.setContentType("text/html");

public void doGet(HttpServletRequest request,


D. HttpServletResponse response)throws ServletException, IOException

Answer optionb

Marks: 2

Consider the following program. Identify the exception that might be thrown
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ColorPostServlet extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)throws-----------------------
{
2513 String color = request.getParameter("color");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>The selected color is: ");
pw.println(color);
pw.close();
}
}

A. ServletException, IOException

B. ServletException, AirthmaticException

C. HttpException, IOException

D. ServletException, HttpException

Answer optiona

Marks: 2

2514 Default layout manager for subclasses of "Window" is _______________.

A. CardLayout
B. FlowLayout

C. GridLayout

D. BorderLayout

Answer optiond

Marks: 1

2515 The class at the top of the AWT hierarchy is ___________

A. Component

B. Window

C. Container

D. Panel

Answer optiona

Marks: 1

2516 A JFrame�s __________ represents the area of the JFrame excluding the title, menu bar, and the border.

A. layout manager

B. content pane

C. event listeners

D. event classes

Answer optionb

Marks: 1

2517 ___________ is a swing component which is equivalent of AWT component Choice.

A. JList

B. JChoice

C. JComboBox

D. JTree

Answer optionc

Marks: 1

2518 Which of these class is super class of Menu class?

A. MenuBar

B. MenuItem

C. CheckboxMenuItem

D. None of the above

Answer optionb

Marks: 1

2519 The ________ class is a container that allows multiple components to be added but only displays one component at a time.

A. JFrame

B. JTabbedPane

C. JPanel

D. Japplet

Answer optionb

Marks: 1

2520 Which of these interfaces handles the event when a component is added to a container?
A. ComponentListener

B. ContainerListener

C. ActionListener

D. ItemListener

Answer optionb

Marks: 1

2521 What is Application logic in the Event Delegation Model?

A. It is a code that processes the event.

B. It is a ode that generates the event.

C. Both A and B

D. None of the above

Answer optiona

Marks: 1

2522 Which of theese generates action events when an item is double-clicked?

A. Choice

B. Checkbox

C. List

D. Label

Answer optionc

Marks: 1

2523 Which of these events does not handled by Adapter classes?

A. ComponentEvent

B. ActionEvent

C. WindowEvent

D. MouseEvent

Answer optionb

Marks: 1

2524 _________ is a protocol that sends independent packets of data, called datagrams.

A. TCP

B. IP

C. UDP

D. HTTP

Answer optionc

Marks: 1

2525 Port numbers are represented by ______.

A. 8 bit

B. 16 bit

C. 32 bit

D. 48 bit

Answer optionb

Marks: 1
2526 If port number is not mentioned in the URL, getPort() method of the URL returns ________.

A. 80

B. 1024

C. 0

D. -1

Answer optiond

Marks: 1

2527 Which of these is correct example of URL of the database?

A. jdbc:sql:dsnname

B. jdbc:dsnname:odbc

C. jdbc:odbc:dsnname

D. jdbc:odbc:jdbcodbc

Answer optionc

Marks: 1

2528 _______________ objects are used to execute stored procedures.

A. CallableStatement

B. Statement

C. PreparedStatement

D. All of the above

Answer optiona

Marks: 1

2529 JSP is used to create _____________.

A. static web content

B. dynamic web content

C. Both A and B

D. None of the above

Answer optionc

Marks: 1

2530 Which of the following technique is not used for session tracking?

A. Visible Fields

B. URL Rewriting

C. Cookies

D. Hidden Fields

Answer optiona

Marks: 1
Which checkbox will be selected in the following code.
import java.awt.*;
public class Demo extends Frame
{
Demo()
{
CheckboxGroup cbg = new CheckboxGroup();
Checkbox cb1 = new Checkbox("First",true,cbg);
Checkbox cb2 = new Checkbox("Second",true,cbg);
Checkbox cb3 = new Checkbox("THird",false,cbg);
cbg.setSelectedCheckbox(cb3);
2531 setLayout(new FlowLayout());
add(cb1);
add(cb2);
add(cb3);
}
public static void main(String args[])
{
Demo d=new Demo();
d.setVisible(true);
d.setSize(200,200);
}
}

A. cb1

B. cb2,cb1

C. cb1,cb2,cb3

D. cb3

Answer optiond

Marks: 2

What will be the order of four items added

import java.awt.*;
import java.applet.*;
/*<applet code="Demo1" width=200 height=200></applet>*/
public class Demo1 extends Applet
{
public void init()
2532 {
Choice c1 = new Choice();
c1.add("One");
c1.addItem("Two");
c1.add("Three");
c1.insert("Lastadded",2);
add(c1);
}
}

A. One,Two,Three,Lastadded

B. One,Two,Lastadded,Three

C. One,Lastadded,Two,Three

D. None of the above

Answer optionb

Marks: 2

What is the meaning of following statement?


2533 List lt=new List(5,true);

A. It creates List object with 5 number of entries in the list that will always be hidden and user can not select two or more items at a time.

B. It creates List object with 5 number of entries in the list that will always be hidden and user may select two or more items at a time.

C. It creates List object with 5 number of entries in the list that will always be visible and user may select two or more items at a time.

D. It creates List object with 5 number of entries in the list that will always be visible and user can not select two or more items at a time.

Answer optionc

Marks: 2

2534 Which of the following code is used to handle window closing event?

addWindowListener(new WindowEvent()
{
public void windowClosing(WindowAdapter wa)
A. {
System.exit(0);
}
});
addNewWindowListener(new WindowEvent()
{
public void windowClosing(WindowAdapter wa)
B. {
System.exit(0);
}
});

addNewWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
C. {
System.exit(0);
}
});

addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
D. {
System.exit(0);
}
});

Answer optiond

Marks: 2

Select the missing statement in given code.


import java.awt.*;
import java.applet.*;
import java.applet.*;
public class Demo3 extends Applet implements ActionListener
{
public void init()
{
List lt= new List(3,true);
2535 lt.add("ccc");
lt.add("ddd");
lt.add("kkk");
lt.add("aaa");
add(lt);
}
}
/*<applet code=Demo3.class height=200 width=200>
</applet>*/

A. lt.addActionListener();

B. lt.addItemListener(this);

C. lt.addActionListener(this);

D. lt.addItemListener();

Answer optionc

Marks: 2

2536 Which of these method executes an SQL statement that may return multiple results?

A. executeMultiple()

B. execute()

C. executeQuery()

D. executeUpdate()

Answer optionb

Marks: 2

2537 ________________ method is used to execute only the �SELECT� query of the SQL.

A. executeSelect()

B. execute()

C. executeQuery()

D. executeUpdate()

Answer optionc

Marks: 2
For the following code select the method that can be used to establish the connection with DBMS.
import java.sql.*;
class Student
{
public static void main(String args[])
{
try
2538 {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.______________("jdbc:odbc:stud");
con.close();
}
catch(Exception e){ }
}
}

A. getConnection

B. openConnection

C. setConnection

D. loadConnection

Answer optiona

Marks: 2

2539 Which of these is correct syntax of doGet() method?

A. void doGet(HttpServletResponse response,HttpServletRequest request) throws ServletException, IOException

B. void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException

C. void doGet(HttpServletResponse response,HttpServletRequest request) throws ServletException

D. void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

Answer optiond

Marks: 2

2540 HttpSession has ___________ method that store objects by name and __________ method that retrieve objects by name.

A. getAttribute(), setAttribute()

B. setSession(), getSession()

C. setAttribute(), getAttribute()

D. getSession() ,setSession()

Answer optionc

Marks: 2

Identify which JSP element is used in the following code of JSP.


2541 Today is <%= new java.util.Date() %>

A. JSP directives

B. JSP expression

C. JSP declaration

D. JSP bean

Answer optionb

Marks: 2
Analyse the following code and select correct option.

import java.awt.*;
import javax.swing.*;
public class ToolTip1 extends JFrame
{
JTextField tf1;
Container cp;
ToolTip1()
{
tf1=new JTextField(12);
tf1.setToolTipText("Enter username");
2542 cp.setLayout(new FlowLayout());
cp.add(tf1);
setVisible(true);
setSize(200,200);
setDefaultCloseOperation(EXIT_ON_CLOSE);

}
public static void main(String args[])
{
ToolTip1 j=new ToolTip1();
}
}

A. Compile Time Error

B. Run Time Error

C. JTextfield is displayed with tooltip text "Enter username"

D. JTextfield is displayed with initial text "Enter username"

Answer optionb

Marks: 2

In following Java program fill statement showing ***.


import java.awt.*;
import javax.swing.*;
public class Demo2 extends JFrame
{
Demo2()
{
JButton b1=new JButton("Hello");
JButton b2=new JButton("Welcome");
setLayout(new GridLayout(1,1));
2543 add(b1); add(b2);
setSize(300,300);
setVisible(true);
setDefaultCloseOperation( ******** );
}
public static void main(String argv[])
{
Demo2 d=new Demo2();
}
}

A. LOWER_ON_CLOSE

B. EXIT_ON_CLOSE

C. MINIMIZE_ON_CLOSE

D. MAXIMIZE_ON_CLOSE

Answer optionb

Marks: 2

Analyse the following code and find out missing statement.


import java.awt.*;
public class ListEx extends Frame
{
List mobile;
ListEx()
{
mobile=new List(4,true);
2544 mobile.add("Nokia");
mobile.add("TATA");
mobile.add("Samsung");
mobile.add("SonyEricson");
mobile.add("Motorola");
mobile.add("BSNL");
add(mobile);
}
}

A. missing import java.awt.event.*;

B. missing {

C. missing main() method

D. missing }

Answer optionc

Marks: 2
Select the proper command to run the following code.
import java.awt.*;
public class MenuDemo extends Frame
{
Menu file,edit;
MenuItem new1,open,cut,copy;

MenuDemo()
{
MenuBar mbar=new MenuBar();
setMenuBar(mbar);

file=new Menu("File");
edit=new Menu("Edit");
mbar.add(file);
mbar.add(edit);

2545 new1=new MenuItem("New");


open=new MenuItem("Open");
cut=new MenuItem("cut");
copy=new MenuItem("copy");

file.add(new1);
file.add(open);
edit.add(cut);
edit.add(copy);

setVisible(true);
setSize(200,200);
}
public static void main(String args[])
{
MenuDemo j=new MenuDemo();
}
}

A. java MenuDemo.java

B. appletviewer MenuDemo.java

C. appletviewer MenuDemo.html

D. java MenuDemo

Answer optiond

Marks: 2

Analyse the following code and fill the appropriate statement in ___________________.
import java.applet.*;
import java.awt.event.*;
/*<applet code="MousePressedDemo" width=200 height=100>
</applet>*/
public class MouseDemo extends Applet implements
{
public void init()
{
addMouseMotionListener(this);
2546 }
public void mouseMoved(MouseEvent me)
{
showStatus("Mouse Moved at "+_______ +" , "+________);
}
public void mouseDragged(MouseEvent me)
{

}
}

me.getXCordinate()
A. me.getYCordinate()

me.getMouseX()
B. me.getMouseY()

me.getX()
C. me.getY()

me.getXPoint()
D. me.getYPoint();

Answer optionc

Marks: 2
Analyse the following code and fill the appropriate statement in ___________________.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="Scroll" width=200 height=200></applet>*/
public class Scroll extends Applet implements AdjustmentListener
{
Scrollbar hsb;
public void init()
2547 {
hsb=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,1000);
add(hsb);
hsb.addAdjustmentListener(this);
}
public void ________________(AdjustmentEvent ae)
{
showStatus("scrollbar value="+hsb.getValue());
}
}

A. scrollValueChanged

B. adjustmentValueChanged

C. adjustmentChanged

D. changedAdjustmentValue

Answer optionb

Marks: 2

Which exception is thrown by main() in the follwing program.


import java.net.*;
class InetAddressMethods
{
public static void main(String args[])
2548 {
InetAddress addr=InetAddress.getLocalHost();
System.out.println("Host Address="+addr.getHostAddress());
System.out.println("Host Name="+addr.getHostName());
}
}

A. UnknownException

B. HostUnknownException

C. UnknownHostException

D. All of the above

Answer optionc

Marks: 2

2549 Choose correct option which can used to create client socket with host as "localhost" and port as 6789.

A. Socket clientSocket = new Socket("localhost", 6789);

B. Socket clientSocket = new Socket( 6789,"localhost");

C. ClientSocket clientSocket = new ClientSocket( 6789,"localhost");

D. ClientSocket clientSocket = new ClientSocket("localhost",6789);

Answer optiona

Marks: 2

Analyse the following code and fill the appropriate statement in ___________________.
import java.sql.*;
class Record
{
public static void main(String args[])throws Exception
{
Class.forName("jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mydsn");
PreparedStatement stmt=con.prepareStatement("select * from emp where EmpName=?");
2550 stmt.______________
ResultSet rs=stmt.executeQuery();
System.out.println("EmpName\tDesignation\tSalary");
where(rs.next())
{
System.out.println(rs.getString(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3));
}
con.close();
}

A. setString(0,"Rahul");

B. setString(0,'Rahul');

C. setString(1,"Rahul");
D. setString(1,'Rahul');

Answer optionc

Marks: 2

Analyse the following code and find errors.


import java.sql.*;
class InsertRecord
{
public static void main(String args[])throws Exception
{
2551 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xyz");
Statement stmt=con.createStatement();
stmt.executeUpdate("insert into student (101,'Smith')");
con.close();
}
}

A. Error is in Connection establishment statement

B. Error is in insert query

C. Error is in query execution statement

D. No error

Answer optionb

Marks: 2

To DELETE all the records from CUSTOMERS table,fill the correct query statement in the ********* in the following code.
Consider CUSTOMER table with 5 fields such as (ID, NAME, AGE, ADDRESS , SALARY )
import java.sql.*;
class DeleteAllRecord
{
public static void main(String args[])throws Exception
{
2552 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xyz");
Statement stmt=con.createStatement();
stmt.executeUpdate("************");
con.close();
}
}

A. DELETE * FROM CUSTOMERS

B. DELETE ID,NAME,AGE,ADDRESS,SALARY FROM CUSTOMERS

C. DELETE FROM TABLE CUSTOMERS

D. DELETE FROM CUSTOMERS

Answer optiona

Marks: 2

To update SALARY=5000 for a customer whose age is 30 from CUSTOMERS table,fill the correct query statement in the ********* in the
following code. Consider CUSTOMER table with 5 fields such as (ID, NAME, AGE, ADDRESS , SALARY )
import java.sql.*;
class DeleteAllRecord
{
public static void main(String args[])throws Exception
{
2553 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:xyz");
Statement stmt=con.createStatement();
stmt.executeUpdate("************");
con.close();
}
}

A. UPDATE CUSTOMERS SALARY=5000 WHERE AGE=30

B. UPDATE CUSTOMERS SET SALARY=5000 IF AGE=30

C. UPDATE CUSTOMERS SET SALARY=5000 WHERE AGE=30

D. UPDATE CUSTOMERS SET SALARY=5000,AGE=30

Answer optionc

Marks: 2
To display ID, NAME and SALARY of a customer whose salary is greater than 2000 AND age is less tan 25 years from the CUSTOMERS table
, fill the correct query statement in the ********* in the following code. Consider CUSTOMER table with 5 fields such as (ID, NAME,
AGE, ADDRESS , SALARY )
import java.sql.*;
class DeleteAllRecord
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
2554 Connection con=DriverManager.getConnection("jdbc:odbc:xyz");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("************");
where(rs.next())
{
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3))
}
con.close();
}
}

A. SELECT ID, NAME, SALARY FROM CUSTOMERS WHERE SALARY > 2000 AND AGE < 25

B. SELECT * FROM CUSTOMERS WHERE SALARY > 2000 AND AGE < 25

C. SELECT ID, NAME, SALARY FROM CUSTOMERS WHOSE SALARY > 2000 AND AGE < 25

D. SELECT ID, NAME, SALARY FROM CUSTOMERS TABLE WHERE SALARY > 2000 AND AGE < 25

Answer optiona

Marks: 2

Analyse the following code and find out error.


import java.io.*;
import javax.servlet.*;
import.java.servlet.http.*;
public class HelloServlet extends HTTPServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
2555 throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1> Welcome to Servlet</h1>");
}
}

A. Error is in doGet() methods header line

B. Error is in package statement

C. Error is in PrintWriter statement

D. All of the above

Answer optionb

Marks: 2

Analyse the following code and find out error.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throwsServletException, IOException
{
2556 String data = request.getParameter("data");
Cookie cookie = new Cookie(data,"MyCookie");
request.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to "+data);
pw.close();
}
}

A. Error is in statement where cookie is created

B. Error is in statement where cookie is added

C. Both A and B

D. No Error

Answer optionc

Marks: 2
Select the proper command to run the following code.
import java.io.*;
import javax.servlet.*;
import.java.servlet.http.*;
public class HelloWorld extends HTTPServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
2557 throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1> Welcome to Servlet</h1>");
}
}

A. http://localhost/HelloWorld in browser's address box

B. http://www.localhost:8080/HelloWorld in browser's address box

C. http://8080:localhost/HelloWorld in browser's address box

D. http://localhost:8080/HelloWorld in browser's address box

Answer optiond

Marks: 2

To retrive session ID, fill the correct option in the ********* in the following Servlet code
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionTrack extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException
{
2558 HttpSession session = request.getSession(true);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<h1>Session Id="+*********);
out.println("</h1></body></html>");
}
}

A. session.getSessionId()

B. session.getId()

C. request.getId()

D. response.getId()

Answer optionb

Marks: 2

2559 Which following containers are not use a border Layout as their default layout?

A. Window

B. Frame

C. Dialog

D. Panel

Answer optiond

Marks: 1

2560 What method is used to specify a container's layout?

A. SetLayout()

B. getLayout()

C. LayoutMangaer()

D. getComponent()

Answer optiona

Marks: 1

2561 Which containers use a FlowLayout as their default layout?

A. Panel and Applet

B. Window and Applet


C. Frame and Panel

D. All of these

Answer optiona

Marks: 1

2562 Which of following Component subclasses that support painting.

A. Canvas

B. Frame

C. Applet

D. All of these

Answer optiond

Marks: 1

2563 which following class is not provides by swing package classes for java swing API

A. JButton

B. JTextField

C. JRadioButton

D. JItem

Answer optiond

Marks: 1

2564 What listener would you implement to be notified when the user has finished editing a text field by pressing Enter

A. ActionListener

B. actionPerformed

C. itemListener

D. TextComponentListener

Answer optiona

Marks: 1

2565 What interface is extended by AWT event listeners?

A. java.util.EventListener

B. java.awt.event

C. ActionListener

D. all of thses

Answer optiona

Marks: 1

2566 Which of following is not Event handling interface?

A. ActionListener

B. ContainerListener

C. FocusListener

D. ButtonListener

Answer optiond

Marks: 1

2567 Which Method is to get the object of URLConnection class

A. openConnection()
B. getInputStream()

C. getOutputStream()

D. getUrlConnection()

Answer optiona

Marks: 1

2568 What is third part of URL address?

A. Hostname

B. port number

C. file path

D. protocol

Answer optionb

Marks: 1

2569 Which of these method is to get IP address?

A. getAddress()

B. getHostAddress()

C. getLocalHost()

D. getHostId()

Answer optionb

Marks: 1

2570 which interface is used to to estblished link betweent data source and application

A. Connection

B. Driver

C. Driver Manager

D. none of the mentioned

Answer optiona

Marks: 1

2571 which of the following is not method of DriverManager class

A. registerDriver(Driver driver)

B. getConnection(String url)

C. deregisterDriver(Driver driver)

D. All of these

Answer optiond

Marks: 1

2572 Which of the following manages a list of database drivers in JDBC?

A. Collection

B. DriverManager

C. JDBC Driver

D. Statement

Answer optionb

Marks: 1

2573 When destroy() method of servlet gets called?


A. The destroy() method is called only once at the end of the life cycle of a servlet.

B. The destroy() method is called before the servlet has executed service method.

C. Both of the above.

D. None of the above.

Answer optiona

Marks: 1

Select missing statement in following code


import java.awt.*;
class First extends Frame{
First(){
Button b=new Button("click me");
b.setBounds(30,100,80,30);// setting button position

2574
setSize(300,300);//frame size 300 width and 300 height
setLayout(null);//no layout manager
setVisible(true);//now frame will be visible, by default not visible
}
public static void main(String args[]){
First f=new First();
}}

A. b.add()

B. Buton.add()

C. add(b)

D. ButtonListener.add()

Answer optionc

Marks: 2

To get output as shown in fig. complete following code?


import java.awt.*;
import javax.swing.*;
public class MyFlowLayout{
JFrame f;
MyFlowLayout(){
JButton b1=new JButton("1");
JButton b2=new JButton("2");
JButton b3=new JButton("3");
JButton b4=new JButton("4");
JButton b5=new JButton("5");
2575 f.add(b1);f.add(b2);f.add(b3);f.add(b4);f.add(b5);

f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new MyFlowLayout();
}
}

A. f=new JFrame(); f.setLayout(new FlowLayout(FlowLayout.RIGHT));

B. f.setLayout(new FlowLayout(FlowLayout.RIGHT));

C. f=new JFrame();

D. new JFrame(); setLayout(new FlowLayout(FlowLayout.RIGHT));

Answer optiona

Marks: 2

2576 Which are commomaly Used methods of JTextArea Class?

A. public void setRows(int rows)

B. public void append(String s)

C. public void insert(String s, int position)

D. All of These

Answer optiond

Marks: 2

Which of the following state is true in case of swing? A)Java swing components are platform-independent.B)Swing doesn't support
2577 pluggable look and feel.c)Swing follows MVC. D)Swing components are heavyweight.
A. A and C

B. A and D

C. A and B

D. A

Answer optiona

Marks: 2

Which of these method of DatagramPacket class is not used to find the destination address?
a) findAddress()
2578 b) getAllAddress()
c) Address()
d) none of above

A. a

B. b and c

C. c

D. d

Answer optiond

Marks: 2

select missing statement in following code? import java.io.*;


import java.net.*;
public class InetDemo{
public static void main(String[] args){
try{
2579 __________________________________________
System.out.println("Host Name: "+ip.getHostName());
System.out.println("IP Address: "+ip.getHostAddress());
}catch(Exception e){System.out.println(e);}
}
}

A. InetAddress ip=InetAddress.getByName("www.msbte.com");

B. InetAddress ip=InetAddress.getName("www.msbte.com");

C. InetAddress ip=InetAddress.Name("www.msbte.com");

D. InetAddress =InetAddress.getByName("www.msbte.com");

Answer optiona

Marks: 2

Which of the following creates a datagram socket and binds it with the available Port Number on the localhost machine

a)DatagramSocket()
2580 b)DatagramSocket(int port)
c)DatagramSocket(int port, InetAddress address)
d)none of the above

A. a

B. b

C. a and b

D. d

Answer optiona

Marks: 2

2581 which of the following is not true for Statement and PreparedStatment?

A. � standard Statement is used to create a Java representation of a literal SQL statement and execute it on the database. A PreparedStatement is a precompile

B. Statement use for general purpose access and PreparedStaement use when you plan to use SQL Statement Many times.

C. Statement is use when you are using static SQL Statements and PreparedStatement is use to access parameter at run time

D. None of above

Answer optiond

Marks: 2
2582 Which of the following is true about javax.servlet.error.message?

A. This attribute gives exact error message which can be stored and analysed after storing in a java.lang.String data type.

B. This attribute gives information about exception type which can be stored and analysed after storing in a java.lang.Class data type

C. This attribute gives status code which can be stored and analysed after storing in a java.lang.Integer data type.

D. This attribute gives information about URL calling the servlet and it can be stored and analysed after storing in a java.lang.String data type.

Answer optiona

Marks: 2

2583 What is the difference between GenericServlet and HttpServlet?

A. The GenericServlet is an abstract class that is extended by HttpServlet to provide HTTP protocol-specific methods. But HttpServlet extends the GenericServl

B. The GenericServlet does not include protocol-specific methods for handling request parameters, cookies, sessions and setting response headers. The HttpServ

C. GenericServlet is not specific to any protocol. HttpServlet only supports HTTP and HTTPS protocol.

D. all of the above

Answer optiond

Marks: 2

2584 Select the correct code for following output?

import javax.swing.*;
public class Combo {
JFrame f;
Combo(){
f=new JFrame("Combo ex");

String country[]={"India","Aus","U.S.A","England","Newzeland"};

cb.setBounds(50, 50,90,20);
f.add(cb);
A.
f.setLayout(null);
f.setSize(400,500);
f.setVisible(true);

}
public static void main(String[] args) {
new Combo();

}
}

import javax.swing.*;
public class Combo {
JFrame f;
Combo(){
f=new JFrame("Combo ex");

String country[]={"India","Aus","U.S.A","England","Newzeland"};

JComboBox cb=new JComboBox(country);


cb.setBounds(50, 50,90,20);
B.
f.setLayout(null);
f.setSize(400,500);
f.setVisible(true);

}
public static void main(String[] args) {
new Combo();

}
}

import javax.swing.*;
public class Combo {
JFrame f;
Combo(){

String country[]={"India","Aus","U.S.A","England","Newzeland"};

JComboBox cb=new JComboBox(country);


cb.setBounds(50, 50,90,20);
f.add(cb);
C.
f.setLayout(null);
f.setSize(400,500);
f.setVisible(true);

}
public static void main(String[] args) {
new Combo();

}
}
import javax.swing.*;
public class Combo {
JFrame f;
Combo(){
f=new JFrame("Combo ex");

String country[]={"India","Aus","U.S.A","England","Newzeland"};

JComboBox cb=new JComboBox(country);


cb.setBounds(50, 50,90,20);
f.add(cb);
D.
f.setLayout(null);
f.setSize(400,500);
f.setVisible(true);

}
public static void main(String[] args) {
new Combo();

}
}

Answer optiond

Marks: 2

Select missing statement form following code using output? import javax.swing.*;
public class MyTable {
JFrame f;
MyTable(){
f=new JFrame();

String data[][]={ {"101","Amit","670000"},


{"102","Jai","780000"},
{"101","Sachin","700000"}};
String column[]={"ID","NAME","SALARY"};

2585
JScrollPane sp=new JScrollPane(jt);
f.add(sp);

f.setSize(300,400);
// f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new MyTable();
}
}

JTable jt=new JTable(data,column);


A. jt.setBounds(30,40,200,300);

B. JTable jt=new JTable(data,column);

JTable jt=new JTable


C. jt.setBounds(30,40,200,300);

D. jt.setBounds(30,40,200,300);

Answer optiona

Marks: 2

What is the result of executing the following Java class:

import java.awt.*;

public class FrameTest extends Frame {


public FrameTest() {
add (new Button("First"));
add (new Button("Second"));
add (new Button("Third"));
pack();
setVisible(true);
}
2586
public static void main(String args []) {
new FrameTest();
}
}

Select from the following options:

A. Only the "third" button is displayed.


B. A runtime exception is generated (no layout manager specified).
C. Only the "first" button is displayed.
D. Only the "second" button is displayed.

A. A

B. B

C. C

D. D

Answer optiona

Marks: 2
Which of these methods is defined in MouseMotionAdapter class?a) mouseDragged()
b) mousePressed()
2587 c) mouseReleased()
d) all the above

A. a

B. b

C. c

D. d

Answer optiond

Marks: 2

Select correct order of event handling steps?


a) The User clicks the button and the event is generated.
2588 b) Event object is forwarded to the method of registered listener class.
c) the method is get executed and returns. d) the object of concerned event class is created automatically and information about
the source and the event get populated with in same object.

A. a,d,b,c

B. a,b,c,d

C. a,d,c,b

D. a,b,c,d

Answer optiona

Marks: 2

Complete following code for given output?import java.awt.*;


import java.awt.event.*;
class ListAction extends Frame
{List list;
Label label;
public ListAction()
{ setTitle("List with ItemListener Demo");
setSize(400,400);
setLayout(new FlowLayout());
setLocationRelativeTo(null);
setVisible(true);
list=new List();
label=new Label();
list.add("Apple");
list.add("Mango");
list.add("Guava");
2589 list.add("Orange");
list.add("Pineapple");
list.add("Grapes");

public void itemStateChanged(ItemEvent ie)


{
label.setText("You selected "+list.getSelectedItem());
}
});

}
public static void main(String args[])
{
new ListAction();
}
}

add(list);
A. list.addItemListener(new ItemListener(){

add(list);
B. add(label);

add(label);
C. list.addItemListener(new ItemListener(){

add(list);
D. add(label);
list.addItemListener(new ItemListener(){

Answer optiond

Marks: 2
Select missing code from following code using output
import java.awt.*;
import java.awt.event.*;

class AEvent extends Frame implements ActionListener{


TextField tf;
AEvent(){

tf=new TextField();
tf.setBounds(60,50,170,20);

Button b=new Button("click me");


2590 b.setBounds(100,120,80,30);

setSize(300,300);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
tf.setText("Welcome");
}
public static void main(String args[]){
new AEvent();
}
}

addActionListener(this);
A. add(b);add(tf);

B. add(b);add(tf); addActionListener(this);

C. b.addActionListener(this);

b.addActionListener(this);
D.
add(b);add(tf);

Answer optiond

Marks: 2

what is out put of following code? import java.io.*;


import java.net.*;
public class URLConnectionExample {
public static void main(String[] args){
try{
URL url=new URL("http://www.msbte.com/java-tutorial");
URLConnection urlcon=url.openConnection();
2591 InputStream stream=urlcon.getInputStream();
int i;
while((i=stream.read())!=-1){
System.out.print((char)i);
}
}catch(Exception e){System.out.println(e);}
}
}

Protocol: http
Host Name: www.msbte.com
A. Port Number: 1024
File Name: /java-tutorial

Protocol: http
Host Name: www.msbte.com
B. Port Number: -1
File Name: /java-tutorial

Protocol: http
Host Name: www.msbte.com
C. Port Number: 0080
File Name: none

Protocol: http
Host Name: www.msbte.com
D. Port Number: 1175
File Name: /java-tutorial

Answer optionb

Marks: 2

select missing statement in following code


import java.sql.*
class connection

{
public static void main(String args[ ])
2592 { try{
Class.forName("sun.jdbc:odbc:jdbcodbcDrive);
System.ot.println("Drivers are equals");
con.Close();
catch(SQLException s)
{ System.out.Println("SQL Error");
}catch(Exception e) { System.out.println("Connection Error"); } }

A. String url=jdbc:odbc:abc; Connection con=DriverManager.getConnection(url);

B. Connection con=DriverManager.getConnection("jdbc:odbc:abc");

C. String url="jdbc:odbc:abc"; Connection con=getConnection(url);


D. Connection con=getConnection("jdbc:odbc:abc");

Answer optionb

Marks: 2

The following example to connect Java Application with access?


import java.sql.*;
class Test{
public static void main(String ar[]){
try{
String url="jdbc:odbc:mydsn";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection(url);
Statement st=c.createStatement();
2593 ResultSet rs=st.executeQuery("select * from login");

while(rs.next()){
System.out.println(rs.getString(1));
}

}catch(Exception ee){System.out.println(ee);}

}}

A. With DSN

B. With out DSN

C. Both A & B

D. None of the above

Answer optiona

Marks: 2

init(),service() and destroy()methods are define in


1.javax.servlet.Servlet interface
2594 2.javax.servlet.ServletHttp class
3.javax.ServletRequest interface
4.javax.servlet.ServletResponse interface

A. 1,2,4

B. 1

C. 1,2

D. 1,2,3

Answer optiona

Marks: 2

Which of the following statements are not correct about the servelt over CGI

A. Performance is significantly better.


2595 B. Servlets does not execute within the address space of a Web server
C. Servlets are platform-independent because they are written in Java.
D. The full functionality of the Java class libraries is available to a servlet

A. A only

B. B and C

C. B only

D. None of above

Answer optionc

Marks: 2

Select missing statement form following code ?


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
private String message;
public void init() throws ServletException
{
message = "Hello World";
}
2596
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1>" + message + "</h1>");
}
public void destroy()
{

}
}
public void doGet(HttpServletRequest request)
A. throws ServletException, IOException

public void Get(HttpServletRequest request,


B. HttpServletResponse response)
throws ServletException, IOException

public void doGet(HttpServletRequest request,


C. HttpServletResponse response)

public void doGet(HttpServletRequest request,


D. HttpServletResponse response)
throws ServletException, IOException

Answer optiond

Marks: 2

2597 Which method is used to add tabs to a JTabbedPane?

A. addTabbed

B. addTab

C. setTabAt

D. setTabbedPane

Answer optionb

Marks: 1

2598 The top level windows in Swings are_______________

A. JFrame

B. Japplet

C. JWindow

D. All of the above

Answer optiond

Marks: 1

2599 Default layout of JPanel is

A. BorderLayout

B. FlowLayout

C. GridLayout

D. None of the above.

Answer optionb

Marks: 1

2600 To put a line as a separator_____________ is used

A. JLiner

B. JSeparator

C. (i)and (ii) both

D. None of these

Answer optionb

Marks: 1

2601 which of these is protocal for breaking and sending packets to an address accross a network?

A. TCP/IP

B. DNS

C. Socket

D. proxy Server
Answer optiona

Marks: 1

2602 ________method is used to find the host of URL?

A. gethost()

B. GetHost()

C. Gethost()

D. getHost()

Answer optiona

Marks: 1

2603 Sockets are _________points of communication

A. Start

B. End

C. Mid

D. None of these

Answer optionb

Marks: 1

2604 The JDBC-ODBC bridge driver resolves__________and makes equivalent____________

A. JDBC call, ODBC call

B. ODBC call, ODBC call

C. ODBC call, JDBC call

D. JDBC call, JDBC call

Answer optiona

Marks: 1

2605 The______________object provides you with methods to access data from the table.

A. ResultSet

B. Parametrized

C. TableStatment

D. Condition

Answer optiona

Marks: 1

2606 Which method of the component class is used to set the position and size of a component in JSP?

A. setBounds()

B. setPosition()

C. setSizePosition()

D. setSize()

Answer optiona

Marks: 1

2607 How to give number of columns for JTextField?

A. Use setColumns( ) method

B. Use the value directly in the constructor

C. Using applyColumn( ) method.


D. We have to use JTextArea class

Answer optionb

Marks: 2

2608 The constructor JCheckBox(true, �YES�) suggests that �

A. Checkbox is selected and displays the string “YES” on it.

B. Checkbox is deselected and displays the string “YES” on it.

C. Checkbox is selected and it shows the tick always on it.

D. There is no such constructor.

Answer optiona

Marks: 2

2609 Which of the following is true?

A. JButton inherits from javax.swing.AbstractButton.

B. You can create a JButton by specifying an icon and text.

C. You can create a JButton by specifying an icon.

D. You can create a JButton by a text.

Answer optionb

Marks: 2

2610 Which of these is superclass of all Adapter classes?

A. Applet

B. ComponentEvent

C. Event

D. InputEvent

Answer optiona

Marks: 2

2611 The___________method in the InetAddress class returns the IP address.

A. getIP()

B. getIPAddress()

C. getHostAddress()

D. getAddress()

Answer optionc

Marks: 2

2612 To obtain an ObjectInputStream from a socket, use___________

A. socket.getInputStream()

B. socket.getObjectStream()

C. socket.getObjectInputStream()

D. new ObjectInputStream(socket.getInputStream());

Answer optiond

Marks: 2

2613 Connection object can be initialized using the___________________________ method of the Driver Manager class.

A. PutConnection()

B. setConnection()
C. Connection()

D. getConnetion()

Answer optiond

Marks: 2

2614 The JDBC-ODBC Bridge driver translates the JDBC API to ODBC API and used with_____________________

A. JDBC drivers

B. ODBC driver

C. Both A and B

None of the above


D.

Answer optionb

Marks: 2

2615 The GET and POST methods are specified in _________.

A. a CGI program

B. a Java program

C. � an HTML form

D. a URL string

Answer optionc

Marks: 2

How many frame are displayed?


import javax.swing.*;
public class Test
{
public static void main(String args[])
{
JFrame f1=new JFrame("My Frame");
2616 JFrame f2=f1;
JFrame f3=f2;
f1.setVisible(true);
f2.setVisible(true);
f3.setVisible(true);
}
}

A. 1

B. 2

C. 3

D. 0

Answer optiona

Marks: 2

Analyze the follwing code: import javax.swing.*;


import java.awt.*;
public class Test extends JFrame
{
public Test(){
setLayout(new FlowLayout());
add(new JButton("Java"));
add(new JButton("Java"));
add(new JButton("Java"));
2617 add(new JButton("Java"));
}
public static void main(String args[]){
JFrame frame=new Test();
frame.setSeize(200,100);
frame.setDefaultCloseOperation(JFrame.ExIT_ON_CLOSE);
frame.setVisible(true);
}
}

A. one button is displayed with the text "Java".

B. Two buttons are displayed with the same text "Java".

C. Three button are displayed with the same text "Java".

D. Four buttons are displayed with the same text "Java".


Answer optiond

Marks: 2

2618 The component for storing and handling data, known as _________, contains the actual contents of the component.

A. a model

B. a view

C. a controller

D. all of the mentioned

Answer optiona

Marks: 2

2619 preparedstatement Object in JDBC is used to execute__________________queries.

A. executable

B. simple

C. high level

D. parameterized

Answer optiond

Marks: 2

2620 Which of the following JDBC Driver refers to a pure Java dreiver that uses a middleware driver to connect to a databse?

A. Type-1 Driver

B. Type-2 Driver

C. Type-3 Driver

D. Type-4 Driver

Answer optionc

Marks: 2

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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
2621 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();
}
}

A. Error in main()

B. Error in loop

C. Error in connection statement

D. Error in close()

Answer optiona

Marks: 2
Choose missing statements in following code from given options. import java.sql.*;
class StudentData
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:stud");
PreparedStatement ps = con.prepareStatement("select *from Student where Marks > ?");
2622 ps.setInt(1,70);
ResultSet rs = ps.*******************;
System.out.println("Students having marks > 70 are:");
while(rs.next())
System.out.println(rs.getString(2));
con.close();
}
catch(Exception e){ }
}
}

A. executeQuery()

B. execute()

C. executeUpdate()

D. resultSet()

Answer optiona

Marks: 2

2623 How can you retrive information fron a ResultSet?

A. By invoking method get(… ,String type) on the ResultSet, where type is the database type

B. By invoking method get(… ,Type type) on the ResultSet, where Type is an object which represent a database type

C. By invoking method getValue(… ), and cast the result to the desired java type

D. By invoking the special getter methods on the ResultSet:getString(…), getBoolean(…), getClob(…),…..

Answer optiond

Marks: 2

What's the difference between servlets and applet?


1.Servlet executes on Server, where as Applet exeutes on Browser
2624 2.Servlet hava no GUI, where as an Applet has GUI
3.Servlet creates static web pages, where as Applet created dynamic web pages
4.Servlet can handle only a single request, where as Applet can handle multiple request

A. 1,2,3 are correct

B. 1,2 are correct

C. 1,3 are correct

D. 1,2,3,4 are correct

Answer optionb

Marks: 2

2625 Which of the following creates a radio button in an HTML form?

A. <input type="text" name="mi" size="1">

B. <input type="radio" name="gender" value="M" checked>

C. <input type="checkbox" name="tennis"> Tennis

D. <input type="checkboxGroup" name="tennis">

Answer optionb

Marks: 2

2626 If your servlet class file has a package statement package chapter5, the servlet .class file must be placed in ________ by default.

A. the same directory with the .java file.

B. TomcatRootDir\webapps\WEB-INF\classes

C. TomcatRootDir\webapps\examples\WEB-INF\classes

D. TomcatRootDir\webapps\examples\WEB-INF\classes\chapter5
Answer optiond

Marks: 2

2627 Container is a base class of ___________

A. Panel

B. Window

C. Both Panel and Window

D. None of these

Answer optionc

Marks: 1

2628 Components can be added to a Panel object by using ______________ method

A. add()

B. include()

C. insert()

D. None of these

Answer optiona

Marks: 1

2629 ImageIcon property can be set for ___________class.

A. Label

B. JButton

C. List

D. Checkbox

Answer optionb

Marks: 1

2630 ____________ method is used to set tool tip text for a component

A. setToolTipText()

B. SettoolTip()

C. setTooltiptext()

D. setText()

Answer optiona

Marks: 1

2631 To change orientation of JProgressBar__________ method is used.

A. void SetOrientation()

B. void setOrientation(int)

C. void setorientation()

D. None of these

Answer optionb

Marks: 1

2632 A ____________ component is used to represent hierarchical view of data.

A. JTree

B. JTable

C. JTabbedPane
D. ScrollPaneConstants

Answer optiona

Marks: 1

2633 _________method is a general form, used to register a source with Listener.

A. addListener()

B. addTypeListener()

C. removeTypeListener()

D. None of these

Answer optionb

Marks: 1

2634 Which of these events will be generated if we close an applet window?

A. ActionEvent

B. AdjustmentEvent

C. ItemEvent

D. WindowEvent

Answer optiond

Marks: 1

2635 Which of the following is a valid method of MouseListener interface.

A. mouseDragged()

B. mouseMoved()

C. mousePressed()

D. All of these

Answer optionc

Marks: 1

2636 The ServerSocket class is designed to be "listener" which waits for clients to connect before doing anything.

A. TRUE

B. FALSE

C.

D.

Answer optiona

Marks: 1

2637 ________ loads database drivers and manages the connection between application and the driver.

A. Driver

B. DriverManager

C. Statement

D. PreparedStatement

Answer optionb

Marks: 1

2638 _________ method is not a navigation method of ResulSet

A. first()

B. next()
C. last()

D. execute()

Answer optiond

Marks: 1

2639 Return type of executeQuery() method is ___________

A. int

B. ResultSet

C. void

D. Statement

Answer optionb

Marks: 1

2640 For execution of UPDATE SQL query in JDBC_____________ method is used.

A. executeQuery()

B. executeUpdate()

C. execute()

D. All of these

Answer optionb

Marks: 1

2641 init() method is provided by ___________ interface.

A. ServletConfig

B. Servlet

C. ServletContext

D. ServletRequest

Answer optionb

Marks: 1

2642 __________ class provides implementations of the basic life cycle methods for a servlet

A. ServletInputStream

B. ServletOutputStream

C. GenericServlet

D. ServletException

Answer optionc

Marks: 1

2643 ________________ allows session data to be read and written.

A. GenericServlet class

B. HttpSession interface

C. ServletConfig interface

D. None of these

Answer optionb

Marks: 1

2644 Which of the following statements are true?

A. JSP is translated into Java servlet by a Web server when a JSP is called.
B. JSP is translated into HTML by a Web server when a JSP is called.

C. JSP is translated into XML by a Web server when a JSP is called.

None of these
D.

Answer optiona

Marks: 1

2645 Identify components which are used to get the following output

A. Applet, MenuItem, Checkbox

B. Frame, Menu, MenuItem, CheckboxMenuItem

C. Frame, Menu, MenuItem, Checkbox

D. Applet, MenuItem, Menu

Answer optionb

Marks: 2

2646 Which is the valid constructor of Scrollbar?

A. Scrollbar(int,int)

B. Scrollbar(int)

C. Scrollbar(int,int,int,int)

D. Scrollbar(float)

Answer optionb

Marks: 2

2647 What is the purpose of JTabbedPane?

A. component that appears as tree stucture

B. component that appears as a group of folders in a file cabinet.

C. component that appears as rows and columns

D. None of these

Answer optionb

Marks: 2

2648 Which event and listener will be used if we close a frame window?

A. MouseEvent and MouseMotionListener

B. AdjustmentEvent and AdjustmentListener

C. ItemEvent and ItemListener

D. WindowEvent and WindowListener

Answer optiond

Marks: 2
Select the missing statements shown by _________in given code
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class CheckboxDemo extends Applet implements ______________
{
Checkbox c1,c2,c3;
public void init()
{
CheckboxGroup cbg=new CheckboxGroup ();
c1=new Checkbox("Red",cbg,false);
c2=new Checkbox("Green",cbg,false);
c3=new Checkbox("Blue",cbg,false);
add(c1);add(c2);add(c3);
2649 c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
}
public void _____________(ItemEvent i)
{
if(c1.getState())
setBackground(Color.RED);
else if(c2.getState())
setBackground(Color.GREEN);
else
setBackground(Color.BLUE);
}
}
/*<applet code=CheckboxDemo.class width=500 height=500></applet>*/

A. ItemListner, itemStateChanged

B. ItemListner, adjustmentValueChanged

C. ActionListner, itemStateChanged

D. None of these

Answer optiona

Marks: 2

Find missing statements in the following code shown by ____________


import java.awt.*;
import java.awt.event.*;
public class AdapterDemo extends Frame
{
AdapterDemo()
{
_______________(new MyAdapter(this));
setSize(500,500);
}
public static void main(String args[])
{
AdapterDemo a=new AdapterDemo();
a.setVisible(true);
2650 }
}
class MyAdapter extends WindowAdapter
{
AdapterDemo a;
MyAdapter(AdapterDemo a1)
{
a=a1;
}
public void windowClosing(______________ w)
{
System.exit(0);
}
}

A. addWindowListener,WindowEvent

B. addMouseListener,MouseEvent

C. addWindowFocusListener,WindowEvent

D. All of these

Answer optiona

Marks: 2

2651 Select correct static/factory method of InetAddress class

A. getByName(String hostname)

B. getAddress()

C. getHostAddress()

D. getHostName()

Answer optiona

Marks: 2
2652 Which of the following method is not defined by URL class

A. getHostName()

B. getHost()

C. getProtocol()

D. getPort()

Answer optiona

Marks: 2

2653 Identify the proper constructor of Socket class

A. Socket(int port)

B. Socket(String hostname,int port)

C. Socket(int port,int maxqueue)

D. Socket(String hostname)

Answer optionb

Marks: 2

2654 Which constructor does not belong to DatagramPacket class?

A. DatagramPacket(int)

B. DatagramPacket(byte[],int)

C. DatagramPacket(byte[],int,int)

D. DatagramPacket(byte[],int,InetAddress,int)

Answer optiona

Marks: 2

2655 Which is not a static constant defined by ResultSet interface.

A. TYPE_FORWARD_ONLY

B. TYPE_SCROLL_INSENSITIVE

C. TYPE_SCROLL_SENSITIVE

D. CONCUR_READ

Answer optiond

Marks: 2

2656 What is the return type of createStatement() method defined by Connection interface?

A. PreparedStatement

B. Statement

C. CallableStatement

D. ResultSet

Answer optionb

Marks: 2

2657 Identify the proper syntax of getConnection() method.

A. Connection getConnection()

B. Connection getConnection(int)

C. Connection getConnection(String)

D. Connection getConnection(int,int)

Answer optionc
Marks: 2

Identify correct option related to Cookie


A. Cookies allows state information to be stored on a client machine.
2658 B. Cookies are valuable for tracking user activities.
C. Provides methods to handle HTTP requests and inputstream.

A. A and C

B. B and C

C. only C

D. A and B

Answer optiond

Marks: 2

2659 How to access setContentType() method in servlet?

A. response.setContentType("text/html")

B. request.setContentType()

C. PrintWriter setContentType()

D. None of these

Answer optiona

Marks: 2

Debug the following code and find out the statement containing error
import java.applet.*;
import java.awt.*;
public class CheckboxGroupDemo extends Applet
{
Checkbox c1,c2,c3;
CheckboxGroup cbg;
public void init()
{
2660 cbg=new CheckboxGroup("c1");
c1=new Checkbox("Red",true,cbg);
c2=new Checkbox("Green",cbg,false);
c3=new Checkbox("Blue",cbg,true);
add(c1);
add(c2);
add(c3);
}
}
/*<applet code=CheckboxGroupDemo.class width=400 height=400></applet>*/

A. Statement where CheckboxGroup is created

B. Statement where Checkbox c1 is created

C. Statement where Checkbox c2 is created

D. Statement where Checkbox c3 is created

Answer optiona

Marks: 2

2661 To get the following output, identify correct code

import java.awt.*;
import java.applet.*;
public class LargestDemo extends Applet
{
Label l1,l2,l3;
TextField t1,t2,t3;
Button b1;
public void init()
{
setLayout(new GridLayout(4,2));
l1=new Label("Enter First NO.");
l2=new Label("Enter Second NO.");
A. l3=new Label("Largest No");
t1=new TextField();
t2=new TextField();
t3=new TextField();
b1=new Button("Largest");
add(l1);add(t1);
add(l2);add(t2);
add(l3);add(t3);
add(b1);
}
}
/*<applet code= LargestDemo.class width=300 height=300></applet>*/
import java.awt.*;
import java.applet.*;
public class LargestDemo extends Applet
{
Label l1,l2,l3;
TextField t1,t2,t3;
Button b1;
public void init()
{
setLayout(new GridLayout(3,3));
l1=new Label("Enter First NO.");
l2=new Label("Enter Second NO.");
B. l3=new Label("Largest No");
t1=new TextField();
t2=new TextField();
t3=new TextField();
b1=new Button("Largest");
add(l1);add(t1);
add(l2);add(t2);
add(l3);add(t3);
add(b1);
}
}
/*<applet code= LargestDemo.class width=300 height=300></applet>*/

import java.awt.*;
import java.applet.*;
public class LargestDemo extends Applet
{
Label l1,l2,l3;
TextField t1,t2,t3;
Button b1;
public void init()
{
setLayout(new GridLayout(4,3));
l1=new Label("Enter First NO.");
l2=new Label("Enter Second NO.");
C. l3=new Label("Largest No");
t1=new TextField();
t2=new TextField();
t3=new TextField();
b1=new Button("Largest Button");
add(l1);add(t1);
add(l2);add(t2);
add(l3);add(t3);
add(b1);
}
}
/*<applet code= LargestDemo.class width=300 height=300></applet>*/

import java.awt.*;
import java.applet.*;
public class LargestDemo extends Applet
{
Label l1,l2,l3;
TextField t1,t2,t3;
Button b1;
public void init()
{
setLayout(new GridLayout(3,4));
l1=new Label("Enter First NO.");
l2=new Label("Enter Second NO.");
D. l3=new Label("Largest No");
t1=new TextField();
t2=new TextField();
t3=new TextField();
b1=new Button("Largest Button");
add(l1);add(t1);
add(l2);add(t2);
add(l3);add(t3);
add(b1);
}
}
/*<applet code= LargestDemo.class width=300 height=300></applet>*/

Answer optiona

Marks: 2

Debug the following code and idntify statements containing error.


import java.awt.*;
import java.applet.*;
public class BorderDemo extends Applet
{
BorderLayout b;
Button b1,b2,b3,b4,b5;
public void init()
{
b=new BorderLayout();
setLayout(b);
b1=new Button("TOP");
2662 b2=new Button("LEFT");
b3=new Button("BOTTOM");
b4=new Button("RIGHT");
b5=new Button("CENTER");
add(b1,BorderLayout.TOP);
add(b3,BorderLayout.BOTTOM);
add(b4,BorderLayout.EAST);
add(b2,BorderLayout.WEST);
add(b5,BorderLayout.CENTER);
}
}
/*<applet code=BorderDemo.class width=500 height=500></applet>*/

A. Statements where buttons b1 and b3 are added to the applet

B. Statements where buttons b2 and b4 are added to the applet


C. Statements where buttons b2 and b5 are added to the applet

D. Statements where buttons b4 and b5 are added to the applet

Answer optiona

Marks: 2

Find out missing statements shown by ___________


import ____________.*;
import java.awt.*;
public class JTableDemo extends JApplet
{
public void init()
{
Container c=_____________();
String headings[]={"ROllNO","NAME","PERCENT","GRADE"};
2663 Object data[][]={{1,"ABC",70,"A+"},{2,"PQR",80,'A'},
{3,"XYZ",50,'B'},{4,"LMN",55.33,'B'},
{5,"PQR",90,"A+"},{6,"SDF",45,'C'}};
JTable t=new JTable(data,headings);
t.setGridColor(Color.RED);
JScrollPane s=new JScrollPane(t,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
c.add(s,BorderLayout.CENTER);
}
}
/*<applet code=JTableDemo.class width=200 height=250></applet>*/

A. java.awt,getContentPane

B. javax.swing,getContentPane

C. javax.swing,getPane

D. None of these

Answer optionb

Marks: 2

Find out missing statements shown by ______________


import java.awt.event.*;
import java.applet.*;
public class InnerAdapter extends _________
{
public void init()
{
addMouseListener(new MyAdapter());
}
2664 class MyAdapter extends _________________
{
public void mousePressed(MouseEvent m)
{
showStatus("MOUSE PRESSED");
}
}
}
/*<applet code=InnerAdapter.class width=500 height=500></applet>*/

A. Applet, MouseAdapter

B. Frame, MouseMotionAdapter

C. Frame, MouseAdapter

D. Applet, MouseMotionAdapter

Answer optiona

Marks: 2
Select statements in the following code containing error
import java.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JRadioDemo extends JApplet implements ActionListener
{
JRadioButton r1,r2,r3;
Container c;
public void init()
{
c=getContentPane();
c.setLayout(new FlowLayout());
r1=new JRadioButton("Red");
r2=new JRadioButton("Green");
r3=new JRadioButton("Blue");
Buttongroup b=new Buttongroup();
2665 b.add(r1);b.add(r2);b.add(r3);
c.add(r1);c.add(r2);c.add(r3);
r1.addActionListener(this);
r2.addActionListener(this);
r3.addActionListener(this);
}
public void actionPerformed(ActionEvent a)
{
if(a.getSource()==r1)
c.setBackground(Color.RED);
else if(a.getSource()==r2)
c.setBackground(Color.GREEN);
else
c.setBackground(Color.BLUE);
}
}
/*<applet code=JRadioDemo.class width=500 height=500></applet>*/

A. Statement where swing package is imported and buttongroup is cretated

B. Statement where awt package is imported and actionlistener is implemented

C. Statement where getContentPane() method is called

D. Statement where setLayout() method is called

Answer optiona

Marks: 2

Identify statements containing error in the following code


import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class CheckBoxDemoEvent extends JApplet implements ItemListener
{
Checkbox c1,c2,c3;
CheckboxGroup cbg;
public void init()
{
cbg=new CheckboxGroup();
setLayout(new FlowLayout());
c1=new Checkbox("CO",false,cbg);
c1.addItemListener(this);
2666 c2=new Checkbox("IF",cbg,false);
c2.addItemListener(this);
c3=new Checkbox("CE",false,cbg);
c3.addactionListener(this);
add(c1);
add(c2);
add(c3);
}
public void itemStateChanged(ActionEvent ie)
{
showStatus("Currently Selected option"+((Checkbox)ie.getSource()).getLabel());
}
}
/*<applet code=CheckBoxDemoEvent.class width=200 height=200></applet>*/

A. Statements where listener is registered for c3 and itemStateChanged() is called

B. Statements where listener is registered for c2

C. Statements where listener is registered for c1

D. None of these

Answer optiona

Marks: 2
Consider the following output. Find the missing statement in the program shown by ____________.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/*
<applet code="KeyEventDemo" width=300 height=100>
</applet>
*/
public class KeyEventDemo extends JApplet
implements ______________
{
String msg = "";
int X = 10, Y = 20;
public void init()
{
addKeyListener(this);
requestFocus();
2667
}
public void keyPressed(________________ k)
{
showStatus("Key Down");
}
public void keyReleased(KeyEvent ke)
{
showStatus("Key Up");
public void keyTyped(KeyEvent ke)
{
msg += ke.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, X, Y);
}
}

A. KeyListener,KeyEvent

B. AdjustmentListener,AdjustmentEvent

C. ItemListener,ItemEvent

D. ActionListener,ActionEvent

Answer optiona

Marks: 2

Find out the missing statements in the following code shown by

import __________.*;
import java.io.*;

public class Demo


{
2668 public static void main(String args[]) throws MalformedURLException
{
URL url = new __________("http://www.msbte.com/curriculum.php");
System.out.println("Port="+ url.getPort());
System.out.println("Host="+ url.getHost());
}
}

A. javax.swing,URLConnection

B. java.net,URL

C. java.net,URLConnection

D. java.sql,ServerSocket

Answer optionb

Marks: 2

Find out the missing statements in the following code shown by __________
import ___________.*;
class InetAddressDemo1
{
public static void main(String args[])throws UnknownHostException
{
2669 ______________ ia=InetAddress.getLocalHost();
System.out.println(ia);
String addr=ia.get____________();
System.out.println("IP Address="+addr);
}
}

A. java.net,InetAddress,HostAddress

B. java.io,ServerSocket,HostName

C. java.net,Socket,HostName

D. None of these
Answer optiona

Marks: 2

What should be the correction done in the following program to get correct output?
import java.sql.*;
import java.io.*;
class InsertDemo
{
public static void main(String args[])
{
int c=0;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
2670 String myURL="jdbc:odbc:EmpDSN";
Connection con=DriverManager.getConnection(myURL);
Statement st=con.createStatement();
c=st.executeUpdate("insert into emp values(1,20000)")
if(c!=0)
System.out.println("Record inserted");
else
System.out.println("Record NOT inserted");
con.close();
}catch(Exception e){}
}
}

A. missing {

B. missing }

C. missing semicolon

D. missing statement

Answer optionc

Marks: 2

What should be the correction done in the program to get correct output?
class Demo
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:MyDSN");
Statement s=cn.createStatement();
ResultSet rs=s.executeQuery("select *from Student");
2671 System .out.println("Name" + " \t " + "Roll_No");
while(rs.next())
{
System.out.println(rs.getString(1)+" \t "+rs.getInt(2));
}
s.close();
c.close();
}
}

A. Missing semicolon

B. Missing {

C. Missing }

D. Missing package statement.

Answer optiond

Marks: 2

Select the statement that must be added to the following program to get the correct output.
import java.sql.*;
import java.io.*;
class DisTable1
{
public static void main(String args[])
{
int id=0;
String name="",addr="";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
2672 Connection cn=DriverManager.getConnection("jdbc:odbc:mydsn");
Preparedstatement pst=cn.prepareStatement("select * from emp");
System.out.println("EmpId\t"+"Name\t"+"Address");
while(rs.next())
{
System.out.print(rs.getInt(1)+"\t");
System.out.print(rs.getString(2)+"\t");
System.out.print(rs.getString(3)+"\n");
}
cn.close();
}catch(Exception e){}
}
}

A. ResultSet rs=pst.executeQuery();

B. Resultset rs=pst.ExecuteQuery();
C. Connection con=DriverManager.getConnection("jdbc:odbc:mydsn","","");

D. None of these

Answer optiona

Marks: 2

What should be the correction done in the following program to get correct output?
import java.sql.*;
import java.io.*;
class DemoInsert
{
public static void main(String args[])
{
int u=0;
try
{
Class.ForName("sun.jdbc.odbc.JdbcOdbcDriver");
2673 String myURL="jdbc:odbc:MyDSN";
Connection con=DriverManager.getConnection(myURL);
Statement st=con.createStatement();
c=st.executeUpdate("insert into student values(1,50)");
if(u!=0)
System.out.println("Record inserted");
else
System.out.println("Record NOT inserted");
con.close();
}catch(Exception e){}
}
}

A. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

B. Class.Forname("sun.jdbc.odbc.JdbcOdbcDriver");

C. Class.forName("sun.jdbc.odbc.jdbcodbcDriver");

D. Missing ;

Answer optiona

Marks: 2

Choose missing statement in following code from given options.


import javax.servlet.*;
import javax.servlet.http.*;
public class SessionDemo extends HTTPServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
2674 {
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
HttpSession hs=req.getSession(true);
pw.println("Session ID= "+hs.getId());
}
}

A. import java.io.*;

B. import java.net.*;

C. import java.sql.*;

D. import java.util.*;

Answer optiona

Marks: 2

Find out the missing statements shown by _____________


import javax.servlet.*;
public class HelloServlet extends GenericServlet
{
public void service(______________ req,____________ res)throws ServletException,IOException
{
2675 res.setContentType("text/html");
PrintWriter pw=res.getWriter();
pw.println("Hello Students");
pw.close();
}
}

A. ServletRequest,HttpSession

B. ServletRequest,ServletResponse

C. HttpSession,ServletResponse

D. HttpSession,Servlet

Answer optionb

Marks: 2
Choose missing statements in following code shown by _____________
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class session1 extends HttpServlet
{
public void doGet(____________ request,
HttpServletResponse response)
throwsServletException, IOException
{
2676 ___________ hs = request.getSession(true);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. HttpServletRequest,HttpSession

B. ServletRequest,ServletResponse

C. HttpSession,ServletResponse

D. Servlet,ServletRequest

Answer optiona

Marks: 2

Find out the error containing statement


import javax.servlet.*;
import java.io.*;
public class HelloServlet extends Genericservlet
{
public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
2677 {
res.setContentType("text/html");
PrintWriter pw = res.getWriter();
pw.println("<I>My first Servlet</I>");
pw.close();
}
}

A. Statement where package is imported

B. Statement where Genericservlet class is extended

C. Statement where PrintWriter is created

D. Statement where service() method is defined

Answer optionb

Marks: 2

2678 ��������.. follows MVC (Model view contoller) architecture.

A. AWT

B. Swing

C. Both i & ii

D. None of the above

Answer optionb

Marks: 1

2679 �������is container that contains title bar and can have Menu bars.It can also have other components like button,checkbox etc.

A. Panel

B. Window

C. Frame

D. Container

Answer optionc

Marks: 1

2680 Which is the super class for the List class.


A. Applet

B. Frame

C. Component

D. Container

Answer optionc

Marks: 1

2681 Way to create frame is

A. Association

B. Inheritance

C. Both A and B

D. None of these

Answer optionc

Marks: 1

2682 �������.. control is used to choose one option from multiple options.

A. JComboBox

B. JTabbedPane

C. JRadioButton

D. JButton

Answer optionc

Marks: 1

2683 �������� generates response to an event.

A. Listener

B. Adapter

C. Controls

D. None of the above

Answer optiona

Marks: 1

2684 ��������.event is generated when mouse wheel is moved.

A. MouseEvent

B. MouseMotionEvent

C. MouseWheelEvent

D. Both ii and iii

Answer optionc

Marks: 1

2685 Which event is generated when component gain or losses keyboard focus.

A. ContainerEvent

B. Component Event

C. KeyEvent

D. FocusEvent

Answer optiond

Marks: 1
2686 If the mouse is pressed and released at the same point ____________is invoked.

A. mouseClicked()

B. mouseReleased()

C. mouseExited()

D. none of the above

Answer optiona

Marks: 1

2687 ��������is numbered socket on particular machine.

A. Port

B. TCP

C. UDP

D. HTTP

Answer optiona

Marks: 1

2688 ��������filters the specific request and cache their result to use in future.

A. Reserved Socket

B. Protocol

C. Proxy Server

D. Web Server

Answer optionc

Marks: 1

2689 java.security package consist of class

A. Permission class

B. Policy class

C. Both I and ii

D. None of the above

Answer optionc

Marks: 1

2690 Which method is used to establish connection with database.

A. getConnection()

B. makeConnection()

C. connection()

D. None of the above

Answer optiona

Marks: 1

2691 �������driver converts JDBC API calls into native C or C++ API calls.

A. JDBC-ODBC Bridge Driver

B. JDBC Native API

C. jdbc-Net Pure Java

D. 100% pure java

Answer optionb
Marks: 1

2692 javax.servlet.http package consist of class

A. HttpServletRequest

B. HttpServletResponse

C. HttpSession

D. Cookie

Answer optiond

Marks: 1

Consider the following code.What will be displayed in output.


/*<applet code="SDemo.class" width=200 height=300>
</applet>*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class SDemo extends Applet


{
Label l2,l3;
Button b1,b2;
TextField t1,t2;
public void init()
{
2693 setLayout( new GridLayout(4,2));
l2=new Label("Stud_Id");
l3=new Label("Name");
t1=new TextField(5);
t2=new TextField(10);
b1=new Button("Update");
b2=new Button("Exit");
add(l2);
add(t1);
add(l3);
add(t2);
add(b1);
add(b2);
}
}

A. Applet with 2 labels,2 textfields

B. Frame with 2 labels,2 textfields

C. Applet with 2 labels,2 textfields and 2 buttons

D. Frame with 2 labels,1 textarea and 2 buttons

Answer optionc

Marks: 2

Consider the following code.Select the missing statement.


public class CardDemo extends JFrame
{
CardLayout card;
JButton b1,b2,b3;
Container c;
CardDemo()
{
c=getContentPane();
card=new CardLayout(40,30);
c.setLayout(card);
b1=new JButton("IF2G");
b2=new JButton("IF4G");
2694 b3=new JButton("IF6G");
c.add("a",b1);
c.add("b",b2);
c.add("c",b3);
}
public static void main(String[]args)
{
CardDemo cd=new CardDemo();
cd.setSize(400,400);
cd.setVisible(true);
cd.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}

A. Applet code missing

B. Missing ;

C. Layout missing

D. Package statement missing.

Answer optiond

Marks: 2
2695 Which of the following is method of TextField Control?

A. void append(String str)

B. void insert(String str,int index)

C. void replaceRange(String str,int startIndex,int endIndex)

D. void setText(String str)

Answer optiond

Marks: 2

2696 Which of the following is not ScrollBar constants.

A. SCROLLBAR_BOTH

B. SCROLLBAR_HOROZONTAL

C. SCROLLBAR_NONE

D. SCROLLBAR_HORIZONTAL_ONLY

Answer optionb

Marks: 2

Consider the following code.Which constructor of Checkbox class is used.


/*<applet code="CheckDemo.class" width =100 height=200>
</applet>*/

import java.awt.*;
import java .applet.*;
import java .awt.event.*;

public class CheckDemo extends Applet implements ItemListener


{
Checkbox c1,c2,c3;
public void init()
{
c1=new Checkbox ("C");
c2=new Checkbox("c++");
c3=new Checkbox("Java");
add(c1);
2697 add(c2);
add(c3);
c1.addItemListener(this);
c3.addItemListener(this);
c3.addItemListener(this);
}
public void paint(Graphics g)
{
g.drawString ("Language selected",10,80);
g.drawString ("C :"+c1.getState(),10,100);
g.drawString("C++ :"+c2.getState(),10,120);
g.drawString("Java :"+c3.getState(),10,140);
}
public void itemStateChanged(ItemEvent ie)
{
repaint();
}
}

A. Parameterised constructor

B. Default constructor

C. Both i and ii

D. None of the above

Answer optiona

Marks: 2
Identify the missing statement in following code
/*<applet code="AreaDemo.class" width=200 height=300>
</applet>*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class AreaDemo extends Applet implements ActionListener
{
TextField t1,t2,t3;
Button b1;
Label l1,l2;
int len,bred,area;
public void init()
{
l1=new Label("Enter Length");
t1=new TextField(5);
l2=new Label("Enter Breadth");
t2=new TextField(8);
2698 b1=new Button("Area of Rectangle");
t3=new TextField(11);
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(t3);
}
public void actionPerformed(ActionEvent ae)
{
len=Integer.parseInt(t1.getText());
bred=Integer.parseInt(t2.getText());
area=len*bred;
t3.setText(Integer.toString(area));
repaint();
}
}

A. In package Statement

B. In applet code

C. In init method

D. In actionPerformed method

Answer optionc

Marks: 2

Which are the controls used in following code?


/*<applet code="TabDemo1.class" width=400 height=400>
</applet> */

import javax.swing.*;
public class TabDemo1 extends JApplet
{
public void init()
{
JTabbedPane jtp=new JTabbedPane();
jtp.addTab("Operating System",new OSPanel());
jtp.addTab("Browser",new BrowserPanel());
jtp.addTab("Website",new WebPanel());
getContentPane().add(jtp);
}

}
class OSPanel extends JPanel
{
public OSPanel()
{
JButton b1=new JButton("Linux");
add(b1);
JButton b2=new JButton("XP");
add(b2);
2699 JButton b3=new JButton("DOS");
add(b3);

}
}
class BrowserPanel extends JPanel
{
public BrowserPanel()
{
JCheckBox cb1=new JCheckBox("Internet Explorer");
add(cb1);
JCheckBox cb2=new JCheckBox("Google Crome");
add(cb2);
JCheckBox cb3=new JCheckBox("Firefox");
add(cb3);
}
}
class WebPanel extends JPanel
{
public WebPanel()
{
String L[]={"Msbte","Aicte","Dte"};
JList jl=new JList(L);
add(jl);
}
}

A. JList,JCheckBox,Jbutton

B. JTabbedPane,JRadioButton,JList

C. JButton,JCheckBox,Jlist,JTabbedPane
D. JTabbedPane,JRadioButton,Jlist,JCheckBox

Answer optionc

Marks: 2

2700 ������method returns remote port to which socket object is connected.

A. getPort()

B. getLocalPort()

C. Both i and ii

D. None of these

Answer optiona

Marks: 2

2701 long getDate() is a method of������class.

A. URLConnection

B. InetAddress

C. DatagramSocket

D. URL

Answer optiona

Marks: 2

2702 Information that is saved for each cookie includes

A. The name of the cookie

B. The expiration date of the cookie

C. The domain and path of the cookie

D. All of the above

Answer optiond

Marks: 2

2703 javax.servlet package contains which of the following class?

A. ServletResponse

B. ServletRequest

C. ServletConfig

D. GenericServlet

Answer optiond

Marks: 2

2704 ���� decide scope of the JSP tag.

A. TLD

B. JSTL

C. Both i and ii

D. None of the above

Answer optionc

Marks: 2
Select the method which can be added to the code.
/*<applet code=SwingDemo.class height=300 width=400>
</applet>*/
import java.awt.*;
import java.applet.*;
public class SwingDemo extends Applet
{
Label l1,l2;
TextField t1,t2;
Button b1,b2;
public void init()
{
t1=new TextField();
2705 t2=new TextField();
l1=new Label("User Name");
l2=new Label("Password");
b1=new Button("Submit");
b2=new Button("Cancel");
setLayout(new GridLayout(3,2));
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(b2);
}
}

A. t1.setEditable(false);

B. t2.setEchoChar('*');

C. Both i and ii

D. None of the above

Answer optionc

Marks: 2

2706 Select the proper code for the given output.

/*<applet code="ChoiceDemo" width=300 height=180>


</applet> */
import java.awt.*;
import java.applet.*;

public class ChoiceDemo extends Applet


{
Choice country,capital;
public void init()
A. {
country=new Choice();
capital=new Choice();
country.add("India");
country.add("Shrilanka");
country.add("Pakistan");
capital.add("Delhi");
capital.add("Colombo");
capital.add("Islamabad");
add(capital);
} }

/*<applet code="ChoiceDemo" width=300 height=180>


</applet> */
import java.awt.*;
public class ChoiceDemo extends Applet
{
Choice country,capital;
public void init()
{
country=new Choice();
B. capital=new Choice();
country.add("India");
country.add("Shrilanka");
country.add("Pakistan");
capital.add("Delhi");
capital.add("Colombo");
capital.add("Islamabad");
add(country);
add(capital);
} }

/*<applet code="ChoiceDemo" width=300 height=180>


</applet> */
import java.awt.*;
import java.applet.*;

public class ChoiceDemo extends Applet


{
Choice country,capital;
public void init()
{
C. country=new Choice();
capital=new Choice();
country.add("India");
country.add("Shrilanka");
capital.add("Delhi");
capital.add("Colombo");
capital.add("Islamabad");
add(country);
add(capital);
} }
/*<applet code="ChoiceDemo" width=300 height=180>
</applet> */
import java.awt.*;
import java.applet.*;

public class ChoiceDemo extends Applet


{
Choice country,capital;
public void init()
{
D. country=new Choice();
capital=new Choice();
country.add("India");
country.add("Shrilanka");
country.add("Pakistan");
capital.add("Delhi");
capital.add("Colombo");
capital.add("Islamabad");
add(capital);
} }

Answer optiona

Marks: 2

Debug the following program

import java.awt.*;
public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo1 m=new MenuDemo();
m.setVisible(true);
m.setMenuBar(mbr);
Menu p=new Menu("Print");
2707 Menu f=new Menu("Format");
Menu w=new Menu("Window");
mbr.add(p);
mbr.add(f);
mbr.add(w);
MenuItem I1=new MenuItem("Preview");
MenuItem I2=new MenuItem("Page set up");
p.add(I1);
p.add(I2);
}
}

A. Menubar is not created

B. Menus are not added

C. Menuitems are not added

D. Package is not imported.

Answer optiona

Marks: 2

Select the method which must be added to following code.


/*<applet code="KeyDemo.class" width=200 height=300>
</applet> */

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class KeyDemo extends JApplet implements KeyListener


{
JLabel l;
JTextField t1;
public void init()
{
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
2708 l=new JLabel("Name");
t1=new JTextField(5);
cp.add(l);
cp.add(t1);
t1.addKeyListener(this);
}
public void keyReleased(KeyEvent e)
{
JTextField t2=(JTextField)e.getSource();
String str=t2.getText();
t2.setText(str.toUpperCase());
}
public void keyPressed(KeyEvent e)
{
}
}

A. public void keyTyped(){}

B. public void keyTyped(KeyEvent e){}

C. public void keytyped(KeyEvent e){}

D. public void KeyType(KeyEvent e){}


Answer optionb

Marks: 2

Select the missing statement for following code.


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Salary extends Applet implements ActionListener
{
Button b1;
int basic,hra,da,gross;
public void init()
{
GridLayout g=new GridLayout(4,2);
Label l1=new Label("Enter Basic Salary ");
t1=new TextField(20);
b1=new Button("Gross Salary");
t2=new TextField(20);
setLayout(g);
add(l1);
2709 add(t1);
add(b1);
add(t2);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
basic=Integer.parseInt(t1.getText());
da=(5*basic)/100;
hra=(15*basic)/100;
gross=basic+hra+da;
t2.setText(Integer.toString(gross));
}
}
/*<applet code= Salary.class width=200 height=200>
</applet>
*/

A. TextField t1;

B. TextField t1,t2;

C. TextArea t1,t2;

D. TextArea t1;

Answer optionb

Marks: 2

For the following code select the listener used to handle event.
/*<applet code="Example.class" width=200 height=300>
</applet>*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class Example extends Applet implements ..................................


{
int x,y;
public void init()
{
addMouseListener(this);
//addMouseMotionListener(this);
}
public void mousePressed (MouseEvent me)
{
int x = me.getX();
int y = me.getY();
if ((x <= getSize().width / 2) && (y <= getSize().height / 2))
setBackground(Color.red);
else if (x <= getSize().width / 2)
setBackground(Color.yellow);
else if (y <= getSize().height / 2)
setBackground(Color.blue);
else
2710 setBackground(Color.green);
repaint();
}
public void mouseReleased (MouseEvent me)
{
}
public void mouseEntered (MouseEvent me)
{
}
public void mouseExited (MouseEvent me)
{
}
public void mouseClicked (MouseEvent me)
{

public void paint (Graphics g)


{
g.drawString("x: ", 10, 50);
g.drawString(Integer.toString(x), 25, 50);
g.drawString("y: ", 10, 70);
g.drawString(Integer.toString(y), 25, 70);
}

A. ItemListener
B. MouseMotionListener

C. MouseWheelListener

D. MouseListener

Answer optiond

Marks: 2

Select the missing statement for following code.


/*<applet code="RadioDemo.class" width=400 height=50>
</applet> */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class RadioDemo extends JApplet implements ActionListener
{
JTextField tf;
public void init()
{
contentPane.setLayout(new FlowLayout());
JRadioButton bt1=new JRadioButton("Apple");
bt1.addActionListener(this);
contentPane.add(bt1);
JRadioButton bt2=new JRadioButton("Orange");
bt2.addActionListener(this);
contentPane.add(bt2);
2711 JRadioButton bt3=new JRadioButton("Mango");
bt3.addActionListener(this);
contentPane.add(bt3);
JRadioButton bt4=new JRadioButton("Banana");
bt4.addActionListener(this);
contentPane.add(bt4);
ButtonGroup bg=new ButtonGroup();
bg.add(bt1);
bg.add(bt2);
bg.add(bt3);
bg.add(bt4);
tf=new JTextField(5);
contentPane.add(tf);
}
public void actionPerformed(ActionEvent ae)
{
tf.setText(ae.getActionCommand());
}
}

A. Container contentPane=getContentPane();

B. Container cp=getContentPane();

C. Container contentPane=ContentPane();

D. container contentPane=getContentPane();

Answer optiona

Marks: 2

Select the method that can be used to handle event.


/*<applet code="ADemo.class" width=300 height=400>
</applet> */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ADemo extends JApplet implements ItemListener


{
JTextField jtf;
public void init()
{
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
JComboBox jc=new JComboBox();
2712 jc.addItem("Addition");
jc.addItem("Sustraction");
jc.addItem("Multiplication");
jc.addItem("Division");
jc.addItemListener(this);
cp.add(jc);
jtf=new JTextField(20);
cp.add(jtf);
}
public void .............................
{
String s=(String)ie.getItem();
jtf.setText("You Selected Addition"+s);
}
}

A. itemChanged(ItemEvent ae)

B. itemValueChanged(ItemEvent ae)

C. itemStateChanged(ItemEvent ae)

D. itemStateChanged()

Answer optionc
Marks: 2

Select the missing statement in following code.


import java.io.*;
import java.net.*;
public class ConEx
{
public static void main(String[] args){
try
{
URL url=new URL("http://www.msbte.com/student-section");
URLConnection urlcon=url.openConnection();
InputStream stream=.............................................
2713 int i;
while((i=stream.read())!=-1)
{
System.out.print((char)i);
}
}
catch(Exception e)
{
System.out.println(e);}
}
}

A. urlcon.getInputStream()

B. url.getOutputStream()

C. con.getInputStream()

D. urlcon.getOutputStream();

Answer optiona

Marks: 2

Consider missing statement in following code from given options.


import import java.sql.*;
public class CreateTable
{
public static void main(String[] args)
{

Connection con = null;

try
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:xyz";
Class.forName(driver);
con = DriverManager.getConnection(url);
2714 try
{
Statement st = con.createStatement();
String sql = "CREATE TABLE Account(Acc_No integer, Acc_Type varchar(10),Ammount integer)";
st.executeUpdate(sql);
System.out.println("Table created successfully!");
}
catch(SQLException s)
{
System.out.println("Table all ready exists!");
}
con.close();
}

}
}

A. Missing package statement

B. Missing sql query

C. Missing catch block

D. Missing try block

Answer optionc

Marks: 2
Consider the following program.What should be the correction done in the program to get correct output?
import java.sql.*;
public class SelectRow
{
public static void main(String[] args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:xyz";
Connection con = DriverManager.getConnection(url);
try
{
Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT * FROM Account");
System.out.println("Acc_No " + "\t\t" + "Acc_Type " + "\t" +"Ammount");
while (res.next())
{
2715 int i = res.getInt("Acc_No");
String s1 = res.getString("Acc_Type");
String s2 = res.getString("Ammount");
System.out.println(i + "\t\t" + s1 + "\t\t" +s2);
}
close();
}
catch (SQLException s)
{
System.out.println("SQL error.");
}
}
catch (Exception e)
{
System.out.println(" error.");
}
}
}

A. Error in main()

B. Error in close()

C. Error in loop

D. Error in connection statement

Answer optionb

Marks: 2

Consider the following program.What should be the correction done in the program to get correct output?
import java.sql.*;
public class InsertPre
{
public static void main(String args[])
{
String url = "jdbc:odbc:xyz";
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(url);
String sql ="insert into Account(Acc_No,Acc_Type,Ammount) values(?,?)";
pst = con.prepareStatement(sql);
pst.setInt(1, 15);
pst.setString(2, "saving");
pst.setInt(3, 30000);
pst.executeUpdate();
2716
pst.close();
sql = "select * from Account";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
while (rs.next())
{
System.out.print(rs.getInt(1) + "\t");
System.out.print(rs.getString(2) + "\t");
System.out.println(rs.getInt(3));
}
rs.close();
pst.close();
con.close();
}
catch (Exception e)
{
}
}
}

A. Error in main()

B. Error in close()

C. Error in loop

D. Error in Query.

Answer optiond

Marks: 2
Consider the following program.Select the interface to fill in the blank space.
import java.sql.*;
public class Column
{
public static void main(String[] args)
{

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:xyz";
Connection con = DriverManager.getConnection(url);
try
{
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM Account");
.............................. md = rs.getMetaData();
int col = md.getColumnCount();
2717 System.out.println("Number of Column : "+ col);
System.out.println("Columns Name: ");
for (int i = 1; i <= col; i++)
{
String col_name = md.getColumnName(i);
System.out.println(col_name);
}
}
catch (SQLException s)
{
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e)
{
System.out.println("error");
}
}
}

A. ResultSet

B. ResultSetMetaData

C. MetaData

D. PreparedStatement

Answer optionb

Marks: 2

Consider the following program and identify missing statement.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws .....................................
{
2718 response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpSession hp=request.getSession(true);
Date create=new Date(hp.getCreationTime());
Date access=new Date(hp.getLastAccessedTime());
out.println("Session is created at "+create);
out.println("Last access time is "+access);
out.println("Session id is "+hp.getId());
}
}

A. IOException

B. ServletException

C. IOException, ServletException

D. SQLException

Answer optionc

Marks: 2
Consider the following program.What should be correction done in the program.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class CheckP extends HttpServlet


{
public void doPost(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(" ");
out.println(" ");
out.println(" ");
out.println(" ");
2719 out.println(" ");
String p1=request.getParameter("username");
String p2=request.getParameter("pass");
if(p1.equals("xyz") && (p2.length > 10))
{
out.println("Opps "+p1+", too long password !!");
}
else
{
out.println("Ok ,Your password is less than 6");
}
out.println("!!!!");
out.println(" ");
}
}

A. Error in package statement

B. Error in else block

C. Error in if block

D. Error in doPost()

Answer optionc

Marks: 2

Select the missing statement in following program.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class AddCooki extends HttpServlet


{
public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException
{
2720 response.setContentType("text/html");
String name = request.getParameter("name");
String value = request.getParameter("value");
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("Cookie Saved Successfully");
pw.close();
}
}

A. Cookie cookie = new Cookie(name);

B. Cookie cookie = new Cookie( value);

C. Cookie cookie = new cookie(name, value);

D. Cookie cookie = new Cookie(name, value);

Answer optiond

Marks: 2

Where should be correction done in the program to get correct output.


<% page language="java"%>
<% page import="java.lang.*"%>
<html>
<body>
<H1><center>Result for <%=request.getParameter("a1")%></center></H1>
<%
int i=Integer.parseInt(request.getParameter("t1"));
int k=0;
2721 String str=request.getParameter("a1");
if(str.equals("square"))
k=i*i;
if(str.equals("cube"))
k=i*i*i;
%>
Result is <%=k%>
</body>
</html>

A. In import statement

B. Get parameter statement

C. In if block
D. In HTML tag

Answer optiona

Marks: 2

Name the class used to represent a GUI application window, which is optionally resizable and can have a title bar, an icon,
2722 and menus

A. Window

B. Panel

C. Dialog

D. Frame

Answer optionc

Marks: 1

2723 Which of these classes can be added to any Container class, using the add method defined in Container class

A. Button

B. CheckboxMenuItemIndex

C. Both A and D.

D. Canvas

Answer optiona

Marks: 1

2724 The class string belongs to ................... package.

A. java.awt

B. java.lang

C. java.applet

D. java.string

Answer optionb

Marks: 1

2725 Swing components that don�t rely on native GUI are referred to as . . .

A. lightweight components

B. heavyweight components

C. GUI components

D. non-GUI components

Answer optiona

Marks: 1

2726 What layout is used to divide a frame into five areas: north, south, east, west, and center?

A. BorderLayout

B. BoxLayout

C. FlowLayout

D. GridLayout

Answer optiona

Marks: 1

2727 The java.net.InetAddress class represents an?

A. Socket

B. IP Address
C. Protocol

D. MAC Address

Answer optionb

Marks: 1

2728 How can you execute a stored procedure in the database?

A. Call method execute() on a CallableStatement object

B. Call method executeProcedure() on a Statement object

C. Call method execute() on a StoredProcedure object

D. Call method run() on a ProcedureCommand object

Answer optiona

Marks: 1

2729 An object of Which is created by the web container at time of deploying the project?

A. ServletConfig

B. ServletContext

C. Both A & B

D. None of the above

Answer optionb

Marks: 1

In Session tracking which method is used in a bit of information that is sent by a web server to a browser
2730 and which can later be read back from that browser?

A. HttpSession

B. URL rewriting

C. Cookies

D. Hidden form fields

Answer optionc

Marks: 1

2731 Which class can handle any type of request so it is protocol-independent?

A. GenericServlet

B. HttpServlet

C. Http

D. Packet

Answer optiona

Marks: 1

Fill in the blanks so that this program displays a Frame:


import java.awt.*;

public class microGUI


{
public static void main ( String[] args )
2732 {
Frame frm = new ___________();
frm.___________( 150, 100 );
frm.___________( true );
}
}

A. Form, setVisible, setOn

B. Frame, setSize, setVisible

C. Frame, setVisible, setSize

D. Window, setSize, paint


Answer optionb

Marks: 2

The Following steps are required to perform


2733 1) Implement the Listener interface and overrides its methods
2) Register the component with the Listener

A. Exception Handling

B. String Handling

C. Event Handling

D. Action Handling

Answer optionc

Marks: 2

2734 To listen to mouse clicked events, the listener must implement the __________ interface or extend the _______ adapter.

A. mouselistner / mouseadapter

B. mousemotionlistner / mousemotionadapter

C. WindowListener/WindowAdapter

D. ComponentListener/ComponentAdapter

Answer optiona

Marks: 2

2735 java.net.URL provides following methods

A. getProtocol(),getHost()

B. A & C

C. int address

D. none

Answer optiona

Marks: 2

2736 ____________ is the class which provides access to UDP socket which allows UDP packets to be sent and received

A. DatagramPacket

B. DatagramSocket

C. ServerSocket

D. Datagramclient

Answer optionb

Marks: 2

2737 Which method interface provides various methods for getting information about database.

A. JDBC API

B. Database MetaData

C. RDB Metadata

D. Database Driver

Answer optionb

Marks: 2

2738 Which interface have following methods clearParameter(),setInt(),execute().

A. CallableStatement interface

B. connection interface
C. preparedStatement interface

D. statement interface

Answer optionc

Marks: 2

What is error in this statement.


class.forName("sun.jdbc.odbc.jdbcodbcDriver");
2739 url="xyz"
connection con=DriverManager.getConnection(url);

A. unidentified string

B. object not created properly

C. no correction in code

D. driver name is wrong

Answer optiona

Marks: 2

2740 ________ method returns the value of the named attribute as an object and __________ returns value of request parameter

A. setAttribute() and setParameter()

B. getAttribute() and getParameter()

C. getAttributeName() and getParameterName()

D. none

Answer optionb

Marks: 2

2741 ________ layout is a group of containers that are displayed one at time with each container in the group.

A. grid layout

B. card layout

C. box layout

D. border layout

Answer optionb

Marks: 2

2742 Which of these methods is used to get x coordinate of the mouse?

A. getX()

B. getXCoordinate()

C. getCoordinateX()

getPointX()
D.

Answer optiona

Marks: 2

2743 Which event handling methods are used for window lost focus and window activated

A. Window_Activated and Window_lost focus

B. windoweventacive and windowlost focusevent

C. both

D. none

Answer optiona

Marks: 2

2744 find incorrect method of Socket class


A. InetAddress getInetAddress()

B. int getPort()

C. int getAddress()

D. int getLocalPort()

Answer optionc

Marks: 2

Which java object are handfull to use in java application i) provides another way to make a connection to the database
2745 ii) provides an object that can accept database timestamp values

A. DeviceManager and time

B. DriverManager and Timestamp

C. DriverType and Time

D. None of this

Answer optionb

Marks: 2

Which type of jdbc driver has following advantages i) it do not require any native binary code
2746 ii) do not need client installation

A. type 1

B. type 2

C. type 3

D. type 4

Answer optionc

Marks: 2

2747 Which software has the knowledge of database when multiple databases are used by application

A. kernal

B. device manager

C. driver manager

D. DBMS

Answer optionc

Marks: 2

What does this mean


2748 public ServletContext getServletContext()

A. it creats session

B. it returns servlet contex object which belong to httpsession

C. it creates session object for servlet

D. none

Answer optionb

Marks: 2

Consider the following program and identify the missing statement.


import java.net.*;
import java.io.*;
class URLDemo
{
public static void main(String args[]) throws MalformedURLException
{
2749 URL netAddress= new URL("http://www.sun.com:/index.html");
System.out.println("Protocol :"+netAddress.getProtocol());
System.out.println("Port :"+netAddress.getPort());
System.out.println("Host :"+netAddress.getHost());
System.out.println("File :"+netAddress.getFile());
}
}

A. Missing semicolon
B. Missing object initialisation

C. Missing initialization

D. No error in program

Answer optiond

Marks: 2

2750 When JSP page is compiled it turns into what?

A. Applet

B. Servlet

C. Application

D. Mailet

Answer optionb

Marks: 2

2751 What does AWT stands for?

A. Abstract writing toolkit

B. All Window Tools

C. All Writing Tools

D. Abstract Window Toolkit

Answer optiond

Marks: 1

2752 which of these methods can be used to know which modifier key is pressed?

A. getActionEvent()

B. getActionKey()

C. getModifier()

D. getKey()

Answer optionc

Marks: 1

2753 When we invoke repaint() for a java.awt.Component object, the AWT invokes the method

A. draw()

B. update()

C. show()

D. paint()

Answer optionb

Marks: 1

What does the following line of code do?


2754 Textfield text = new Textfield(10);

A. Creates text object that can hold 10 rows of text.

B. Creates the object text and initializes it with the value 10.

C. Creates text object that can hold 10 columns of text.

D. The code is illegal.

Answer optionc

Marks: 1

2755 Which of these methods can be used to know the type of focus change?
A. typeFocus()

B. typeEventFocus()

C. isTemporary()

D. isPermanent()

Answer optionc

Marks: 1

2756 Which method of URL class represents a URL and has complete set of methods to manipulate URL in Java?

A. java.net.URL

B. java.net.URLConnection

C. All the above

D. None of the above

Answer optiona

Marks: 1

2757 Which steps occur when establishing a TCP connection between two computers using sockets?

A. The server instantiates a ServerSocket object, denoting which port number communication is to occur on

B. The server invokes the accept() method of the ServerSocket class. This method waits until a client connects to the server on the given port

C. After the server is waiting, a client instantiates a Socket object, specifying the server name and port number to connect to

D. All of the above

Answer optiond

Marks: 1

2758 Which of the following is true about JDBC architecture?

A. JDBC API layer provides the application-to-JDBC Manager connection.

B. JDBC Driver API layer supports the JDBC Manager-to-Driver Connection.

C. Both of the above.

D. None of the above.

Answer optionc

Marks: 1

2759 Which of the following consists of methods for contacting a database?

A. DriverManager

B. JDBC driver

C. Connection

D. Statement

Answer optionc

Marks: 1

2760 Which of the following is used to call stored procedures on the database?

A. Statement

B. PreparedStatement

C. CallableStatement

D. None of the above

Answer optionc

Marks: 1
2761 Which of the following is a server side technology?

A. HTML

B. JSP

C. JAVASCRIPT

D. CSS

Answer optionb

Marks: 1

2762 Which of the following is an implicit object?

A. pageContext

B. servletContext

C. httpContext

D. sessionContext

Answer optiona

Marks: 1

2763 What is javax.servlet.Servlet?

A. interface

B. abstract class

C. concreate class

D. None of the above.

Answer optiona

Marks: 1

2764 To use the ActionListener interface it must be implemented by a class there are several ways to do that find in the following?

Creating a new class


A.

B. using the class the graphical component

C. an anonymous inner class

D. All mentioned above

Answer optiond

Marks: 2

what is use of this method?


2765 public ServerSocket(int port) throws IOException

Attempts to create a server socket bound to the specified port. An exception occurs if the port is already bound by
A. another application.

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


B. the backlog parameter specifies how many incoming clients to
store in a wait queue.

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


C. the InetAddress parameter specifies the local IP address to bind to. The InetAddress is used for servers that may have multiple IP addresses, allowing t

Creates an unbound server socket. When using this constructor,


D. use the bind() method when you are ready to bind the server socket

Answer optiona

Marks: 2

2766 What happens if you call deleteRow() on a ResultSet object?

The row you are positioned on is deleted from the ResultSet,


A. but not from the database.

The row you are positioned on is deleted from


B. the ResultSet and from the database
The result depends on whether the property synchronize With
C. DataSource is set to true or false

You will get a compile error: the method does not exist
D. because you can not delete rows
from a ResultSet

Answer optionb

Marks: 2

Given the following servlet mapping definition for the web application named 'secureapp',
<servlet>
<servlet-name>ProcessLoginData</servlet-name>
<servlet-class>DoLogin</servlet-class>
</servlet>
2767 <servlet-mapping>
<servlet-name>ProcessLoginData</servlet-name>
<url-pattern>do/Login</url-pattern>
</servlet-mapping>
which of the following URLs will correctly request the Servlet?

A. http://localhost:8080/secureapp/do/Login?name="bob"

B. http://localhost:8080/secureapp/doLogin?name="bob"

C. http://localhost:8080/Login?name="bob"

D. http://localhost:8080/secureapp/Login?name="bob"

Answer optiona

Marks: 2

For a given ServletResponse response, which retrieve an object for


2768 writing text data?

A. response.getOutputWriter()

B. response.getWriter()

C. response.getWriter().getOutputStream()

D. response.getWriter(Writer.OUTPUT_TEXT)

Answer optionb

Marks: 2

Select the proper statements to run the following code.

import java.awt.*;
/*<applet code="JLabelDemo.class" width=200 height=200>
</applet> */
public class JLabelDemo extends JApplet
{
public void init()
{

//GET CONTENT PANE


2769 Container contentPane = getContentPane();

//CREATE AN ICON
ImageIcon i1=new ImageIcon("Desert.jpg");

//CREATE LABEL
JLabel j1=new JLabel("Desert",i1,JLabel.CENTER);

//ADD LABEL TO THE CONTENT PANE

}
}

A. contentPane.add(j1);

B. import javax.swing.*;

import javax.swing.*;
C. contentPane.add(j1);

D. none of the above

Answer optionc

Marks: 2
Observe the following code

import java.awt.*;
import javax.swing.*;
/*<applet code="JTableDemo.class" width=400 height=500>
</applet> */
public class JTableDemo extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
2770 final String[] colHeads = { "Name", "Phone", "Fax"};
final Object[][] data = {
{"Prashant", "12345","6789"},
{"Rupesh", "12345", "23456"}
};
JTable table = new JTable(data, colHeads);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
JScrollPane jsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}

A. The output is obtained in table with two rows and three columns.

B. The output is obtained in table with two rows and two columns.

C. The output is obtained in table with three rows and three columns.

The output is obtained in table with two rows and three columns
D. with horizontal and vertical scrollbar

Answer optiond

Marks: 2

Consider the following program. Find which missing statement.


import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
/*<applet code="JTreeDemo.class" width=400 height=300> </applet> */
public class JTreeDemo extends JApplet
{ public void init(){
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
DefaultMutableTreeNode a = new DefaultMutableTreeNode("CO5G");
top.add(a);
DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("JPR");
a.add(a1);
2771 DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("SWE");
a.add(a2);
DefaultMutableTreeNode b = new DefaultMutableTreeNode("CO6G");
top.add(b);
DefaultMutableTreeNode b1 = new DefaultMutableTreeNode("AJP");
b.add(b1);
DefaultMutableTreeNode b2 = new DefaultMutableTreeNode("MAN");
b.add(b2);
JTree tree = new JTree(top);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
JScrollPane jsp = new JScrollPane(tree, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
} }

DefaultMutableTreeNode top = new DefaultMutableTreeNode


A. ("Third Year Computer Engineering");

B. Top top=new Top();

C. JTree tree = new JTree(top);

D. none of the above

Answer optiona

Marks: 2

Find out the Error statement


import java.applet.*;
import java.awt.event.*;
/*
<applet code="InnerClassDemo" width=200 height=100>
</applet>
*/
public class InnerClassDemo extends Applet
{
public void init()
{
2772
addMouseListener(new MyMouseAdapter());
}
class MyMouseAdapter
{
public void mousePressed(MouseEvent me)
{
showStatus("Mouse Pressed");
}
}
}

A. public class InnerClassDemo extends Applet


addMouseListener(new MyMouseAdapter());
B.
class MyMouseAdapter

C. public void mousePressed(MouseEvent me) {

D. none of the above

Answer optionb

Marks: 2

select proper missing statement:

import java.net.*;
class InetAddressTest
{
public static void main(String args[]) {
2773 InetAddress Address = InetAddress.getLocalHost();
System.out.println(Address);
InetAddress SW[] = InetAddress.___________("www.nba.com");
for (int i=0; i<SW.length; i++)
System.out.println(SW[i]);
}
}

A. getAllByName()

B. getByName()

C. getName()

D. getAllName()

Answer optiona

Marks: 2

Select Correct output

import java.net.*;
class URLDemo
{
public static void main(String args[]) throws MalformedURLException
{
2774 URL hp = new URL("https://www.google.com/downloads");
System.out.println("Protocol: "+hp.getProtocol());
System.out.println("Port: "+hp.getPort());
System.out.println("Host: "+hp.getHost());
System.out.println("File: "+hp.getFile());
System.out.println("Ext: "+hp.toExternalForm());
}
}

Protocol: https
Port: -1
A. Host: localhost
File: /downloads
Ext: https://www.google.com/downloads

Protocol: https
Port: -1
B. Host: www.google.com
File: /downloads
Ext: https://www.google.com/downloads

Protocol: https
Port: -1
C. Host: www.google.com
File: /downloads
Ext: https://www.google.com

Protocol: https
Port: -1
D. Host: www.google.com
File: google
Ext: https://www.google.com/downloads

Answer optionb

Marks: 2
what is an output of following code

import java.sql.*;
public class CreateTable {
public static void main(String [] args) {
Connection con = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:mydsn");
2775 Statement sta = con.createStatement();
int count = sta.executeUpdate("CREATE TABLE student (roll int, name VARCHAR(20),address VARCHAR(20))");
System.out.println("Table created.");
sta.close();
con.close();
} catch (Exception e) {
System.err.println("Exception: "+e.getMessage());
}
}
}

A. Table Created

B. compile error

C. Driver Error

D. none of above

Answer optiona

Marks: 2

consider following code. what is an ouput of given code?


import java.sql.*;
public class Example {
public static void main(String args[]) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM employee ORDER BY empid");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int rowCount = 1;
while (rs.next()) {
2776 for (int i = 1; i <= numberOfColumns; i++) {
System.out.print(rs.getString(i) + " ");
}
rowCount++;
}
stmt.close();
con.close();
}
catch (Exception e) {
System.out.println(e);
}
}
}

A. error in ResultSet

B. error in ResultsetMetaData

show output like


C. 2 amol 4 sachin 7 rahul

D. none of above

Answer optionc

Marks: 2

consider following code. what is an ouput of given code?

import java.sql.*;
class Rsmd{
public static void main(String args[]){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
PreparedStatement ps=con.prepareStatement("select * from employee");
ResultSet rs=ps.executeQuery();

2777 ResultSetMetaData rsmd=rs.getMetaData();

System.out.println("Total columns: "+rsmd.getColumnCount());


System.out.println("Column Name of 1st column: "+rsmd.getColumnName(1));
System.out.println("Column Type Name of 1st column: "+rsmd.getColumnTypeName(1));

con.close();

}catch(Exception e){ System.out.println(e);}

}
}

Total columns: 2
A. Column Name of 1st column: empid
Column Type Name of 1st column: INTEGER

Column Name of 1st column: empid


B. Column Type Name of 1st column: INTEGER
Total columns: 2
C. Column Name of 1st column: empid

Total columns: 2
D. Column Type Name of 1st column: INTEGER

Answer optiona

Marks: 2

To delete reord from database table student what modification we have to do in following program.

import java.sql.*;

public class JdbcDemo1 {


public static void main(String args[]) throws Exception {

2778 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
Statement stmt = con.createStatement();
int result=st.executeUpdate("delete student where id=1");

System.out.println(result+" records affected");


con.close();
}}

A. int result=("delete from student where id=1");

B. stmt.executeUpdate("delete from student ");

C. int result=stmt.executeUpdate("delete from student where id=1");

D. int result=st.executeUpdate("delete from student where id=1");

Answer optionc

Marks: 2

Choose missing statements in following code from given options.


public class GetSession extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(false);
try {
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.println("<html><body>");
if (session == null) {
writer.println("<p>You are not logged in</p>");
} else {
writer.println("Thank you, you are already logged in");
writer.println("Here is the data in your session");
2779 Enumeration names = session.getAttributeNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
Object value = session.getAttribute(name);
writer.println("<p>name=" + name + " value=" + value + "</p>");
} }
writer.println("<p><a href=\"/ServletSession/login.html\">Return" +
"</a> to login page</p>");
writer.println("</body></html>");
writer.close();
} catch (Exception e) {
e.printStackTrace();
} } }

import javax.servlet.http.*;
A. import java.io.*;
import java.util.*;

import javax.servlet.http.*;
B. import java.util.*;

import javax.servlet.*;
C. import java.util.*;

import javax.servlet.http.*;
D. import java.io.*;

Answer optiona

Marks: 2
In following Java program fill statement showing ***.Select any one option fro given options

import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
2780 String data = request.getParameter("data");
Cookie cookie = ***************
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. new Cookie("MyCookie", data);

B. new Cookie("MyCookie", data1);

C. new Cookie("MyCookie", data2);

D. new Cookie("MyCookie", database);

Answer optiona

Marks: 2

A JSP page called test.jsp is passed a parameter name in the URL


using http://localhost/test.jsp?name="John". The test.jsp contains the
following code.
2781 <%! String myName=request.getParameter();%>
<%! String test= "welcome" + myName; %>
<%= test%>

A. The program prints "Welcome John"

The program gives a syntax error because of the statement


B. <%! String myName=request.getParameter();%>

The program gives a syntax error because of the statement


C. <% String test= "welcome" + myName; %>

The program gives a syntax error because of the statement


D. <%= test%>

Answer optionb

Marks: 2

consider below program and print message " hi h r u" . select proper method.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet {


private String message;
public void init() throws ServletException
{
message = "hi h r u";
2782 }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();

public void destroy()


{ }
}

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException


{
response.setContentType("text/html");
A. PrintWriter out = response.getWriter();
out.println("<h1>" + message + "</h1>");

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException


{
response.setContentType("text/html");
B. PrintWriter out = response.getWriter();

}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
C. response.setContentType("text/html");

PrintWriter out = response.getWriter();


out.println("<h1>" + message + "</h1>");
}

public void doGet(HttpServletRequest request,


HttpServletResponse response)
throws ServletException, IOException
{
D. response.setContentType("text/html");

PrintWriter out = response.getWriter();


out.println("<h1>" + hi h r u+ "</h1>");
}

Answer optionc

Marks: 2

2783 The ______________class is the root of all AWT components.

A. Component

B. Container

C. Applet

D. Scrollbar

Answer optiona

Marks: 1

2784 Which method is used to move and resize the component?

A. setBackground(Color� c)

B. setBounds(int� x, int� y, int� width, int� height)

C. setEnabled(boolean� b)

D. setVisible(boolean� b)

Answer optionb

Marks: 1

2785 The default layout for a window is _______________

A. BorderLayout

B. FlowLayout

C. GridLayout

D. CardLayout

Answer optiona

Marks: 1

2786 Font information is obtained from the current graphics environment using which of the following methods.

A. getLocalGraphicsEnvironment()

B. getAvailableFontFamilyNames()

C. getAllFonts()

D. getFont()

Answer optiona

Marks: 1

2787 List allows multiple selection of items, whereas Choice allows single selection at a time.

A. true

B. false
C.

D.

Answer optiona

Marks: 1

2788 A component that combines a button or editable field and a drop-down list.

A. JComboBox

B. JButton

C. JTextField

D. JLabel

Answer optiona

Marks: 1

2789 JProgressBar extends ___________ public class.

A. JScrollBar

B. JComponent

C. JSeparator

D. JMenuBar

Answer optionb

Marks: 1

2790 getSource() method returns

A. the integer value corresponding to the type of event

B. the source of the event

C. the type of state change

D. the type of adjustment which caused the value changed event

Answer optionb

Marks: 1

2791 _________________defines one method to recognize when the state of the item changes.

A. ActionListener

B. AdjustmentListener

C. ItemListener

D. MouseListener

Answer optionc

Marks: 1

2792 There are three participants in event delegation model in Java; - Event Source, Event Listeners & ______

A. Event

B. Event Object

C. Process

D. Message

Answer optionb

Marks: 1

The AdjustmentEvent class defines five types of adjustment event, listed here:
2793 UNIT_INCREMENT ,UNIT_DECREMENT ,BLOCK_INCREMENT ,BLOCK_DECREMENT &______

A. MOVE
B. TRACK

C. SLIDE

D. ROTATE

Answer optionb

Marks: 1

2794 __________ sits between the local network and the external network.

A. Printer

B. Proxy Server

C. Host

D. Port

Answer optionb

Marks: 1

2795 ServerSocket(int port) throws IOException, SecurityException

A. TRUE

B. FALSE

C.

D.

Answer optiona

Marks: 1

2796 In the three-tier model, commands are sent to a middle tier of services, which then send SQL statements to the _______________

A. Client

B. Server

C. Database

D. JDBC

Answer optionc

Marks: 1

2797 Type II Drivers is also called as __________

A. Bridge

B. Native

C. Middleware

D. Pure

Answer optionb

Marks: 1

2798 execute(),exceuteQuery() & executeUpdate() methods belong to _________.

A. Connection

B. Statement

C. DriverManager

D. ResultSet

Answer optionb

Marks: 1

2799 A servlet stays in memory, so it doesn�t have to be reloaded each time.


A. true

B. false

C.

D.

Answer optiona

Marks: 1

2800 Cookies are placed in the browser by calling addCookie() on the _________ object.

A. Response

B. Servlet

C. Session

D. HTTPServlet

Answer optiona

Marks: 1

2801 The jsp directives are messages that tells the web container how to translate a JSP page into the corresponding ____________

A. Servlet

B. Cookie

C. Session

D. HyperText

Answer optiona

Marks: 1

2802 Which methods are used to get the output shown in figure

A. getSelectedItem();getSelectedIndex();getItemCount();

B. getItem();getIndex();getItemCount();

C. getSelectedItem();getSelectedIndex();getItem();

D. getItemSelected();getIndexSelected();getItemCount();

Answer optiona

Marks: 2

2803 Identify the AWT components shown in the output

A. Label,TextArea &Button

B. Label,TextArea,Button & Frame

C. Label,TextField &Button

D. Label,TextField,Button & Frame

Answer optiond

Marks: 2

2804 Figure shown is the example of which layout manager.

A. GridLayout

B. BoxLayout

C. FlowLayout

D. GridBagLayout

Answer optiond

Marks: 2
2805 The default layout for a dialog is____________

A. GridLayout

B. BoxLayout

C. FlowLayout

D. BorderLayout

Answer optiond

Marks: 2

2806 Select the correct code to get the factorial of a number.

public void ActionPerformed(ActionEvent e)


{
String s = textfield1.getText();
A. int a = Integer.parseInt(s);
int w=a*a;
textfield2.setText(Integer.toString(w));
}

public void actionPerformed(ActionEvent e)


{
String s = textfield1.getText();
B. int a = Integer.parseInt(s);
int w=a*a;
textfield2.setText(Integer.toString(w));
}

public void actionPerformed(ActionEvent e)


{
String s = textfield1.getText();
C. int a = Integer.parseInt(s);
int w=a*a;
}

public void actionPerformed(actionevent e)


{
String s = textfield1.getText();
D. int a = Integer.parseInt(s);
int w=a*a;
textfield2.setText(Integer.toString(w));
}

Answer optiona

Marks: 2

2807 What does the method getActionCommand() return?

A. Command

B. Character

C. String

D. Integer

Answer optionc

Marks: 2

2808 ServerSocket(int port) throws ______________

A. IOException

B. SecurityException

Both of above
C.

D. None of the above

Answer optionc

Marks: 2

2809 send() and receive() method of Datagram Socket class send and receive data in the form of ________

A. Message

B. DatagramPacket

C. Bytes

D. Bits
Answer optionb

Marks: 2

Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver�);
2810 Refer to which step in querying databases.

A. Execute a query or update.

B. Process the results.

C. Close the connection.

D. Load the JDBC driver.

Answer optiond

Marks: 2

2811 Which SQL statements can be passed in executeUpdate() method?

A. SELECT

B. INSERT

C. BOTH OF THE ABOVE

D. NONE OF THE ABOVE

Answer optionb

Marks: 2

2812 Which method of ResultSet interface moves the cursor forward one row from its current position?

A. First

B. Next

C. Previous

D. Last

Answer optionb

Marks: 2

2813 What are the paramenters of doGet() method?

A. ServletContext,Servlet

B. HttpServletRequest request,HttpServletResponse response

C. Servlet,GenericServlet

D. None of the above

Answer optionb

Marks: 2

What does the below statement refer to?


2814 response.setContentType("text/html");

A. This tells the client to interpret the page as HTML

B. This tells the server to interpret the page as HTML

C. This tells the client and server to interpret the page as HTML

D. None of the above

Answer optiona

Marks: 2

2815 getParameterNames() method returns

A. Returns an Enumeration of the parameter names

B. Returns the value of the parameter name as a String

C. Returns an array of values of the parameter name


D. None of the above

Answer optiona

Marks: 2

What lines should be inserted in the missing rows to get a button on the frame window?
import java.awt.*;
class MyFrame3 extends Frame
{
Button b;
MyFrame3()
{
super("My Frame");
________________
________________
2816 ________________
b.setBounds(20,60,70,20);
add(b);
}
public static void main(String args[])
{
MyFrame3 f=new MyFrame3();
f.show();
}
}

setSize(400,300);
A. b=new Button("show");
setLayout(null);

b=new Button("show");
B. setLayout(null);

setSize(400,300);
C. b=new button("show");
setLayout(null);

setSize(400,300);
D. b=new Button("show");

Answer optiona

Marks: 2

What is the output of the below code?


import java.awt.*;
public class MyMenu1 extends Frame
{
public static void main(String args[])
{
MyMenu1 m=new MyMenu1();

m.setTitle("MyFrame");
m.setVisible(true);
MenuBar mbr=new MenuBar();
2817 m.setMenuBar(mbr);
Menu m1=new Menu("Format");
Menu m2=new Menu("help");
mbr.add(m1);
mbr.add(m2);
MenuItem p1=new MenuItem("word wrap");
CheckboxMenuItem p2=new CheckboxMenuItem("Font");
m1.add(p1);
m1.add(p2);
}
}

A. S1Q43O1.jpeg

B. S1Q43O2.jpeg

C. S1Q43O3.jpeg

D. All of the above

Answer optionc

Marks: 2
Complete the code to draw JTable on applet window?
/*<applet code="MyJTable" width=900 height=900>
</applet>*/
import java.awt.*;
import javax.swing.*;
public class MyJTable extends Japplet {
public void init() {
Container c=getContentPane();
c.setLayout(new FlowLayout());
String[] columnnames={"Name","RollNo"};
2818 String rowdata[][]=
{
{"ABC","1"},
{"PQR","2"},
{"XYZ","3"},
};
-------------
-------------
-------------
}
}

JTable jt=new JTable(rowdata,columnnames);


A. JScrollPane jsp=new JScrollPane(jt);
c.add(jsp);

Table jt=new Table(rowdata,columnnames);


B. JScrollPane jsp=new JScrollPane(jt);
c.add(jsp);

JTable jt=new JTable(rowdata,columnnames);


C. JScrollPane jsp=new JScrollPane(jt);
c.add(j);

JTable jt=new JTable(rowdata,columnnames);


D. JScrollPane jsp=new JScrollPane();
c.add(jsp);

Answer optiona

Marks: 2

2819 Which code is correct to get the below output?

JLabel above = new JLabel("Above Separator");


A. JSeparator separator = new JSeparator();
JLabel below = new JLabel("Below Separator");

JLabel above = new JLabel("Above Separator");


content.add(above);
JSeparator separator = new JSeparator();
B. content.add(separator);
JLabel below = new JLabel("Below Separator");
content.add(below);

JLabel above = new JLabel("Above Separator");


content.add(above);
JSeparator separator = new JSeparator();
C. content.add(s);
JLabel below = new JLabel("Below Separator");
content.add(below);

JLabel above = new JLabel("Above Separator");


content.add(above);
JSeparator separator = new JSeparator();
D. content.add(separator);
JLabel below = new JLabel("Below Separator");
content.add(above);

Answer optionb

Marks: 2
Select the missing statement for the program.
/*<applet code="MyControl7" width=300 height=300>
</applet>*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MyControl7 extends Applet implements ItemListener
{
Checkbox c1,c2,c3;
TextField t;
public void init()
{
t=new TextField();
c1=new Checkbox("Mumbai");
c2=new Checkbox("Pune");
c3=new Checkbox("Delhi");
setLayout(null);
c1.setBounds(20,20,70,20);
c2.setBounds(20,45,70,20);
c3.setBounds(20,70,70,20);
2820 t.setBounds(20,150,100,20);
add(c1);
add(c2);
add(c3);
add(t);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
}
public void ______________________
{
String s=" ";
if(c1.getState())
s=s+"Mumbai";
if(c2.getState())
s=s+"Pune";
if(c3.getState())
s=s+"Delhi";
t.setText(s);
}
}

A. itemStateChanged(ItemEvent ie)

B. actionPerformed(ActionEvent e)

C. adjustmentValueChanged(AdjustmentEvent ae)

D. keyPressed(KeyEvent ke)

Answer optiona

Marks: 2

Is the below given code correct to dispose the frame window on click event of close button.
import java.awt.*;
import java.awt.event.*;
class MyWindow2 extends Frame implements WindowListener
{
MyWindow2()
{
super("My Window");
setSize(400,300);
addWindowListener(this);
}
public static void main(String args[])
{
MyWindow2 w=new MyWindow2();
w.show();
}
public void windowOpened(WindowEvent we)
{
}
public void windowClosing(WindowEvent we)
2821 {
dispose();
}
public void windowClosed(WindowEvent we)
{
System.exit(0);
}
public void windowIconified(WindowEvent we)
{
}
public void windowDeiconified(WindowEvent we)
{
}
public void windowActivated(WindowEvent we)
{
}
public void windowDeactivated(WindowEvent we)
{
}
}

A. Yes

B. No

C. cant predict

D. both A and B

Answer optiona
Marks: 2

Complete the code to display the selected item of the list.


/*<applet code="MyControl11" width=300 height=300>
</applet>*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MyControl11 extends Applet implements ItemListener
{
List list;
Label l;
public void init()
{
list=new List();
l=new Label();
list.add("one");
2822 list.add("two");
list.add("three");
setLayout(null);
list.setBounds(20,20,100,20);
l.setBounds(20,150,100,20);
add(list);
add(l);
list.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
________________________
}
}

A. List.getSelectedObjects();

B. l.setText(list.getSelectedItem());

C. label.setText(list.getSelectedItem());

D. list.getItem();

Answer optionb

Marks: 2

Choose the correct output for the program.


import java.net.*;
class myURL1
{
public static void main(String args[]) throws MalformedURLException
{
2823 URL u=new URL("http://www.msbte.com/main");
System.out.println("Protocol="+u.getProtocol());
System.out.println("Host Name="+u.getHost());
System.out.println("Port Number="+u.getPort());
System.out.println("File Name="+u.getFile());
}
}

Protocol=http
Host Name=www.msbte.com
A. Port Number=-1
File Name=/ main

Protocol=http
Host Name=www.msbte.com
B. Port Number=8080
File Name=/ main

Protocol=http
C. Host Name=www.msbte.com
Port Number=-1
File Name=

Protocol=http
Host Name=www.msbte.com
D. Port Number=8080
File Name=

Answer optiona

Marks: 2

Identify the method used for establishing the connection to the database.

import java.sql.*;
class Mydatabase1
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
2824 System.out.println("Driver Loaded");
Connection c=DriverManager._______________ ("jdbc:odbc:MYDSN"," "," ");
System.out.println("Connection Established");
}
catch(Exception e)
{
System.out.println(e);
}
}
}
A. getConnection();

B. getConnection(String url, String user, String password);

C. getConnection(String url);

D. getConnection(String url, Properties info);

Answer optionb

Marks: 2

Which symbol is used for inserting the record dynamically.


2825 PreparedStatement p=c.prepareStatement("insert into Employee values(_,_)");

A. *

B. #

C. ?

D. $

Answer optionc

Marks: 2

Identify the correct sequence for querying the database


2826 There are seven standard steps in querying databases:

• Load the JDBC driver.


• Define the connection URL.
• Establish the connection.
A. • Execute a query or update.
• Create a statement object.
• Process the results.
• Close the connection.

• Load the JDBC driver.


• Define the connection URL.
• Establish the connection.
B. • Create a statement object.
• Execute a query or update.
• Process the results.
• Close the connection.

• Load the JDBC driver.


• Establish the connection.
• Define the connection URL.
C. • Create a statement object.
• Execute a query or update.
• Process the results.
• Close the connection.

• Load the JDBC driver.


• Define the connection URL.
• Establish the connection.
D. • Process the results.
• Create a statement object.
• Execute a query or update.
• Close the connection.

Answer optionb

Marks: 2

Identify the packages needed to execute the below program.


public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println ("<!DOCTYPE HTML PUBLIC \�-//W3C//DTD HTML
2827 4.0 Transitional//EN\�>");
out.println("<HTML><HEAD><TITLE>Hello
World</TITLE></HEAD>");
out.println(�<BODY><BIG>Hello World
</BIG></BODY></HTML>");
out.close();
}
}

A. import java.io.*;

import java.io.*;
B. import javax.servlet.*;
import javax.servlet.http.*;

C. import javax.servlet.*;

import java.io.*;
D. import javax.servlet.*;
import java.net.*;
Answer optionb

Marks: 2

getSession() method is called using object of?


2828 HttpSession session =__________.getSession();

A. HTTPRequest object

B. Session object

C. Cookie object

D. ServletContext object

Answer optiona

Marks: 1

Select the methods called to obtain name and value information.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class GetCookiesServlet extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
Cookie[] cookies = request.getCookies();
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
2829 pw.println("<B>");
for(int i = 0; i < cookies.length; i++)
{
________________________
________________________

pw.println("name = " + name +"; value = " + value);


}
pw.close();
}
}

String Name = cookies[i].getName();


A. String Value = cookies[i].getValue();

String name = cookies[i].getName();


B. String value = cookies[i].getValue();

String name = Cookies[i].getName();


C. String value = Cookies[i].getValue();

String name = cookies[i].getNames();


D. String value = cookies[i].getValues();

Answer optionb

Marks: 2

2830 Which of following is not a valid awt component.

A. Button

B. Label

C. Dialog boxes

D. TextField

Answer optionc

Marks: 1

2831 Which of the following statements is for placing the frames upper left corner to (200,100)?

A. setLocation(200,100)

B. setForLocation(200,100)

C. setPosition(200,100)

D. None of these

Answer optiona

Marks: 1

2832 Which of the following swing components donot have an Icon parameter in its constructor?

A. JLabel

B. JButton
C. JCheckBox

D. JTextField

Answer optiond

Marks: 1

2833 Window , frame and dialog use ________ as their default layout.

A. GridLayout

B. BorderLayout

C. FlowLayout

D. CardLayout

Answer optionb

Marks: 1

2834 ____________creates a dropdown list of textual entries

A. Choice

B. JComboBox

C. List

D. Both A & B

Answer optiond

Marks: 1

2835 Which of following Component generate AdjustmentEvent

A. Button

B. Scrollbar

C. List

D. Choice

Answer optionb

Marks: 1

2836 Which of the following listeners have similar adapter class

A. ActionListener

B. ItemListener

C. AdjustmentListener

D. FocusListener

Answer optiond

Marks: 1

2837 Which are constants of KeyListener

A. VK_PAGE_DOWN

B. VK_ALT

C. VK_UP

D. All of these

Answer optiond

Marks: 1

2838 Which of the following is not method of MouseListener


A. mouseMoved(MouseEvent me)

B. mouseClicked(MouseEvent m);

C. mouseEntered(MouseEvent me)

D. mouseExited(MouseEvent me);

Answer optiona

Marks: 1

2839 Which class is used to create object of Socket on server side

A. Socket

B. ServerSocket

C. DatagramPacket

D. InetAddress

Answer optionb

Marks: 1

2840 Which of the following are URL class Constructors.

A. URL(String urlspecifier)

B. Url (String urlspecifier)

C. URL(Url urlspecifier,String port)

D. None of these

Answer optiona

Marks: 1

2841 Which of the following is factory method of InetAddress class

A. getAddress()

B. getLocalPort()

C. getByName()

D. getHostname()

Answer optionc

Marks: 1

2842 While sending packets using DatagramPacket class which constructors are used to create object of DatagramPacket

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

B. DatagramPacket(byte data[ ], int size, int port ,InetAddress ipAddress)

C. DatagramPacket(byte data[ ], int size, InetAddress ipAddress, int port)

D. DatagramPacket(byte data[ ], int offset, int size)

Answer optionc

Marks: 1

2843 Which of the methods are of ResultSet interface

A. afterLast()

B. beforeFirst()

C. first()

D. All of these

Answer optiond

Marks: 1
2844 The JDBC-ODBC bridge is ____________

A. Multithreaded

B. Three tiered

C. Best for any platform

D. All of the above

Answer optiona

Marks: 1

2845 Which are different types of servlets

A. HttpServlet

B. FTPServlet

C. GenericServlet

D. Both A & C

Answer optiond

Marks: 1

2846 Which class is used to implement concept of cookies

A. Cookie

B. Cookies

C. Cookiee

D. None of these

Answer optiona

Marks: 1

What code should be added so that we can get following Code?


import java.awt.*;
import java.awt.event.*;
class WindowCloseDemo extends Frame
{
Button exit;
WindowCloseDemo()
{
exit=new Button("OK");
2847 add(exit);
WindowClose w =new WindowClose();
addWindowListener(w );

setSize(400,300);
setVisible(true); }
public static void main(String []cd)
{ WindowCloseDemo w cd=new WindowCloseDemo(); } }
class WindowClose extends WindowAdapter
{ public void windowClosing(WindowEvent we) { System.exit(1); } }

A. setTitle("Window ");

B. setLayout(new FlowLayout())

C. import java.applet.*;

D. All of these

Answer optionb

Marks: 2

2848 What will be program to give above o/p

import java.awt.*;
import java.applet.*;
/*<applet code="demo1" width=300 height=300></applet>*/
public class demo1 extends Applet
{
Button b1,b2;
public void init()
A. {
b1=new Button("OK");
b2=new Button("Cancel");
setLayout(new FlowLayout(FlowLayout.RIGHT));
add(b1);
add(b2);
}
}
import java.awt.*;
import java.applet.*;
/*<applet code="demo1" width=300 height=300></applet>*/
public class demo1 extends Applet
{
Button b1,b2;
public void init()
B. {
b1=new Button("OK");
b2=new Button("Cancel");
setLayout(new FlowLayout(FlowLayout.LEFT));
add(b1);
add(b2);
}
}

import java.awt.*;
import java.applet.*;
/*<applet code="demo1" width=300 height=300></applet>*/
public class demo1 extends Applet
{
Button b1,b2;
public void init()
C. {
b1=new Button("OK");
b2=new Button("Cancel");
setLayout(new FlowLayout());
add(b1);
add(b2);
}
}

import java.awt.*;
import java.applet.*;
/*<applet code="demo1" width=300 height=300></applet>*/
public class demo1 extends Applet
{
Button b1,b2;
D. public void init()
{
b1=new Button("OK");
b2=new Button("Cancel");
setLayout(new FlowLayout(FlowLayout.RIGHT));
}
}

Answer optiona

Marks: 2

import java.awt.*;
import java.applet.*;
/*<applet code="demo3" width=300 height=300></applet>*/
public class demo3 extends Applet
{
Button b1,b2;
public void init()
2849 {
b1=new Button("OK");
b2=new Button("Cancel");
setLayout(new BorderLayout());
add(b1,BorderLayout.EAST);
add(b2,BorderLayout.WEST);
}}

A. S1Q2701.jpg

B. S1Q2702.jpg

C. S1Q2703.jpg

D. None of these

Answer optionc

Marks: 2
To produce follow ing output in given program w hich statement should be placed to change the background color of applet
import javax.sw ing.*;
import java.aw t.*;
import java.aw t.event.*;
/* <applet code=JRadioButtonDemo.class w idth=500 height=500> </applet> */
public class JRadioButtonDemo extends JApplet implements ItemListener
{ JRadioButton r,g,b;
ButtonGroup bg;
Container cp;
public void init()
{
r=new JRadioButton("RED");
g=new JRadioButton("GREEN");
b=new JRadioButton("BLUE");
cp= getContentPane(); cp.setLayout(new Flow Layout());
2850 cp.add(r);
cp.add(g);
cp.add(b);
bg=new ButtonGroup();
bg.add(r);
bg.add(g);
bg.add(b);
r.addItemListener(this);
g.addItemListener(this);
b.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{ ...........................................................................
..........................................................................
....................................................................... } }

if(ie.getItemSelectable()==r) cp.setBackground(Color.RED); if(ie.getItemSelectable()==g) cp.setBackground(Color.GREEN); if(ie.getItemSelectable()==b) cp.se


A.

B. if(ie.getItemSelected()==r) cp.setBackground(Color.RED); if(ie.getItemSelected()==g) cp.setBackground(Color.GREEN); if(ie.getItemSelected()=

C. Both A and B

D. None of these

Answer optiona

Marks: 2

What will be o/p of following program


/*<applet code="DemoFont3" width=400 height=300></applet>*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DemoFont3 extends Applet implements MouseListener
{
Font f;
int click=0;
int size=1;
public void init()
{
addMouseListener(this);
} public void mouseClicked(MouseEvent e)
{
2851 if(e.getClickCount()<11)
{
size=size+2;
}
repaint();
}
public void mousePressed(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void paint(Graphics g) {
f=new Font("Times New Roman",Font.BOLD,size);
setFont(f);
g.drawString("JAVA",100,200);
}

A. When mouse is clicked String java will be displayed

B. On every mouse click string will be displayed in increased size

C. On every mouse click color of string will be changed

D. None of these

Answer optionb

Marks: 2

2852 Which classes are used for connection-less socket programming?

A. DatagramSocket

B. DatagramPacket

C. Both A & B

D. None of the above

Answer optionc
Marks: 2

2853 The client in socket programming must know which informations?

A. IPaddress of Server

B. Port number

C. Both A & B

D. None of the above

Answer optionc

Marks: 2

2854 Which of the following methods are used to read data from socket

A. getStream()

B. getInputStream()

C. getOutputStream()

D. None of these

Answer optionb

Marks: 2

2855 What is disadvantage of Type 4Native-Protocol Driver

A. At client side separate driver is needed for each database

B. Type-4 driver is entirely written in java

C. It does not support to read MYSql data

D. The driver converts JDBC calls to vendor specific database protocolA

Answer optiona

Marks: 2

Find out errors in following program


import java.sql.*;
import java.io.*;
public class Exp10_1_5
{
public static void main(String arg[])
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection();
Statement s=c.createStatement();
String q="select * from student_register";
ResultSet r=s.executeQuery(q);
2856 while(r.next())
{
System.out.println("Roll No:"+r.getInt(1));
System.out.println("Name:"+r.getString(2));
System.out.println("Phone No=:"+r.getInt(3));
}
c.close();
}
catch(ClassNotFoundException e)
{ }
catch(SQLException e1)
{ }
}
}

A. Driver is not loaded properly

B. Connection is not established

C. Query execution is not correct

D. Program will execute Properly

Answer optionb

Marks: 2

2857 Which method is used to perform DML statements in JDBC?

A. executeResult()

B. execute()
C. executeUpdate()

D. executeQuery()

Answer optiond

Marks: 2

2858 To get the servlet environment information

A. ServletConfig object is used

B. ServletContainer object is used

C. ServletContext object is used

D. ServletException object is used

Answer optionc

Marks: 2

2859 Which method is used to specify before any lines that uses the PintWriter?

A. SetPageType()

B. setContentsType()

C. setContextType()

D. SetContentType()

Answer optiond

Marks: 2

import javax.swing.*;
public class MyProgress extends JFrame{
JProgressBar jb;
int i=0,num=0;
MyProgress(){
jb=new JProgressBar(0,2000);
jb.setBounds(40,40,200,30);

jb.setValue(0);
jb.setStringPainted(true);

add(jb);
setSize(400,400);
setLayout(null);
2860 }

public void iterate(){


while(i<=2000){
jb.setValue(i);
i=i+20;
try{Thread.sleep(150);}catch(Exception e){}
}
}
public static void main(String[] args) {
MyProgress m=new MyProgress();
m.setVisible(true);
m.iterate();
}
}

A. S1Q4201.jpg

B. S1Q4202.jpg

C. S1Q4203.jpg

D. Program will not esecute

Answer optiona

Marks: 2

2861 Which is correct code to display following o/p


import javax.swing.*;
public class R {
JFrame f;

R (){
f=new JFrame();

JRadioButton r1=new JRadioButton("A) Male");


JRadioButton r2=new JRadioButton("B) FeMale");
r1.setBounds(50,100,70,30);
r2.setBounds(50,150,70,30);

A. ButtonGroup bg=new ButtonGroup();


bg.add(r1);bg.add(r2);

f.add(r1);f.add(r2);

f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new R ();
}
}

import javax.swing.*;
public class R {
JFrame f;

Radio(){
f=new JFrame();

JRadioButton r1=new JRadioButton("A) Male");


JRadioButton r2=new JRadioButton("B) FeMale");
r1.setBounds(50,100,70,30);
r2.setBounds(50,150,70,30);

B. ButtonGroup bg=new ButtonGroup();


bg.add(r1);bg.add(r2);

f.add(r1);f.add(r2);

f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new Radio();
}
}

import javax.swing.*;
public class R {
JFrame f;

Radio(){
f=new JFrame();

JRadioButton r1=new JRadioButton("A) Male");


JRadioButton r2=new JRadioButton("B) FeMale");
r1.setBounds(50,100,70,30);
r2.setBounds(50,150,70,30);

ButtonGroup bg=new ButtonGroup();


C. bg.add(r2);
bg.add(r1);

f.add(r1);f.add(r2);

f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new Radio();
}
}

import javax.swing.*;
public class R {
JFrame f;

Radio(){
f=new JFrame();

JRadioButton r1=new JRadioButton("A) Male");


JRadioButton r2=new JRadioButton("B) FeMale");
r1.setBounds(50,100,70,30);
r2.setBounds(50,150,150,30);
D.
f.add(r1);f.add(r2);

f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new Radio();
}
}

Answer optiona

Marks: 2
Which statements should be added to the following program to get this o/p
import javax.swing.*;
import java.awt.*;
import javax.swing.tree.*;
/*<applet code="JTreeE1" width=400 height=200></applet>*/
public class JTreeE1 extends JApplet
{JTree tree;
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
2862 DefaultMutableTreeNode top = new DefaultMutableTreeNode("India");
DefaultMutableTreeNode a = new DefaultMutableTreeNode("Maharashtra");
top.add(a);
DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("Pune");
a.add(a1);
DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("Mumbai");
a.add(a2);
tree = new JTree(top);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(tree, v,h);
contentPane.add(jsp, BorderLayout.CENTER);}}

DefaultMutableTreeNode a21 = new DefaultMutableTreeNode("Panvel");


A. a2.add(a21);

DefaultMutableTreeNode a21 = new DefaultMutableTreeNode("Panvel");


B. a1.add(a21);

DefaultMutableTreeNode a21 = new DefaultMutableTreeNode("Panvel");


C. top.add(a21);

DefaultMutableTreeNode a21 = new DefaultMutableTreeNode("Panvel");


D. a.add(a21);

Answer optiona

Marks: 2

import java.awt.*;
import java.applet.*;
/* <applet code="SBDemo1" width=300 height=200> </applet> */
public class SBDemo1 extends Applet
{Scrollbar vertSB, horzSB;
public void init()
{
2863 int width = Integer.parseInt(getParameter("width"));
int height = Integer.parseInt(getParameter("height"));
vertSB = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, height);
horzSB = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, width);
add(vertSB);
add(horzSB);
}
}

A. Horizontal Scrollbar will be displayed

B. Vertical Scrollbar will be displayed

C. Both a & B

D. None of these

Answer optionc

Marks: 2

For the following code select the method that can be used to handle event

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*<applet code="scr" width=300 height=300></applet>*/
public class scr extends Applet implements ItemListener
{
Checkbox r,g,b;
public void init()
{
CheckBoxGroup cbg=new CheckBoxGroup();
r=new Checkbox(�RED�,cbg,true);
g=new Checkbox(�GREEN�,cbg,false);
b=new Checkbox(�BLUE�,cbg,false);
add(r);
2864 add(g);
add(b);
r.addItemListener(this);
g.addItemListener(this);
b.addItemListener(this);
}
public void _______________________________________
{
if(ie.getItem()==r)
setBackground(Color.red);
else
if (ie.getItem==g)
setBackground(Color.green);
else
setBackground(Color.blue);
}}

A. itemChanged(ItemEvent ie)
B. itemChanged(ActionEvent ie)

C. adjustmentValueChanged(ItemEvent ie)

D. itemStateChanged(ItemEvent ie)

Answer optiond

Marks: 2

What will be o/p of following program


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="AppDemo1" width=300 height=180></applet>*/
public class AppDemo1 extends Applet implements ItemListener {
Choice os;
List l;
public void init()
{
os = new Choice();
os.add("Windows 98/XP");
2865 os.add("Windows NT/2000");
os.add("Solaris");
os.add("MacOS");
add(os);
l= new List();
os.addItemListener(this);
add(l);
}
public void itemStateChanged(ItemEvent e)
{
if(e.getItemSelectable()==os)
l.addItem(((Choice)e.getItemSelectable()).getSelectedItem());}
}

A. Selected item of choice are added to list

B. Selected item of list are added to choice

C. It will check which component is generating event

D. None of these

Answer optiona

Marks: 2

/*<applet code="DemoFont3" width=400 height=300></applet>*/


import java.awt.*;
What will be O/P of following program
import java.awt.event.*;
import java.applet.*;
public class DemoFont3 extends Applet implements MouseListener
{ Font f;
int click=0;
int size=1;
public void init() {
addMouseListener(this);
}
2866 public void mouseClicked(MouseEvent e)
{ if(e.getClickCount()<11)
{ size=size+2; }
repaint(); }
public void mousePressed(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void paint(Graphics g)
{ f=new Font("Times New Roman",Font.BOLD,size);
setFont(f);
g.drawString("JAVA",100,200);
}}

A. On every click Font Style will be changed

B. On every mouse click font size will be increase by two upto 10 mouse clicks

C. Program will not execute

D. None of these

Answer optionb

Marks: 2
Select the correct answer
import java.net.*;
import java.io.*;
import java.util.Date;
class UCDemo
{
public static void main(String
args[]) throws___________
2867 {
_____________________________
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());}}

MalformedURLException,
A. URL hp = new URL("http://www.internic.net");

UnknownHostException,
B. URL hp = new URL("http://www.internic.net");

C. URL hp = new URL("http://www.internic.net"); UnknownHostException,

D. URL hp = new URL("http://www.internic.net"); MalformedURLException,

Answer optiona

Marks: 2

Find out the error in following program


class InetAddressTest
{
public static void main(String args[])
2868 {
InetAddress Address = InetAddress.getLocalHost();
System.out.println(Address);
}}

A. UnknownHostException must be caught

B. java.net. Package is required

C. Both A&B

D. None of these

Answer optionc

Marks: 2

What will be output of this program


import java.sql.*;
public class JDBCExample {
public static void main(String[] args) throws Exception
{
Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver");
2869 System.out.println("Connecting to database...");
conn = DriverManager.getConnection(jdbc:odbc:stud�);
stmt = conn.createStatement();
String sql = "select * from student;";
stmt.executeUpdate(sql);
}}

A. All records are displayed

B. Program will not Execute

C. Connection will not be established

D. None of these

Answer optionb

Marks: 2

Which statements are required in following program to retrive records from table
import java.sql.*;
public class JDBCExample {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connecting to database...");
2870 conn = DriverManager.getConnection(jdbc:odbc:stud�);
System.out.println(" Records of table...");
stmt = conn.createStatement();
______________________________________________________
__________________________________________________________________
System.out.println("Inserted records into the table...");
System.out.println("Goodbye!");
}}

A. ResultSet rs=stmt.executeQuery("select * from student");


B. ResultSet rs=stmt.execute("select from student");

C. ResultSet rs=stmt.executeUpdate("select * from student");

D. None of these

Answer optiona

Marks: 2

2871 Which of the following is correct code to execute stored procedures

import java.sql.*;
public class JDBCExample {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver");
A. System.out.println("Connecting to database...");
conn = DriverManager.getConnection(jdbc:odbc:stud”);
System.out.println(" Records of table...");
stmt = conn.createStatement();
stmt.execute("exec proc ");
System.out.println("Goodbye!");
}}

args) {
Connection conn = null;
PreparedStatement stmt = null;
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connecting to database...");
B. conn = DriverManager.getConnection(jdbc:odbc:stud”);
System.out.println(" Records of table...");
stmt = conn.createStatement();
stmt.execute("exec proc ");
System.out.println("Goodbye!");
}}

import java.sql.*;
public class JDBCExample {
public static void main(String[] args) {
Connection conn = null;
CallableStatement stmt = null;
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver");
C. System.out.println("Connecting to database...");
conn = DriverManager.getConnection(jdbc:odbc:stud”);
System.out.println(" Records of table...");
stmt = conn.prepareCall("exec Proc");
stmt.execute();
System.out.println("Goodbye!");
}}

import java.sql.*;
public class JDBCExample {
public static void main(String[] args) {
Connection conn = null;
CallableStatement stmt = null;
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connecting to database...");
D.
conn = DriverManager.getConnection(jdbc:odbc:stud”);
System.out.println(" Records of table...");
stmt = conn.createStatement();
stmt.execute("exec proc ");
System.out.println("Goodbye!");
}}

Answer optionc

Marks: 2

Which statements should be inserted in program to execute following query


import java.sql.*;
public class JDBCExample {
public static void main(String[] args) {
Connection conn = null;
PreparedStatement stmt = null;
Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver");
2872 conn = DriverManager.getConnection(jdbc:odbc:stud�);
String sql="INSERT INTO Registration "+"VALUES (?,?,?)";
stmt.setInt(1,100);
stmt.setString(2,'ABC');
stmt.setInt(3,45);
stmt.close();
conn.close();}}

stmt = conn.prepareStatement(sql);
A. int i= stmt.executeUpdate();

stmt = conn.preparedStatement(sql);
B. int i= stmt.executeUpdate();

stmt = conn.prepareStatement(sql);
C. int i= stmt.execute();

D. Program will execute without inserting any statements

Answer optiona

Marks: 2
2873 Which is correct code to retrieve cookies

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SettingandReadingCookies extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>");
out.println("A Web Page");
out.println("</TITLE>");
out.println("</HEAD>");
A. out.println("<BODY");
Cookie[] cookies = request.getCookies();
boolean foundCookie = false;
for(int loopIndex = 0; loopIndex < cookies.length; loopIndex++)
{
Cookie cookie1 = cookies[loopIndex];
if (cookie1.getName().equals("color"))
{
out.println("bgcolor = " + cookie1.getValue());
foundCookie = true;
} }
out.println("<H1>Setting and Reading Cookies</H1>");
out.println("This page will set its background color using a cookie when reloaded."); out.println("</BODY>");
out.println("</HTML>");
} }

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SettingandReadingCookies extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>");
out.println("A Web Page");
out.println("</TITLE>");
B. out.println("</HEAD>");
out.println("<BODY");
boolean foundCookie = false;
for(int loopIndex = 0; loopIndex < cookies.length; loopIndex++)
{
Cookie cookie1 = cookies[loopIndex];
if (cookie1.getName().equals("color"))
{
out.println("bgcolor = " + cookie1.getValue());
foundCookie = true;
} }
out.println("<H1>Setting and Reading Cookies</H1>");
out.println("This page will set its background color using a cookie when reloaded.");
out.println("</HTML>");
} }

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SettingandReadingCookies extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>");
out.println("A Web Page");
out.println("</TITLE>");
out.println("</HEAD>");
C. out.println("<BODY");
Cookie[] cookies = req.getCookie();
boolean foundCookie = false;
for(int loopIndex = 0; loopIndex < cookies.length; loopIndex++)
{
Cookie cookie1 = cookies[loopIndex];
if (cookie1.getName().equals("color"))
{
out.println("bgcolor = " + cookie1.getValue());
foundCookie = true;
} }
out.println("<H1>Setting and Reading Cookies</H1>");
out.println("This page will set its background color using a cookie when reloaded."); out.println("</BODY>");
out.println("</HTML>");
} }
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SettingandReadingCookies extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>");
out.println("A Web Page");
out.println("</TITLE>");
out.println("</HEAD>");
D. out.println("<BODY");
Cookie[] cookies = request.getCookieName();
boolean foundCookie = false;
for(int loopIndex = 0; loopIndex < cookies.length; loopIndex++)
{
Cookie cookie1 = cookies[loopIndex];
if (cookie1.getName().equals("color"))
{
out.println("bgcolor = " + cookie1.getValue());
foundCookie = true;
} }
out.println("<H1>Setting and Reading Cookies</H1>");
out.println("This page will set its background color using a cookie when reloaded."); out.println("</BODY>");
out.println("</HTML>");
} }

Answer optiona

Marks: 2

Which statement is required instead of________________


<html>
<body>
2874 <%@ page import= _____________________%>
Today is: <%= new Date() %>
</body>
</html>

A. Import java.lang

B. java.util.Date

C. java.uti.*;

D. Import java.util.*;

Answer optionb

Marks: 2

Find out the missing statement in following program


import java.io.*;
import javax.servlet.*;
public class simple extends GenericServlet
{
public void service(ServletRequest rq,ServletResponse rs)throws IOException, ServletException
{
2875 rs.setContentType("text/html");
out.println("<html>");
out.println("<body bgcolor=red>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}

A. import javax.Servlet.http.*;

B. PrintWriter out = rs.getWriter();

C. public void doGet (HttpServletRequest request, HttpServletResponse response)

D. public void doPost (HttpServletRequest request, HttpServletResponse response)

Answer optionb

Marks: 2

2876 To obtain the size of frame window___________ method is used.

A. setSize( )

B. getSize( )

C. getDimension( )

D. None of these

Answer optionb

Marks: 1
2877 When __________ dialog box is active all the inputs are directed to it until it closed.

A. Modal

B. Modeless

C. Input

D. None of these

Answer optiona

Marks: 1

2878 To disable a menu item _______ method is used.

A. setDisable()

B. setEnabled()

C. disable()

D. None of these

Answer optionb

Marks: 1

2879 Which of the following method translates mouse click on specific point of tree to a tree path object?

A. getPath( )

B. getPathForLocation( )

C. getTreePath( )

D. None of these

Answer optionb

Marks: 1

2880 ___________ method is not declared in KeyListener interface.

A. keyTyped()

B. keyPressed()

C. keyEntered()

D. keyReleased()

Answer optionc

Marks: 1

2881 ____________ method is provided by AdjustmentListener.

A. adjusmentEvent()

B. adjustmentValueChanged()

C. getValue()

D. getAdjustmentValue()

Answer optionb

Marks: 1

2882 Which of the following method is used to obtained command name of invoking ActionEvent?

A. getActionCommand()

B. getCommand()

C. getActionEvent()

D. None of these

Answer optiona
Marks: 1

2883 TCP clients are connected with the help of _________ class

A. Socket

B. ServerSocket

C. ClientSocket

D. ClientServerSocket

Answer optiona

Marks: 1

2884 Which of the following method is not a factory method of InetAddress?

A. getAllByName( )

B. getByName( )

C. getHostName( )

D. getLocalHost( )

Answer optionc

Marks: 1

2885 __________ is reliable protocol.

A. TCP

B. UDP

C. Both (i) and (ii)

D. None of these

Answer optiona

Marks: 1

2886 Which of the following class is used to create socket at client side?

A. Socket

B. ClientSocket

C. ServerSocket

D. None of these

Answer optiona

Marks: 1

2887 To execute DELETE query ______________method is used.

A. execute( )

B. executeUpdate( )

C. executeQuery( )

D. None of these

Answer optionb

Marks: 1

2888 Connection is __________

A. Class

B. Interface

C. Method

D. Abstract Class
Answer optionb

Marks: 1

2889 Which of the following method is used to load drivers for database?

A. forName( )

B. loadDriver( )

C. installDriver( )

D. None of these

Answer optiona

Marks: 1

2890 __________is logical set of rows and columns of data returned by executing SQL statement.

A. Statement

B. Connection

C. Table

D. ResultSet

Answer optiond

Marks: 1

2891 _________ are stored at client side and stores state information.

A. Sessions

B. Cookies

C. Forms

D. None of these

Answer optionb

Marks: 1

2892 GenericServlet class is present in __________ package.

A. java.awt

B. javax.servlet.http

C. javax.swing

D. javax.servlet

Answer optiond

Marks: 1

2893 JSP container translates JSP pages into equivalent___________

A. Java Applet

B. html files

C. Java Servlet

D. None of these

Answer optionc

Marks: 1

2894 What components will be needed to get following output?

A. Applet, Label, TextField, Button

B. Applet, Label, TextArea, Button

C. Frame, Label, TextField, Button


D. Frame, Label, TextArea, Button

Answer optiond

Marks: 2

2895 What components will be needed to get following output?

A. JApplet, JComboBox, JCheckBox, JButton

B. JApplet, JComboBox, JRadioButton, JButton

C. JFrame, JComboBox, JRadioButton, JButton

D. JFrame, JComboBox, JCheckBox, JButton

Answer optionc

Marks: 2

Which of the following statement are missing in the code given below?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DemoItemEvent extends Applet
{
Checkbox cb1,cb2;
public void init()
{
cb1=new Checkbox("Red");
add(cb1);
2896 cb2=new Checkbox("Blue");
add(cb2);
cb1.addItemListener(this);
}
public void itemStateChanged()
{
if(ie.getSource()==cb1)
showStatus(cb1.getLabel());
}
}
/*<applet code="DemoItemEvent.class" width=600 height=400></applet>*/

A. Missing parameter in itemStateChanged( ) method

B. Missing implementation of ItemListener interface

C. Missing implementation of ActionListener interface

D. Both (i) and (ii)

Answer optiond

Marks: 2

To get the proper output complete the code given below:


import java.awt.*;
import java.awt.event.*;
class AppWindow extends Frame
{
AppWindow(String title)
{
super(title);
this.addWindowListener(new WindowAdapter()
{
public void _ _ _ _ _ _ _ _ _ _ _ _ _
2897 {
System.exit(0);
}
});
}
public static void main(String args[])
{
AppWindow app=new AppWindow("First Window");
app.setSize(300,400);
app.setVisible(true);
}
}

A. windowClosing(WindowEvent we)

B. windowclosing(WindowEvent we)

C. windowClosing(WindowListener me)

D. None of these

Answer optiona

Marks: 2

2898 Which of the following is correct syntax of getByName() method of InetAddress class?

A. static InetAddress getByName(String hostname)throws UnknownHostException


B. InetAddress getByName(URL hp)throws UnknownHostException

C. static InetAddress[] getByName(String hostname)throws UnknownHostException

D. static InetAddress getByName()throws UnknownHostException

Answer optiona

Marks: 2

2899 Which of the following statement is used by server to accept connection request from client?

Socket ss=new Socket(port);


A. ss.accept( );

Socket ss=new Socket(hostname,port);


B. ss.accept( );

ServerSocket ss=new ServerSocket(port);


C. ss.accept( );

ServerSocket ss=new ServerSocket(hostname,port);


D. ss.accept( );

Answer optionc

Marks: 2

2900 Which of the following is method of InetAddress class?

A. getHostName( )

B. getHostAddress( )

C. isMulticastAddress( )

D. all of above

Answer optiond

Marks: 2

2901 Which of the following is the correct syntax of executeUpdate( ) method?

A. int executeUpdate()

B. int executeUpdate(String str)

C. ResultSet executeUpdate( )

D. ResultSet executeUpdate(String str)

Answer optionb

Marks: 2

2902 Which of the following statement is used to obtain the object of Prepared Statement interface?

A. PreparedStatement pstmt=con.prepareStatement(qry);

B. PreparedStatement pstmt=con.createStatement();

C. Statement pstmt=con.prepareStatement();

D. None of these

Answer optiona

Marks: 2

Which of the following describes the correct sequence involved for inserting record in stud table having two columns rollNo and
sname?
1. Statement stmt=con.createStatement( );
2903 2. Connection con=DriverManager.getConnection(url);
3. int res=stmt.executeQuery(qry);
4. Class.forName(�sun.jdbc.odbc.JdbcOdbcDriver�);
5. String qry= �insert into stud values(12,�xyz�);

A. 1-2-3-4-5

B. 4-2-5-3-1

C. 4-2-1-3-5

D. 4-2-1-5-3
Answer optiond

Marks: 2

2904 Which of the following is correct syntax of service() method of GenericServlet ?

A. void service(SevletContext contex)

B. void service (ServletConfig sc)

C. void service (ServletRequest req, ServletResponse res)

D. void service (ServletResponse res)

Answer optionc

Marks: 2

2905 Which of the following is true about getSession(true) and getSession(false) statement?

A. If no session exist getSession(true) creates and returns session for current request.

B. getSession(false) returns existing session for current request.

C. Both A and B

D. None of these

Answer optionc

Marks: 2

2906 Which of the following statements are used to send cookie to client machine?

Cookie c=new Cookie(“My Cookie”, data);


A. response.addCookie(c);

Cookie c=new Cookie(“My Cookie”, data);


B. response.sendCookie(c);

Cookie c=new Cookie(“My Cookie”, data);


C. request.sendCookie(c);

Cookie c=new Cookie(“My Cookie”, data);


D. request.addCookie(c);

Answer optiona

Marks: 2

Select the proper output for following code:


import java.awt.*;
import java.applet.*;
public class DemoGridLayout extends Applet
{
Button b1,b2,b3,b4,b5;
public void init()
{
GridLayout g=new GridLayout(3,2,30,20);
setLayout(g);

b1=new Button("First");
2907 b2=new Button("Second");
b3=new Button("Third");
b4=new Button("Fourth");
b5=new Button("Fifth");

add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
}
}
/*<applet code="DemoGridLayout.class" width=350 height=200></applet>*/

A. S1Q42O1.jpg

B. S1Q42O2.jpg

C. S1Q42O3.jpg

D. S1Q42O4.jpg

Answer optiona

Marks: 2

2908 Identify the code for the output given below


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DemoCheckBox extends Applet
{
Checkbox cb1,cb2,cb3,cb4;
public void init()
{
cb1=new Checkbox("win/xp");
A. cb2=new Checkbox("win/NT");
cb3=new Checkbox("win/PROF");
cb4=new Checkbox("win/UNIX");

add(cb1); add(cb2);
add(cb3); add(cb4);
}
}
/*<applet code="DemoCheckBox.class" width=300 height=250></applet>*/

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DemoCheckBox extends Applet
{
Checkbox cb1,cb2,cb3,cb4;
public void init()
{
cb1=new Checkbox("win/xp");
B. cb2=new Checkbox("win/NT",true);
cb3=new Checkbox("win/PROF");
cb4=new Checkbox("win/UNIX",true);

add(cb1); add(cb2);
add(cb3); add(cb4);
}
}
/*<applet code="DemoCheckBox.class" width=300 height=250></applet>*/

import java.awt.*;
import java.awt.event.*;
class DemoCheckBox extends Frame
{
Checkbox cb1,cb2,cb3,cb4;
DemoCheckBox()
{
cb1=new Checkbox("win/xp");
cb2=new Checkbox("win/NT",true);
cb3=new Checkbox("win/PROF");
cb4=new Checkbox("win/UNIX",true);
C.
add(cb1); add(cb2);
add(cb3); add(cb4);
}
public static void main(String args[ ])
{
DemoCheckBox d=new DemoCheckBox();
d.setVisible(true);
d.setSize(300,250);
}
}

import java.awt.*;
import java.awt.event.*;
class DemoCheckBox extends Frame
{
Checkbox cb1,cb2,cb3,cb4;
DemoCheckBox()
{
cb1=new Checkbox("win/xp");
cb2=new Checkbox("win/NT");
cb3=new Checkbox("win/PROF");
cb4=new Checkbox("win/UNIX");
D.
add(cb1); add(cb2);
add(cb3); add(cb4);
}
public static void main(String args[ ])
{
DemoCheckBox d=new DemoCheckBox();
d.setVisible(true);
d.setSize(300,250);
}
}

Answer optionb

Marks: 2
Debug the following code and find which statement contains error.

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;

public class DemoJTable extends JApplet


{
JTable jt;
JScrollPane jsp;
public void init()
{
Container c=getContentPane();
c.setLayout(new BorderLayout());

2909 Object data[][]={{"10","xyz","CO"},


{"11","pqr","IF"},
{"12","abc","IF"},
{"13","def","CO"}};

String colheads[]={"Roll No","Name","Branch"};


jt=new JTable(data,colheads);

int vsb=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int hsb=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;

jsp=new JScrollPane(jt);
c.add(jsp,BorderLayout.CENTER);
}
}
/*<applet code="DemoJTable.class" width=300 height=300></applet>*/

A. Error in statement in which JTable is created

B. Error in statement in which JScrollPane is created

C. Error in statement in which applet tag is declared

D. None of these

Answer optionb

Marks: 2

Select the missing statement in the following code


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DemoChoice extends Applet implements ItemListener
{
Choice ch;
public void init()
{
ch=new Choice();
ch.add("Red");
2910 ch.add("Green");
ch.add("Blue");
add(ch)
}
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==ch)
showStatus(ch.getSelectedItem());
}
}
/*<applet code="DemoChoice.class" width=300 height=200></applet>*/

A. add(ch)

B. ch.addItemListener(this);

C. implements ItemListener

D. Both i and iii

Answer optionb

Marks: 2

For the following code select the missing statement


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DemoMouseEvent extends Applet
{
public void init()
{
this.addMouseListener(_ _ _ _ _ _ _ _( )
2911 {
public void mouseEntered(MouseEvent me)
{
showStatus("Mouse Entered");
}
});
}
}
/*<applet code="DemoMouseEvent.class" width=300 height=300></applet>*/

A. new MouseEvent( )

B. new MouseAdapter( )
C. new MouseListener( )

D. None of these

Answer optionb

Marks: 2

For the following code select the missing statement

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class DemoActionEvent extends Applet implements ActionListener


{
Label lblNum1,lblRes;
TextField txtNum1,txtRes;
Button btnSqr;
public void init()
{
lblNum1=new Label("Enter First No:");
txtNum1=new TextField(5);

lblRes=new Label("Largest No:");


txtRes=new TextField(5);
2912 btnSqr=new Button("Square");

add(lblNum1);
add(txtNum1);
add(lblRes);
add(txtRes);

add(btnSqr);

btnSqr.addActionListener(this);
}
public void _ _ _ _ _ _ _ _ _ _ _ _
{
int a=Integer.parseInt(txtNum1.getText());
if(ae.getSource()==btnSqr)
txtRes.setText(""+(a*a));
}
}
/*<applet code="DemoActionEvent.class" width=600 height=300></applet>*/

A. mouseClicked(MouseEvent me)

B. buttonPressed(MouseEvent me)

C. actionPerformed(ActionEvent ae)

D. None of these

Answer optionc

Marks: 2

Debug the following code and find which statement contains error.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DemoAdjustmentEvent extends Applet
implements AdjustmentListener
{
Scrollbar sbRed,sbGreen,sbBlue;
public void init()
{
sbRed=new Scrollbar(Scrollbar.VERTICAL,20,10,0,255);
sbGreen=new Scrollbar(Scrollbar.VERTICAL,20,10,0,255);
sbBlue=new Scrollbar(Scrollbar.VERTICAL,20,10,0,255);

add(sbRed);add(sbGreen);add(sbBlue);
2913
sbRed.addAdjustmentListener(this);
sbGreen.addAdjustmentListener(this);
sbBlue.addAdjustmentListener(this);
}
public void itemStateChanged(AdjustmentEvent ae)
{
int r=sbRed.getValue();
int g=sbGreen.getValue();
int b=sbBlue.getValue();

Color c=new Color(r,g,b);


setBackground(c);
}
}
/*<applet codebase="DemoAdjustmentEvent.class" width=300 height=300></applet>*/

A. Error in statement were itemStateChanged( ) method is defined

B. Error in <applet> tag

C. Error in statement were Scrollbar sbRed is created

D. Both A and B

Answer optiond
Marks: 2

Select the proper output for following code


import java.net.*;
class DemoURL
{
public static void main(String args[])throws MalformedURLException
2914 {
URL hp=new URL("http://www.gmail.com/ /index.php");
System.out.println("Port: "+hp.getPort());
}
}

A. Port: -1

B. Port: 0

C. Error

D. None of these

Answer optiona

Marks: 2

Choose missing statements in following code from given options.


import java.sql.*;
class DemoFetch
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="Jdbc:Odbc:studdsn";
Connection con=____________________;
Statement stmt=con.createStatement();
2915 String qry="select * from stud";
ResultSet rs=stmt.executeQuery(qry);
System.out.println("Roll No\tName ");
while(rs.next())
{
int rno=rs.getInt("roll");
String nm=rs.getString("sname");
System.out.println(rno+"\t"+nm);
}
con.close();
}catch(Exception e){}
}
}

A. DriverManager.getConnection(" "," ")

B. DriverManager.getConnection(url," "," ")

C. DriverManager.createConnection(" "," ")

D. DriverManager.createConnection(url, " "," ")

Answer optionb

Marks: 2

Choose missing statements in following code from given options.


import java.sql.*;
class DemoFetch1
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="Jdbc:Odbc:empdsn";
Connection con=DriverManager.getConnection(url,"","");
String qry="select * from emp";
PreparedStatement stmt=_____________________;
2916 ResultSet rs= stmt.executeQuery();
System.out.println("EmpID\tName\tSalary");
while(rs.next())
{
int eid=rs.getInt("empId");
String nm=rs.getString("ename");
double sal=rs.getDouble("salary");
System.out.println(eid+"\t"+nm+"\t"+sal);
}
con.close();
}catch(Exception e){System.out.println(e.toString());}
}
}

A. con.prepareStatement(qry)

B. con.createStatement(qry)

C. con.createStatement()

D. None of these

Answer optiona
Marks: 2

Which of the following describes the correct sequence of the steps involved in making connection with database using
preparedStatement interface?
1. Establish a connection
2. Create an object of PreparedStaement interface
2917 3. Load JDBC driver
4. Close the Connection
5. Process the Result
6. Execute the SQL Queries
7. Set the parameter values

A. 3-1-2-7-6-5-4

B. 2-3-5-1-6-4-7

C. 3-1-6-2-4-5-7

D. 3-1-2-7-5-6-4

Answer optiona

Marks: 2

Debug the following code and find which statement contains error.
import java.sql.*;
import java.io.*;
class DemoUpdateRecord
{
public static void main(String args[])
{
Connection con;
Statement stmt;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
2918 con=DriverManager.getConnection(Jdbc:odbc:stud"","");
stmt=con.createStatement();
String qry="update stud set per=67.56 where rno=34";
int res=stmt.executeUpdate(qry);
if(res>0)
System.out.println("Operation Successful");

stmt.close();
con.close();
}catch (Exception ex) {}
}
}

A. Error in statement where drivers are loaded

B. Error in statement where executeUpdate() method is called

C. Both i and ii

D. No Error

Answer optiond

Marks: 2

A JSP page called validate.jsp is passed two parameters first username and password in the URL using http://localhost:8080/
validate.jsp?username =admin & password=admin123 . The validate.jsp contains following code
<%
String msg="";
String unm= request.getParameter("username");
String passwd= request.getParameter("password");
2919 if(unm.equals(passwd))
out.println("Valid Login");
else
out.println("In-Valid Login");
%>
What will be the output of above code segment?

A. It will print Valid Login

B. Error

C. It will print In-Valid Login

D. None of these

Answer optionc

Marks: 2
Debug the following code and find which statements are missing or wrong and contains error.
import java.io.*;
import javax.servlet.*;
public class DemoAddCookie extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
2920 String data=request.getParameter("txtdata");
Cookie c=new Cookie("MyCookie",data);
response.setCookie(c);
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
pw.println("<B>My cookie has been sent<BR>");
pw.close();
}
}

A. Missing } statement

B. response.addCookie(c) instead of response.setCookie( c)

C. Missing import javax.servlet.http.*;

D. Both B and C

Answer optiond

Marks: 2

Debug the following code and find which statement contains error.
import java.io.*;
import java.servlet.*;
public class DemoServlet extends GenericServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
2921 {
res.setContentType("text/html");
PrintWriter pw= res.getWriter();
pw.println("<h2> Hello World...");
pw.close();
}
}

A. Error in statement where service method is written

B. No error

C. Error in statement where package java.servlet is imported

D. Error in method where setContentType() method is called

Answer optionc

Marks: 2

Choose missing statements in following code from given options.


import java.io.*;
public class HelloServlet extends GenericServlet
{

public void service(ServletRequest request,ServletResponse response)throws ServletException,IOException


2922 {
response.setContentType("text/html");
pw.println("<B>Hello Servlet");
pw.close();
}
}

A. PrintWriter pw=response.getWriter();

B. import javax.servlet.http.*;

C. import javax.servlet.*;

D. Both i and iii

Answer optiond

Marks: 2

2923 The setColor() is the method of which class?

A. Applet

B. Graphics

C. Color

D. Object

Answer optionb
Marks: 1

2924 How to add the names in choice controls?

A. At the time of creation itself

B. Using addName()

C. Using addItem()

D. using add()

Answer optionc

Marks: 1

2925 In java events are all the activties that occur between

A. The User

B. The Applications

C. Both A & B

D. None of these

Answer optionc

Marks: 1

2926 Event object class belongs to

A. Java.util

B. java.awt

C. java.lang

D. java.sql

Answer optiona

Marks: 1

2927 How to make the group of Radio Buttons?

A. Using ButtonGroup class

B. Using JButtonGroup class

C. Using JRadioButton class

D. Using AbstractButton class

Answer optiona

Marks: 1

2928 The default horizontal and vertical gap is

A. 0 Pixel

B. 1 Pixel

C. 5 Pixel

D. 10 Pixel

Answer optionc

Marks: 1

2929 Which two parameters are required for Jlabel constructor to create Table?

A. Data Array and row headings

B. Data Array and Column Headings

C. Single Data element and column headings

D. Single Data element and row Headings


Answer optionb

Marks: 1

2930 At the root of Java event hierarchy is_______________

A. AWTEvent

B. Event

C. EventObject

D. Events.

Answer optionc

Marks: 1

2931 Which protocol that web browser and servers use for pages and images

A. TCP/IP

B. UDP

C. HTTP

D. SMTP

Answer optionc

Marks: 1

2932 In which form the getAddress() returns object's internet address?

A. Int[]

B. byte[]

C. long[]

D. String

Answer optiond

Marks: 1

2933 _________interface is important for java.sql pacakge in JDBC.

A. Statement

B. Result

C. Connection

D. None of above

Answer optionc

Marks: 1

2934 In which phase of JSP life cycle ,JSP page turns into servlet?

A. JSP Compilation

B. JSP Execution

C. JSP Initialization

D. JSP Cleanup

Answer optiona

Marks: 1

2935 These methods doGet(),doPost(),doHead(),doDelete(),doTrace() are used in?

A. GenericServlet

B. HttpServlet

C. Both A & B
D. None of above

Answer optionb

Marks: 1

2936 Which components are used in the following output?

A. Label,TextField,Button

B. Label,Applet,button

C. TextField,Button

D. Label,Button,

Answer optiona

Marks: 2

2937 ___________is a factory method of InetAddress class which returns an array of InetAddress.

A. getLocalHost()

B. getByName()

C. getAllByName()

D. getByAddress()

Answer optionc

Marks: 2

2938 Which interface provide methods to execute queries with the database?

A. Connection interface

B. Statement interface

C. ResultSet Interface

D. None of the above

Answer optionb

Marks: 2

2939 which of the following awt components does not have text property?

A. Label

B. TextField

C. Checkbox

D. ScrollBar

Answer optiond

Marks: 1

2940 Which of the following awt components does not have intrinsic scrollbar associated with it ?

A. TextArea

B. List

C. Choice

D. TextField

Answer optiond

Marks: 1

2941 Which of the following constructors creates option button (radio button)?

A. Checkbox()

B. Checkbox(String label)
C. Checkbox(String label, boolean state)

D. Checkbox(String label, boolean state, CheckboxGroup group)

Answer optiond

Marks: 1

2942 The following visible swing component displays how much of the total task has completed.

JProgressBar
A.

B. JScrollBar

C. Jlist

D. JComboBox

Answer optiona

Marks: 1

2943 Which of the following awt components shows the list of items from which user may select one or more?

A. Menu

B. List

C. Choice

D. All

Answer optiond

Marks: 1

2944 The state of the following awt components can be turn on or off.

A. Checkbox

B. CheckboxMenuItem

C. Both

D. None

Answer optionc

Marks: 1

2945 The following swing component does not show image on it.

A. Jlabel

B. Jbutton

C. Jcheckbox

D. JTextField

Answer optiond

Marks: 1

2946 Select the features of swing component.

A. Light weight

B. Tool Tips

C. Pluggable look and feel

D. All

Answer optiond

Marks: 1

2947 ______________________ is implemented in order to handle events on TextComponents.

A. WindowListener
B. MouseListener

C. AdjustmentListener

D. TextListener

Answer optiond

Marks: 1

2948 The following abstract methods of KeyListener needs to be overidden, in order to give response to KeyEvent.

A. KeyPressed()

B. KeyReleased()

C. KeyTyped()

D. All

Answer optiond

Marks: 1

2949 ______________________ is the superclass of all awt events.

A. WindowEvent

B. KeyEvent

C. AwtEvent

D. TextEvent

Answer optionc

Marks: 1

2950 Identify the Valid method of DriverManager-

A. registerDriver()

B. deregisterDriver()

C. getConnection()

D. openConnection()

Answer optionc

Marks: 1

2951 Object of PreparedStatement can be retrieved by using following method of Connection interface.

A. createStatement()

B. prepareStatement()

C. prepareCall()

D. None

Answer optionb

Marks: 1

2952 Java Servlets often serve the same purpose and significantly better than ______________________

A. Common Gateway Interface(CGI)

B. Graphical User Interface(GUI)

C. Application Program Inteface(API)

D. None

Answer optiona

Marks: 1

2953 The following interface is not listed in javax.servlet package.


A. Servlet

B. ServletContext

C. HttpSession

D. ServletResponse

Answer optionc

Marks: 1

2954 Which components are used in the following output-

A. JFrame, JLabel, JRadioButton, JButton

B. JApplet, JLabel, JTextField, JButton

C. JFrame, JLabel, JCheckbox, JButton

D. JDialog, JLabel,JRadioButton,JButtonGroup

Answer optiona

Marks: 2

2955 Commonly used constructors of JTable are -

A. JTable()

B. JTable(Object[][] rowData, Object[] columnNames)

C. JTable(Vector rowData, Vector columnNames)

D. All

Answer optiond

Marks: 2

2956 Which of the following method is used to draw an empty outligned box?

A. drawRect()

B. drawOval()

C. drawString()

D. fillRect()

Answer optiona

Marks: 2

2957 The Components used in the output are -

A. JFrame, JPanel, JTree, Jbutton

B. JFrame, JPanel, JTree, JTabbedPane

C. JFrame, JPanel, JTree, Jlabel

D. JFrame, JPanel, JTree, Jmenu

Answer optionb

Marks: 2

2958 The following method is not a part of MouseMotionListener interface.

A. public void mouseClicked(MouseEvent obj)

B. public void mouseDragged(MouseEvent obj)

C. public void mouseMoved(MouseEvent obj)

D. None

Answer optiona

Marks: 2
Select the correct sequence to be filled in the following blank space.

import java.awt.*;
import java.awt.event.*;
class DemoFrame extends Frame implements ___________
{
public DemoFrame()
{
this.add__________(this);
this.setBounds(100,100,600,400);
this.setVisible(true);
}
2959 public void windowOpened(WindowEvent obj) { }
public void windowClosed(WindowEvent obj) { }
public void windowClosing(WindowEvent obj)
{
this.setVisible(false);
System.exit(0);
}
public void windowIconified(WindowEvent obj) { }
public void windowDeiconified(WindowEvent obj) { }
public void windowActivated(WindowEvent obj) { }
public void windowDeactivated(WindowEvent obj) { }
}

A. WindowListener, WindowEvent

B. WindowAdapter, WindowListener

C. WindowAdapter, WindowEvent

D. WindowListener, WindowListener

Answer optiond

Marks: 2

Choose the incorrect statement.


2960 The object of ActionEvent is generated whenever-

A. Button is clicked

B. List Item is double clicked

C. Text in the TextField is changed.

D. MenuItem is selected

Answer optionc

Marks: 2

2961 Select the true statement about Socket and ServerSocket-

A. They are used to established connection oriented communication

B. They provides reliable communication

C. They can send large amount of data

D. All

Answer optiond

Marks: 2

2962 Identify the invalid constructor for Sender's datagram packet

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

B. DatagramPacket(byte [ ] data, int size, InetAddress ip, int port)

C. DatagramPacket(byte [ ] data, int size,string offset)

D. None of the above

Answer optionc

Marks: 2
Find the missing statements in the following program-

import java.io.*;
_____________________________

public class URLConnectionReader {


public static void main(String[] args) throws Exception {
2963 URL url = new URL("http://www.google.com/");
URLConnection con = _____________________________
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}

A. import java.net.*; , url.getConnection();

B. import java.sql.*; , url.getConnection();

C. import java.net.*; , url.openConnection();

D. import java.sql.*; , url.openConnection();

Answer optionc

Marks: 2

For successful communication between Client and Server, select the correct statement for blank space shown below

import java.io.*;
import java.net.*;
public class ServerDemo {
public static void main(String[] args) throws Exception {
ServerSocket serverSocket = new ServerSocket(2000);
Socket clientSocket = serverSocket.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
System.out.println(in.readLine());
}
2964 }

public class ClientDemo {


public static void main(String[] args) throws Exception {
_________________________________________________

PrintWriter out = new PrintWriter(clientSocket.getOutputStream());


out.println("this is hello message from client.");
out.close();
}
}

A. Socket clientSocket = new Socket("Server");

B. Socket clientSocket = new Socket("Server", 2000);

C. Socket clientSocket = new Socket("Server", 3000);

D. Socket clientSocket = new Socket();

Answer optionb

Marks: 2

2965 Object of Connection interface can be retrieved using following method of DriverManager -

A. getConnection(String connectionstring)

B. getConnection(void)

C. openConnection()

D. None

Answer optiona

Marks: 2

Fill in the blank.

import java.sql.*;
import sun.jdbc.odbc.*;
public class DatabaseDemo {
public static void main(String[] args) throws Exception {
2966 Driver d = new JdbcOdbcDriver();
DriverManager.registerDriver(d);
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
____________ = con.getMetaData();
con.close();
}
}

A. ResultSetMetaData metadata

B. DatabaseMetaData metadata
C. Statement stmt;

D. PreparedStatement stmt;

Answer optionb

Marks: 2

2967 Which of the following statement is true about Servlet?

A. It runs on web server

B. It dynamically creates a web page

C. It is platform independent

D. All

Answer optiond

Marks: 2

2968 The following is not a valid state and session management technique in java

A. URL Rewriting

B. Hidden Form Field

C. Session Binding

D. HttpSession

Answer optionc

Marks: 2

2969 Choose the correct source code to display the following output

import java.awt.*;
class DemoFrame extends Frame
{
MenuBar mbar;
Menu file, edit;
MenuItem cut, copy, paste;
public DemoFrame()
{
mbar = new MenuBar();
file=new Menu("File");
edit=new Menu("Edit");
cut=new MenuItem("Cut");
copy=new MenuItem("Copy");
paste=new MenuItem("Paste");
A. file.add(cut);
file.add(copy);
file.add(paste);
mbar.add(file);
mbar.add(edit);
this.setMenuBar(mbar);
}
public static void main(String args[])
{
DemoFrame f = new DemoFrame();
f.setBounds(50,50,600,400);
f.setVisible(true);
}
}

import java.awt.*;
class DemoFrame extends Frame
{
MenuBar mbar;
Menu file, edit, exit;
MenuItem cut, copy, paste;
public DemoFrame()
{
mbar = new MenuBar();
file=new Menu("File");
edit=new Menu("Edit");
exit=new Menu("Exit");
cut=new MenuItem("Cut");
copy=new MenuItem("Copy");
paste=new MenuItem("Paste");
B. edit.add(cut);
edit.add(copy);
edit.add(paste);
mbar.add(file);
mbar.add(edit);
mbar.add(exit);
this.setMenuBar(mbar);
}
public static void main(String args[])
{
DemoFrame f = new DemoFrame();
f.setBounds(50,50,600,400);
f.setVisible(true);
}
}
import java.awt.*;
class DemoFrame extends Frame
{
MenuBar mbar;
Menu file, edit, exit;
MenuItem cut, copy, paste;
public DemoFrame()
{
mbar = new MenuBar();
file=new Menu("File");
edit=new Menu("Edit");
exit=new Menu("Exit");
cut=new MenuItem("Cut");
copy=new MenuItem("Copy");
paste=new MenuItem("Paste");
C. file.add(cut);
file.add(copy);
file.add(paste);
mbar.add(file);
mbar.add(edit);
mbar.add(exit);
this.setMenuBar(mbar);
}
public static void main(String args[])
{
DemoFrame f = new DemoFrame();
f.setBounds(50,50,600,400);
f.setVisible(true);
}
}

import java.awt.*;
class DemoFrame extends Frame
{
MenuBar mbar;
Menu file, edit;
MenuItem cut, copy, paste;
public DemoFrame()
{
mbar = new MenuBar();
file=new Menu("File");
edit=new Menu("Edit");
cut=new MenuItem("Cut");
copy=new MenuItem("Copy");
paste=new MenuItem("Paste");
D. edit.add(cut);
edit.add(copy);
edit.add(paste);
mbar.add(file);
mbar.add(edit);
this.setMenuBar(mbar);
}
public static void main(String args[])
{
DemoFrame f = new DemoFrame();
f.setBounds(50,50,600,400);
f.setVisible(true);
}
}

Answer optionb

Marks: 2

2970 Select the source code to display following output.

import java.awt.*;
import javax.swing.*;
class DemoFrame extends JFrame
{
JTable table;
JScrollPane jsp;
public DemoFrame()
{
Container contain=this.getContentPane();
String rowdata[][]={{"1001","L&T INFOTECH"},{"1002","INFOSYS"},{"1003","TCS"}};
A. String columnnames[]={ };
table=new JTable(rowdata,columnnames);
jsp = new JScrollPane(table);
contain.add(jsp);
}
public static void main(String args[])
{
DemoFrame d = new DemoFrame();
d.setVisible(true);
}
}

import java.awt.*;
import javax.swing.*;
class DemoFrame extends JFrame
{
JTable table;
JScrollPane jsp;
public DemoFrame()
{
Container contain=this.getContentPane();
String rowdata[][]={{"1001","L&T INFOTECH"},{"1002","INFOSYS"},{"1003","TCS"}};
B. String columnnames[]={"Code","Company"};
table=new JTable(columnnames,rowdata);
jsp = new JScrollPane(table);
contain.add(jsp);
}
public static void main(String args[])
{
DemoFrame d = new DemoFrame();
d.setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
class DemoFrame extends JFrame
{
JTable table;
JScrollPane jsp;
public DemoFrame()
{
Container contain=this.getContentPane();
String rowdata[][]={{"1001","L&T INFOTECH"},{"1002","INFOSYS"},{"1003","TCS"}};
C. String columnnames[]={"Code","Company"};
table=new JTable(rowdata,columnnames);
jsp = new JScrollPane(table);
contain.add(jsp);
}
public static void main(String args[])
{
DemoFrame d = new DemoFrame();
d.setVisible(true);
}
}

import java.awt.*;
import javax.swing.*;
class DemoFrame extends JFrame
{
JTable table;
JScrollPane jsp;
public DemoFrame()
{
Container contain=this.getContentPane();
String rowdata[][]={{"1001","L&T INFOTECH"},{"1002","INFOSYS"},{"1003","WIPRO"}};
D. String columnnames[]={"Code","Company"};
table=new JTable(columnnames,rowdata);
jsp = new JScrollPane(table);
contain.add(jsp);
}
public static void main(String args[])
{
DemoFrame d = new DemoFrame();
d.setVisible(true);
}
}

Answer optionc

Marks: 2

2971 Select the source code to display following output.

import java.awt.*;
import javax.swing.*;
class DemoFrame extends JFrame
{
JButton b1,b2,b3;
public DemoFrame()
{
Container contain=this.getContentPane();
contain.setLayout(new FlowLayout());
b1=new JButton("Morning");
b2=new JButton("Afternoon");
A. b3=new JButton("Evening");
b2.setToolTipText("Good Morning");
contain.add(b1);
contain.add(b2);
contain.add(b3);
}
public static void main(String args[])
{
DemoFrame d = new DemoFrame();
d.setVisible(true);
}
}

import java.awt.*;
import javax.swing.*;
class DemoFrame extends JFrame
{
JButton b1,b2,b3;
public DemoFrame()
{
Container contain=this.getContentPane();
contain.setLayout(new FlowLayout());
b1=new JButton("Morning");
b2=new JButton("Afternoon");
b3=new JButton("Evening");
B.
contain.add(b1);
contain.add(b2);
contain.add(b3);
}
public static void main(String args[])
{
DemoFrame d = new DemoFrame();
d.setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
class DemoFrame extends JFrame
{
JButton b1,b2,b3;
public DemoFrame()
{
Container contain=this.getContentPane();
contain.setLayout(new FlowLayout());
b1=new JButton("Morning");
b2=new JButton("Afternoon");
b3=new JButton("Night");
C. b1.setToolTipText("Good Morning");
b2.setToolTipText("Good Afternoon");
b3.setToolTipText("Good Night");
contain.add(b1);
contain.add(b2);
contain.add(b3);
}
public static void main(String args[])
{
DemoFrame d = new DemoFrame();
d.setVisible(true);
}
}

import java.awt.*;
import javax.swing.*;
class DemoFrame extends JFrame
{
JButton b1,b2,b3;
public DemoFrame()
{
Container contain=this.getContentPane();
contain.setLayout(new FlowLayout());
b1=new JButton("Morning");
b2=new JButton("Afternoon");
b3=new JButton("Evening");
D. b1.setToolTipText("Good Morning");
b2.setToolTipText("Good Afternoon");
b3.setToolTipText("Good Evening");
contain.add(b1);
contain.add(b2);
contain.add(b3);
}
public static void main(String args[])
{
DemoFrame d = new DemoFrame();
d.setVisible(true);
}
}

Answer optiond

Marks: 2

2972 Identify the valid constructor for Jtree

A. JTree()

B. JTree(TreeNode root)

C. JTree(Object[] nodes)

D. All

Answer optiond

Marks: 2

2973 Choose the proper source code to display following output

import java.awt.*;
import java.awt.event.*;
class DemoFrame extends Frame
{
Checkbox c1,c2;
Label msg;
public DemoFrame()
{
this.setLayout(new FlowLayout());
msg= new Label("Welcome To AWT");
this.add(msg);
CheckboxGroup group=new CheckboxGroup();
c1=new Checkbox("India",false,group);
c2=new Checkbox("America",false,group);
c1.addItemListener(this);
A. c2.addItemListener(this);
this.add(c1);
this.add(c2);
}
public void itemStateChanged(ItemEvent obj)
{
Checkbox box=(Checkbox)obj.getItemSelectable();
msg.setText("Welcome " + box.getLabel());
}
public static void main(String args[])
{
DemoFrame f = new DemoFrame();
f.setVisible(true);
}
}
import java.awt.*;
import java.awt.event.*;
class DemoFrame extends Frame implements ItemListener
{
Checkbox c1,c2;
Label msg;
public DemoFrame()
{
this.setLayout(new FlowLayout());
msg= new Label("Welcome To AWT");
this.add(msg);
CheckboxGroup group=new CheckboxGroup();
c1=new Checkbox("India",false,group);
c2=new Checkbox("America",false,group);
B. this.add(c1);
this.add(c2);
}
public void itemStateChanged(ItemEvent obj)
{
Checkbox box=(Checkbox)obj.getItemSelectable();
msg.setText("Welcome " + box.getLabel());
}
public static void main(String args[])
{
DemoFrame f = new DemoFrame();
f.setVisible(true);
}
}

import java.awt.*;
import java.awt.event.*;
class DemoFrame extends Frame implements ItemListener
{
Checkbox c1,c2;
Label msg;
public DemoFrame()
{
this.setLayout(new FlowLayout());
msg= new Label("Welcome To AWT");
this.add(msg);
CheckboxGroup group=new CheckboxGroup();
c1=new Checkbox("India",false,group);
c2=new Checkbox("America",false,group);
c1.addItemListener(this);
C. c2.addItemListener(this);
this.add(c1);
this.add(c2);
}
public void itemStateChanged(ItemEvent obj)
{
Checkbox box=(Checkbox)obj.getItemSelectable();
msg.setText("Welcome " + box.getLabel());
}
public static void main(String args[])
{
DemoFrame f = new DemoFrame();
f.setVisible(true);
}
}

import java.awt.*;
import java.awt.event.*;
class DemoFrame extends Frame implements ItemListener
{
Checkbox c1,c2;
Label msg;
public DemoFrame()
{
this.setLayout(new FlowLayout());
msg= new Label("Welcome To AWT");
this.add(msg);
CheckboxGroup group=new CheckboxGroup();
c1=new Checkbox("India",false,group);
c2=new Checkbox("America",false,group);
c1.addItemListener(this);
D. c2.addItemListener(this);
this.add(c1);
this.add(c2);
}
public void actionPerformed(ItemEvent obj)
{
Checkbox box=(Checkbox)obj.getItemSelectable();
msg.setText("Welcome " + box.getLabel());
}
public static void main(String args[])
{
DemoFrame f = new DemoFrame();
f.setVisible(true);
}
}

Answer optionc

Marks: 2

2974 To handle all the events related to ScrollBar, the following method of AdjustmentListener needs to be overriden.

A. public void adjustmentValueChanged(AdjustmentEvent obj)

B. public void adjustmentChanged(AdjustmentEvent obj)

C. public void actionPerformedActionEvent obj)

D. None of the above

Answer optiona
Marks: 2

2975 The ComponentAdapter class overrides the following methods of ComponentListener interface.

public void componentInserted(ComponentEvent obj)


public void componentShown(ComponentEvent obj)
A. public void componentChanged(ComponentEvent obj)
public void componentRemoved(ComponentEvent obj)

public void componentMoved(ComponentEvent obj)


public void componentShown(ComponentEvent obj)
B. public void componentResized(ComponentEvent obj)
public void componentHidden(ComponentEvent obj)

public void componentMoved(ComponentEvent obj)


public void componentShown(ComponentEvent obj)
C. public void componentChanged(ComponentEvent obj)
public void componentRemoved(ComponentEvent obj)

public void componentAdded(ComponentEvent obj)


public void componentShown(ComponentEvent obj)
D. public void componentResized(ComponentEvent obj)
public void componentRemoved(ComponentEvent obj)

Answer optionb

Marks: 2

2976 The method addActionListener(ActionListener obj) can be invoked on the following set of Components

A. Button, List, MenuItem

B. Button, List, Label

C. Button, MenuItem, Checkbox

D. Button, List, Choice

Answer optiona

Marks: 2

2977 Select the source code to display following output.

import java.net.*;
class NetworkDemo
{
public static void main(String args[])
{
InetAddress ip[] = InetAddress.getAllByName("www.yahoo.com");
A. for(int i=0;i<ip.length;i++)
{
System.out.println(ip[i].getHostAddress());
}
}
}

import java.net.*;
class NetworkDemo
{
public static void main(String args[]) throws UnknownHostException
{
InetAddress ip[] = InetAddress.getAllByName("www.yahoo.com");
B. for(int i=0;i<ip.length;i++)
{
System.out.println(ip[i].getHostAddress());
}
}
}

import java.net.*;
class NetworkDemo
{
public static void main(String args[]) throws UnknownHostException
{
InetAddress ip[] = InetAddress.getByName("www.yahoo.com");
C. for(int i=0;i<ip.length;i++)
{
System.out.println(ip[i].getHostAddress());
}
}
}

import java.net.*;
class NetworkDemo
{
public static void main(String args[]) throws UnknownHostException
D. {
InetAddress ip = InetAddress.getByName("www.yahoo.com");
System.out.println(ip[i].getHostAddress());
}
}

Answer optionb

Marks: 2
2978 The following constructor of ServerSocket class is invalid.

A. ServerSocket(int port)

B. ServerSocket(int port, int maxqueue)

C. ServerSocket(int port, int maxque, InetAddress localaddress)

D. ServerSocket()

Answer optiond

Marks: 2

2979 Select the program code which can display first and last record from the employee table.

import java.sql.*;
import sun.jdbc.odbc.*;
class DatabaseDemo
{
public static void main(String args[]) throws SQLException
{
Driver d = new JdbcOdbcDriver();
DriverManager.registerDriver(d);
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
PreparedStatement pstmt=con.prepareStatement("select name, salary from employee");
ResultSet rs =pstmt.executeQuery();
A. if(rs.first())
{
System.out.println(rs.getString(1) + "\t" + rs.getDouble(2));
}
if(rs.last())
{
System.out.println(rs.getString(1) + "\t" + rs.getDouble(2));
}
con.close();
}
}

import java.sql.*;
import sun.jdbc.odbc.*;
class DatabaseDemo
{
public static void main(String args[]) throws SQLException
{
Driver d = new JdbcOdbcDriver();
DriverManager.registerDriver(d);
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
PreparedStatement pstmt=con.prepareStatement("select name, salary from employee",ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs =pstmt.executeQuery();
B. if(rs.first())
{
System.out.println(rs.getString(1) + "\t" + rs.getDouble(2));
}
if(rs.last())
{
System.out.println(rs.getString(1) + "\t" + rs.getDouble(2));
}
con.close();
}
}

import java.sql.*;
import sun.jdbc.odbc.*;
class DatabaseDemo
{
public static void main(String args[]) throws SQLException
{
Driver d = new JdbcOdbcDriver();
DriverManager.registerDriver(d);
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
PreparedStatement pstmt=con.prepareStatement("select name, salary from employee",ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
ResultSet rs =pstmt.executeQuery();
C. if(rs.first())
{
System.out.println(rs.getString(1) + "\t" + rs.getDouble(2));
}
if(rs.last())
{
System.out.println(rs.getString(1) + "\t" + rs.getDouble(2));
}
con.close();
}
}
import java.sql.*;
import sun.jdbc.odbc.*;
class DatabaseDemo
{
public static void main(String args[]) throws SQLException
{
Driver d = new JdbcOdbcDriver();
DriverManager.registerDriver(d);
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
PreparedStatement pstmt=con.prepareStatement("select name, marks from student",ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
D. if(rs.first())
{
System.out.println(rs.getString(1) + "\t" + rs.getDouble(2));
}
if(rs.last())
{
System.out.println(rs.getString(1) + "\t" + rs.getDouble(2));
}
con.close();
}
}

Answer optionb

Marks: 2

The object of following interface is most suitable for executing stored procedure and can be retrieved by invoking prepareCall()
2980 method of Connection interface

A. Statement

B. CallableStatement

C. PreparedStatement

D. All

Answer optionb

Marks: 2

import javax.servlet.*;
import javax.servlet.http.*;
public class ServletDemo
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
2981 pw.println("<HTML><BODY><FORM METHOD=POST ACTION=ServletDemo.class>");
pw.println("<br>Name :<input type=text name=txtname>");
pw.println("<br><input type=submit name=btnsubmit>");
pw.flush();
}
}

Select the missing statement in the above program-

extends GenericServlet
A. throws ServletException, IOException
pw.println("</FORM></BODY></HTML>");

extends HttpServlet
B. throws ServletException, IOException
pw.println("</FORM></BODY></HTML>");

implements HttpServlet
C. throws ServletException, IOException
pw.println("</FORM></BODY></HTML>");

extends HttpServlet
D. pw.println("</FORM></BODY></HTML>");

Answer optionb

Marks: 2

2982 Choose the proper source code to display following output

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletDemo extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
A. PrintWriter pw = response.getWriter();
pw.println("<HTML><BODY><FORM METHOD=POST ACTION=ServletDemo.class>");
pw.println("<br>Name :<input type=text name=txtname>");
pw.println("<br>Password :<input type=password name=txtpassword>");
pw.println("<br><input type=submit name=btnsubmit >" );
pw.println("</FORM></BODY></HTML>");
pw.flush();
}
}
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletDemo extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
B. pw.println("<HTML><BODY><FORM METHOD=POST ACTION=ServletDemo.class>");
pw.println("<br>Name :<input type=text name=txtname>");
pw.println("<br>Password :<input type=password name=txtpassword>");
pw.println("<br><input type=submit name=btnsubmit>");
pw.println("</FORM></BODY></HTML>");
pw.flush();
}
}

import javax.servlet.*;
import javax.servlet.http.*;
public class ServletDemo extends HttpServlet
{
public void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
C. pw.println("<HTML><BODY><FORM METHOD=POST ACTION=ServletDemo.class>");
pw.println("<br>Name :<input type=text name=txtname>");
pw.println("<br>Password :<input type=text name=txtpassword>");
pw.println("<br><input type=submit name=btnsubmit>");
pw.println("</FORM></BODY></HTML>");
pw.flush();
}
}

import javax.servlet.*;
import javax.servlet.http.*;
public class ServletDemo extends GenericServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
D. pw.println("<HTML><BODY><FORM METHOD=POST ACTION=ServletDemo.class>");
pw.println("<br>Name :<input type=text name=txtname>");
pw.println("<br>Password :<input type=password name=txtpassword>");
pw.println("<br><input type=submit name=btnsubmit>");
pw.println("</FORM></BODY></HTML>");
pw.flush();
}
}

Answer optiona

Marks: 2

2983 Identify true statement from the following

A. GenericServlet is protocol independent while HttpServlet is protocol dependant

B. GenericServlet lifecycle consists of methods like doGet() and doPost()

C. HttpSession is new feature of GenericServlet

D. GenericServlet is highly used to handle web requests of web server

Answer optiona

Marks: 2

Choose proper statements for the blank space provided in the following source code

import javax.servlet.*;
import javax.servlet.http.*;
public class ServletDemo extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
Cookie c = new Cookie("MyCookie","Hello");
2984 _________________________________
response.setContentType("text/html");
PrintWriter pw = _________________________
pw.println("<HTML><BODY><FORM METHOD=POST ACTION=ServletDemo.class>");
pw.println("<br>Cookie added...");
pw.println("</FORM></BODY></HTML>");
pw.flush();
}
}

response.setCookie(c);
A. response.printWriter();

response.addCookie(c);
B. response.printWriter();

response.setCookie(c);
C. response.getWriter();

response.addCookie(c);
D. response.getWriter();

Answer optiond
Marks: 2

2985 Choose the proper syntax of sendRedirect() method

A. public void sendRedirect(void) throws IOException

B. public void sendRedirect(String url) throws IOException

C. public void sendRedirect(URL url) throws IOException

D. None of the above

Answer optionb

Marks: 2

2986 Which class is present at top of AWT hierachy?

A. Container

B. Component

C. Panel

D. Window

Answer optionb

Marks: 1

2987 Which of the following method is not present in TextField?

A. setEchoChar()

B. append()

C. getText()

D. echoCharisSet()

Answer optionb

Marks: 1

2988 Which layout manager is used to represent component similar to word flow in text editor?

A. FlowLayout

B. GridLayout

C. CardLayout

D. BorderLayout

Answer optiona

Marks: 1

2989 In MVC architecture, MVC stands for?

A. Model Visiblity Control

B. Module Visiblity Contol

C. Menu View Component

D. Model View Controller

Answer optiond

Marks: 1

2990 JProgressBar class is present in which package?

A. java.awt

B. javax.swing

C. java.awt.progressbar

D. javax.swing.progressbar
Answer optionb

Marks: 1

2991 Which of the following awt control is not active?

A. Button

B. Label

C. Checkbox

D. Scrollbar

Answer optionb

Marks: 1

2992 getPathForLocation() is present in which of the following class?

A. JButton

B. JComboBox

C. JTable

D. JTree

Answer optiond

Marks: 1

2993 Which of the following statement is false?

A. TextComponent is superclass of TextField and TextArea

B. Swing provides Platform independent component

C. Panel do not have titlebar and border

D. JApplet class is present in java.applet package

Answer optiond

Marks: 1

2994 ___________________ generated when component is removed from container?

A. ComponentEvent

B. ContainerEvent

C. ActionEvent

D. ItemEvent

Answer optionb

Marks: 1

2995 __________method is invoked when a character has been entered.

A. keyTyped()

B. keyPressed()

C. keyReleased()

D. none of the above

Answer optiona

Marks: 1

2996 Which of the following method is not present in WindowListener inteface?

A. windowMinimized()

B. windowActivated()

C. windowDeactivated()
D. windowIconified()

Answer optiona

Marks: 1

2997 ServerSocket(int port) will create serversocket on the specified port with queue length of _________________.

A. 1

B. 10

C. 50

D. 100

Answer optionc

Marks: 1

2998 Which of the following statement invokes stored procedure in sql?

A. PreparedStatement

B. Connection Statement

C. CallableStatement

D. All of the mentioned

Answer optionc

Marks: 1

2999 What is JDBC?

A. java compiler

B. java API

C. java interpreter

D. java compiler and java API

Answer optionb

Marks: 1

3000 Type 1 driver is known as__________________?

A. JDBC-Native API

B. JDBC-ODBC Bridge Driver

C. JDBC-net pure java

D. None of these

Answer optionb

Marks: 1

3001 Type 2 is also known as_______________________?

A. JDBC-Native API

B. JDBC-ODBC Bridge Driver

C. JDBC-ODBC Bridge Driver

D. None of these

Answer optiona

Marks: 1

3002 Choose the correct syntax of jsp directives.

A. <%@ directive_name %>

B. <% directive_name %>


C. <%@ directive_name @%>

D. None of these

Answer optiona

Marks: 1

3003 JSTL stands for______?

A. Java Servlet Tagged Library

B. Java Sun Tag Library

C. Java Servlet Tag Library

D. JavaServer Pages Standard Tag Library

Answer optiond

Marks: 1

3004 Which of the following method are main methods in life cycle of servlet? 1.init() 2.service() 3.destroy() 4.stop() 5.wait()

A. All (1),(2),(3),(4) and (5)

B. Only (1),(2) and (3)

C. Only (3),(4) and (5)

D. Only (1),(4) and (5)

Answer optionb

Marks: 1

To run following program which minimum packages are required to run the program?
/*
<applet code="MyProg1.java" width=500 height=500>
</applet>
*/

public class MyProg1 extends JApplet


{
Label lbl;
Button b;
Container cp;
3005 public void init()
{
setLayout(new FlowLayout());
cp=getContentPane();
lbl=new Label("First Label");
b=new Button("My Buttton");
cp.add(lbl);
cp.add(b);
}

import java.awt.*;
A. import javax.swing.*;
import java.applet.*;

import java.awt.*;
B. import java.swing.*;
import java.applet.*;

C. import java.awt.*;
import java.applet.*;

import javax.swing.*;
D. import java.applet.*;

Answer optiona

Marks: 2

3006 In following figure to laid out the components which layout manager will be used?

A. FlowLayout

B. GridLayout

C. BorderLayout

D. CardLayout

Answer optionb

Marks: 2
3007 Which of the following is not constructor of Checkbox?

A. Checkbox(String str, int val)

B. Checkbox(String str,boolean on)

C. Checkbox(String str,boolean on,ChecboxGroup cbGroup)

D. Checkbox(String str,ChecboxGroup cbGroup,boolean on)

Answer optiona

Marks: 2

What is error in the following program?


import java.awt.event.*;
import java.awt.*;
class WindowDemo extends Frame implements WindowListener
{

WindowDemo()
{
setVisible(true);
setSize(500,500);
addWindowListener(this);
}

public void windowClosing(WindowEvent we)


{
dispose();
}
public void windowClosed(WindowEvent we)
{

}
public void windowActivated(WindowEvent we)
{
3008
}
public void windowDeActivated(WindowEvent we)
{

}
public void windowDeiconified(WindowEvent we)
{

}
public void windowIconified(WindowEvent we)
{

}
public void windowOpened(WindowEvent we)
{

}
public static void main(String a[])
{
new WindowDemo();
}
}

WindowDemo.java:3: error: WindowDemo is not abstract and does not override abstract method windowDeIconified(WindowEvent) in WindowListener
class WindowDemo extends Frame implements WindowListener
A. ^
1 error

WindowDemo.java:3: error: WindowDemo is not abstract and does not override abstract method windowMinimized(WindowEvent) in WindowListener
class WindowDemo extends Frame implements WindowListener
B. ^
1 error

WindowDemo.java:3: error: WindowDemo is not abstract and does not override abstract method windowMaximized(WindowEvent) in WindowListener
class WindowDemo extends Frame implements WindowListener
C. ^
1 error

WindowDemo.java:3: error: WindowDemo is not abstract and does not override abstract method windowDeactivated(WindowEvent) in WindowListener
class WindowDemo extends Frame implements WindowListener
D. ^
1 error

Answer optiond

Marks: 2

Which of the following statement is false?


1)AdapterClass provides easy implementation of methods of EventListener interface
3009 2)EventSource is a object used to create and generate event.
3)KeyEvent is superclass of InputEvent
4)ComponentEvent is superclass of WindowEvent

A. 1

B. 2

C. 3

D. 4
Answer optionc

Marks: 2

3010 Which of the following constant is not present in WindowEvent class?

A. WINDOW_GAINED_FOCUS

B. WINDOW_MINIMIZED

C. WINDOW_ICONIFIED

D. WINDOW_OPENED

Answer optionb

Marks: 2

What is output of following program?


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

try
{
URL urldemo=new URL("http://www.msbte.com/index.html");
System.out.println("Protocol:"+urldemo.getProtocol());
3011 System.out.println("Host:"+urldemo.getHost());
System.out.println("Port:"+urldemo.getPort());
System.out.println("File:"+urldemo.getFile());
}
catch(Exception e)
{
System.out.println(e.getMessage());
}

A. Cant produce output because of compile time error

B. Cant produce output because of run time error

Protocol:http
Host:www.msbte.com
C. Port:0
File:/index.html

Protocol:http
Host:www.msbte.com
D. Port:-1
File:/index.html

Answer optiond

Marks: 2

Which minimum packages are required to run complile the given program successfully?
class URLConDemo
{
public static void main(String args[])
{
int ch;
try
{
URL urldemo=new URL("http://www.google.com");
URLConnection urlcon=urldemo.openConnection();
System.out.println("Content Length:"+urlcon.getContentLength());
System.out.println("Content Type:"+urlcon.getContentType());
long d=urlcon.getDate();
Date date=new Date(d);
3012 System.out.println("Date:"+date);
InputStream is=urlcon.getInputStream();
while((ch=is.read())!=-1)
{
System.out.print((char)ch);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}

import java.util.*;
A. import java.net.*;

B. import java.net.*;

import java.net.*;
C. import java.util.*;
import java.io.*;
import java.net.*;
D. import java.io.*;

Answer optionc

Marks: 2

Which of the following statement is false?


1)Socket class throws UnknownHostException or IOException
3013 2)URL class throws MalformedURLException
3)InetAddress class throws IOException
4)accept() method used as blocking call which will keep wating for client communication

A. 1

B. 2

C. 3

D. 4

Answer optionc

Marks: 2

What is output of following program for given table "Student"


ID Name City
---------------------------
1 Mahesh Pune
2 Akshay Solapur
3 Deepak USA
import java.sql.*;
class ConDemo
{

public static void main(String a[])


{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:samarth");
3014 PreparedStatement ps=con.prepareStatement("select * from Student");
ResultSet rs=ps.executeQuery();
rs.next();
rs.next();
System.out.println("Id="+rs.getInt(1));
System.out.println("Name="+rs.getString(2));
System.out.println("City="+rs.getString(3));
rs.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}

1 Mahesh Pune
A. 2 Akshay Solapur
3 Deepak USA

B. 2 Akshay Solapur

C. 3 Deepak USA

D. Error in the given the program

Answer optionb

Marks: 2

3015 The doGet() method extracts value of the parameters type and number by using____________

A. request.getParameter()

B. request.setParameter()

C. response.getParameter()

D. response.getAttribute()

Answer optiona

Marks: 2

Which of the following are the interfaces?


1.ServletContext
3016 2.Servlet
3.GenericServlet
4.HttpServlet

A. All (1),(2),(3) and (4)


B. Only (1) and (2)

C. Only (1),(3) and (4)

D. Only (1) and (4)

Answer optionb

Marks: 2

3017 Java servelet are efficient and powerful solution for creating ________________________ for the web pages

A. dynamic content

B. static content

C. hardware

D. both (a) and (b)

Answer optionb

Marks: 2

Which run time error will occur in following program?


import java.awt.*;
import java.applet.*;
/*
<applet code="Demo" width=500 height=500>
</applet>
*/
public class Demo extends Applet
{
Button b[];
3018 public void init()
{
setLayout(new FlowLayout());

for(int i=0;i<5;i++)
{
add(b[i]=new Button(" "+i));
}
}
}

A. ArrayIndexOutOfBoundsException:

B. NullPointerException

C. IOException

D. No run time error

Answer optionb

Marks: 2

3019 To get the given output which program is correct?

/*
<applet code="ScrollbarAction.class" width=400 height=300>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ScrollbarAction extends Applet implements AdjustmentListener


{
Scrollbar vert,horz;
public void init()
{
setLayout(new FlowLayout());
vert = new Scrollbar(Scrollbar.VERTICAL,0,2,0,500);
horz = new Scrollbar(Scrollbar.HORIZONTAL,0,2,0,500);
A. add(vert);
add(horz);
vert.addAdjustmentListener(this);
}

public void adjustmentValueChanged(AdjustmentEvent ae)


{
repaint();
}

public void paint(Graphics g)


{
g.drawString("Vertical Value = "+vert.getValue());
g.drawString("Horizontal Value = "+horz.getValue());
}
}
/*
<applet code="ScrollbarAction.class" width=400 height=300>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ScrollbarAction extends Applet implements AdjustmentListener


{
Scrollbar vert,horz;
public void init()
{
setLayout(new FlowLayout());
vert = new Scrollbar(Scrollbar.VERTICAL,0,2,0,500);
horz = new Scrollbar(Scrollbar.HORIZONTAL,0,2,0,500);
B. add(vert);
add(horz);
vert.addAdjustmentListener(this);
horz.addAdjustmentListener(this);
}

public void adjustmentValueChanged(AdjustmentEvent ae)


{
repaint();
}

public void paint(Graphics g)


{
g.drawString("Vertical Value = "+getValue(),10,100);
g.drawString("Horizontal Value = "+getValue(),10,120);
}
}

/*
<applet code="ScrollbarAction.class" width=400 height=300>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ScrollbarAction extends Applet implements AdjustmentListener


{
Scrollbar vert,horz;
public void init()
{
setLayout(new FlowLayout());
vert = new Scrollbar(Scrollbar.VERTICAL,0,2,0,500);
horz = new Scrollbar(Scrollbar.HORIZONTAL,0,2,0,500);
C. add(vert);
add(horz);
vert.addAdjustmentListener(this);
horz.addAdjustmentListener(this);
}

public void adjustmentValueChanged(AdjustmentEvent ae)


{
repaint();
}

public void paint(Graphics g)


{
g.drawString("Vertical Value = "+vert.getValue(),10,100);
g.drawString("Horizontal Value = "+horz.getValue(),10,120);
}
}

/*
<applet code="ScrollbarAction.class" width=400 height=300>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ScrollbarAction extends Applet implements AdjustmentListener


{
Scrollbar vert,horz;
public void init()
{
setLayout(new FlowLayout());
vert = new Scrollbar(Scrollbar.VERTICAL,0,2,500);
horz = new Scrollbar(Scrollbar.HORIZONTAL,0,2,500);
D. add(vert);
add(horz);
addAdjustmentListener(this);

public void adjustmentValueChanged(AdjustmentEvent ae)


{
repaint();
}

public void paint(Graphics g)


{
g.drawString("Vertical Value = "+vert.getValue(),10,100);
g.drawString("Horizontal Value = "+horz.getValue(),10,120);
}
}

Answer optionc

Marks: 2

3020 To get the given output which program is correct?


import javax.swing.*;
import java.awt.*;

class JProgressBarDemo extends JFrame


{
JProgressBar jpb;

JProgressBarDemo()
{
setSize(300,300);
setLayout(new FlowLayout());
setTitle("ProgressBar Example");
jpb= new JProgressBar(0,1000);
jpb.setValue(0);
jpb.setStringPainted(true);
add(jpb);
}

public void iterator()


{
A. for(int i=0;i<=1000;i=i+20)
{
try
{
Thread.sleep(100);
}
catch(Exception e)
{
System.out.println(e);
}
jpb.setValue(i);
}
}

public static void main(String args[])


{
JProgressBarDemo pbd= new JProgressBarDemo();
pbd.setVisible(true);
pbd.iterator();
}
}

import javax.swing.*;
import java.awt.*;

class JProgressBarDemo extends JFrame


{
JProgressBar jpb;

JProgressBarDemo()
{
setSize(300,300);
setLayout(new FlowLayout());
setTitle("ProgressBar Example");
jpb= new JProgressBar(0,1000);
jpb.setValue(0);
jpb.setStringPainted(true);
add(jpb);
}
B.
public void iterator()
{
for(int i=0;i<=1000;i=i+20)
{
sleep(100);
jpb.setValue(i);
}
}

public static void main(String args[])


{
JProgressBarDemo pbd= new JProgressBarDemo();
pbd.setVisible(true);
pbd.iterator();
}
}
import javax.swing.*;
import java.awt.*;

class JProgressBarDemo extends JFrame


{
JProgressBar jpb;

JProgressBarDemo()
{
setSize(300,300);
setLayout(new FlowLayout());
setTitle("ProgressBar Example");
jpb= new JProgressBar(0,1000);
jpb.setValue(0);
jpb.setStringPainted(true);
add(jpb);
}

public void iterator()


{
C. for(int i=0;i<=1000;i=i+20)
{
try
{
Thread.sleep(100);
}
catch(Exception e)
{
System.out.println(e);
}
jpb.setValue(i);
}
}

public static void main(String args[])


{
JProgressBarDemo pbd= new JProgressBarDemo();
pbd.setVisible(true);
iterator();
}
}

import javax.swing.*;
import java.awt.*;

class JProgressBarDemo extends JFrame


{
JProgressBar jpb;

JProgressBarDemo()
{
setSize(300,300);
setLayout(new FlowLayout());
setTitle("ProgressBar Example");
jpb= new JProgressBar(0,1000);
jpb.setValue(0);
add(jpb);
}

public void iterator()


{
for(int i=0;i<=1000;i=i+20)
D. {
try
{
Thread.sleep(100);
}
catch(Exception e)
{
System.out.println(e);
}
jpb.setValue(i);
}
}

public static void main(String args[])


{
JProgressBarDemo pbd= new JProgressBarDemo();
pbd.setVisible(true);
pbd.iterator();
}
}

Answer optiona

Marks: 2

3021 Which of the following programm is correct for getting given output when user interacted with scrollbar?
/*
<applet code="ScrollbarColoursDemo.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ScrollbarColoursDemo extends Applet implements AdjustmentListener


{
Scrollbar red,green,blue;
public void init()
{
red = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255);
green = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255);
blue = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255);
add(red);
add(green);
add(blue);
A. red.addAdjustmentListener(this);
green.addAdjustmentListener(this);
blue.addAdjustmentListener(this);
}

public void adjustmentValueChanged(AdjustmentEvent ae)


{
repaint();
}

public void paint(Graphics g)


{
setBackground(new Color(red.getValue(),green.getValue(),blue.getValue()));
g.setColor(Color.WHITE);
g.drawString("Red Green Blue",210,70);
g.drawString("Red Value = "+red.getValue(),10,100);
g.drawString("Green Value = "+green.getValue(),10,120);
g.drawString("Blue Value = "+blue.getValue(),10,140);
}
}

/*
<applet code="ScrollbarColoursDemo.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ScrollbarColoursDemo extends Applet


{
Scrollbar red,green,blue;
public void init()
{
red = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255);
green = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255);
blue = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255);
add(red);
add(green);
add(blue);
B. red.addAdjustmentListener(this);
green.addAdjustmentListener(this);
blue.addAdjustmentListener(this);
}

public void adjustmentValueChanged(AdjustmentEvent ae)


{
repaint();
}

public void paint(Graphics g)


{
setBackground(new Color(red.getValue(),green.getValue(),blue.getValue()));
g.setColor(Color.WHITE);
g.drawString("Red Green Blue",210,70);
g.drawString("Red Value = "+red.getValue());
g.drawString("Green Value = "+green.getValue());
g.drawString("Blue Value = "+blue.getValue());
}
}
/*
<applet code="ScrollbarColoursDemo.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ScrollbarColoursDemo extends Applet implements AdjustmentListener


{
Scrollbar red,green,blue;
public void init()
{
red = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255);
green = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255);
blue = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255);
add(red);
add(green);
add(blue);
C. addAdjustmentListener(this);

public void adjustmentValueChanged()


{
repaint();
}

public void paint(Graphics g)


{
setBackground(new Color(red.getValue(),green.getValue(),blue.getValue()));
g.setColor(Color.WHITE);
g.drawString("Red Green Blue",210,70);
g.drawString("Red Value = "+red.getValue(),10,100);
g.drawString("Green Value = "+green.getValue(),10,120);
g.drawString("Blue Value = "+blue.getValue(),10,140);
}
}

/*
<applet code="ScrollbarColoursDemo.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ScrollbarColoursDemo extends Applet implements AdjustmentListener


{
Scrollbar red,green,blue;
public void init()
{
red = new Scrollbar(Scrollbar.VERTICAL,0,,255);
green = new Scrollbar(Scrollbar.VERTICAL,0,255);
blue = new Scrollbar(Scrollbar.VERTICAL,0,255);
add(red);
add(green);
add(blue);
D. red.addAdjustmentListener(this);
green.addAdjustmentListener(this);
blue.addAdjustmentListener(this);
}

public void adjustmentValueChanged()


{
repaint();
}

public void paint(Graphics g)


{
setBackground(new Color(red.getValue(),green.getValue(),blue.getValue()));
g.setColor(Color.WHITE);
g.drawString("Red Green Blue",210,70);
g.drawString("Red Value = "+red.getValue(),10,100);
g.drawString("Green Value = "+green.getValue(),10,120);
g.drawString("Blue Value = "+blue.getValue(),10,140);
}
}

Answer optiona

Marks: 2
Which statement should be included in given program at dotted(......) line so that it will create a window and that will be closed
after closing it?
import java.awt.*;
import java.awt.event.*;
class InnerClassesDemo extends Frame
{
InnerClassesDemo()
{
setVisible(true);
setSize(500,500);
setLocation(300,300);
setTitle("Self Closing Frame Using Adapter Class");
setResizable(false);
.......................................................................................................
3022 }

public static void main(String args[])


{
InnerClassesDemo fd = new InnerClassesDemo();
}

class MyAdapter extends WindowAdapter


{
public void windowClosing(WindowEvent we)
{
dispose();
}
}
}

A. addWindowListener(new MyAdapter(this));

B. addWindowListener(this);

C. addWindowListener(MyAdapter ma=new MyAdapter(this));

D. addWindowListener(new MyAdapter());

Answer optiond

Marks: 2

3023 Which the following program is correct for getting given output?

/*
<applet code="MultiListAction.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class MultiListAction extends Applet implements ItemListener


{
List l;
String items;
public void init()
{
items="";
l = new List(6);
l.add("India");
l.add("Pakistan");
l.add("Austrilia");
l.add("China");
l.add("UK");
A.
l.add("USA");
add(l);
l.addItemListener(this);
}
public void paint(Graphics g)
{
items = " ";
String msg[] = l.getSelectedItems();
for(int i = 0; i<msg.length; i++)
{
items = items + msg[i] + ",";
}
g.drawString("Current Selection ="+items,50,150);
}
public void itemStateChanged(ItemEvent ie)
{
repaint();
}

}
/*
<applet code="MultiListAction.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class MultiListAction extends Applet implements ItemListener


{
List l;
String items;
public void init()
{
items="";
l = new List(6,true);
l.add("India");
l.add("Pakistan");
l.add("Austrilia");
l.add("China");
B. l.add("UK");
l.add("USA");
add(l);
l.addItemListener(this);
}
public void paint(Graphics g)
{
items = " ";
String msg[] = l.getSelectedItems();
for(int i = 0; i<msg.length; i++)
{
items = items + msg[i] + ",";
}
g.drawString("Current Selection ="+items,50,150);
}
public void itemStateChanged(ItemEvent ie)
{
repaint();
}

/*
<applet code="MultiListAction.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class MultiListAction extends Applet implements ItemListener


{
List l;
String items;
public void init()
{
items="";
l = new List(6);
l.add("India");
l.add("Pakistan");
l.add("Austrilia");
l.add("China");
C. l.add("UK");
l.add("USA");
add(l);
addItemListener(this);
}
public void paint(Graphics g)
{
items = " ";
String msg[] = l.getSelectedItems();
for(int i = 0; i<msg.length; i++)
{
items = items + msg[i] + ",";
}
g.drawString("Current Selection ="+items,50,150);
}
public void itemStateChanged(ItemEvent ie)
{
repaint();
}

}
/*
<applet code="MultiListAction.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class MultiListAction extends Applet implements ItemListener


{
List l;
String items;
public void init()
{
items="";
l = new List(6,false);
l.add("India");
l.add("Pakistan");
l.add("Austrilia");
l.add("China");
D. l.add("UK");
l.add("USA");
add(l);
addItemListener(this);
}
public void paint(Graphics g)
{
items = " ";
String msg[] = l.getSelectedItems();
for(int i = 0; i<msg.length; i++)
{
items = items + msg[i] + ",";
}
g.drawString("Current Selection ="+items,50,150);
}
public void itemStateChanged(ItemEvent ie)
{
repaint();
}

Answer optionb

Marks: 2

3024 Which the following program is correct for getting given output?

/*
<applet code="CheckboxGroupAction.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class CheckboxGroupAction extends Applet implements ItemListener


{
Checkbox c1,c2,c3;
CheckboxGroup cbGroup;

public void init()


{
cbGroup = new CheckboxGroup();
c1 = new Checkbox("CRICKET",cbGroup);
c2 = new Checkbox("HOCKEY",cbGroup);
c3 = new Checkbox("FOOTBALL",true,cbGroup);
add(c1);
A. add(c2);
add(c3);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
}

public void paint(Graphics g)


{
g.drawString("CURRENT SELECTION = ",10,100);
Checkbox c = cbGroup.getSelectedCheckbox();
String msg = c.getLabel();

public void itemStateChanged(ItemEvent ie)


{
repaint();
}
}
/*
<applet code="CheckboxGroupAction.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

class CheckboxGroupAction extends Applet implements ItemListener


{
Checkbox c1,c2,c3;
CheckboxGroup cbGroup;

public void init()


{
cbGroup = new CheckboxGroup();
c1 = new Checkbox("CRICKET",true,cbGroup);
c2 = new Checkbox("HOCKEY",false,cbGroup);
c3 = new Checkbox("FOOTBALL",false,cbGroup);
B. add(c1);
add(c2);
add(c3);
addItemListener(this);
}

public void paint(Graphics g)


{
g.drawString("CURRENT SELECTION = ",100);
Checkbox c = cbGroup.getSelectedCheckbox();
String msg = c.getLabel();
g.drawString(msg,153,100);
}

public void itemStateChanged(ItemEvent ie)


{
repaint();
}
}

/*
<applet code="CheckboxGroupAction.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class CheckboxGroupAction extends Applet implements ItemListener


{
Checkbox c1,c2,c3;
CheckboxGroup cbGroup;

public void init()


{
cbGroup = new CheckboxGroup();
c1 = new Checkbox("CRICKET",false,cbGroup);
c2 = new Checkbox("HOCKEY",false,cbGroup);
c3 = new Checkbox("FOOTBALL",true,cbGroup);
C. add(c1);
add(c2);
add(c3);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
}

public void paint(Graphics g)


{
g.drawString("CURRENT SELECTION = ",10,100);
Checkbox c = cbGroup.getSelectedCheckbox();
String msg = c.getLabel();
}

public void itemStateChanged(ItemEvent ie)


{
repaint();
}
}
/*
<applet code="CheckboxGroupAction.class" width=500 height=500>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class CheckboxGroupAction extends Applet implements ItemListener


{
Checkbox c1,c2,c3;
CheckboxGroup cbGroup;

public void init()


{
cbGroup = new CheckboxGroup();
c1 = new Checkbox("CRICKET",true,cbGroup);
c2 = new Checkbox("HOCKEY",false,cbGroup);
c3 = new Checkbox("FOOTBALL",true,cbGroup);
add(c1);
D. add(c2);
add(c3);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
}

public void paint(Graphics g)


{
g.drawString("CURRENT SELECTION = ",10,100);
Checkbox c = cbGroup.getSelectedCheckbox();
String msg = c.getLabel();
g.drawString(msg,153,100);
}

public void itemStateChanged(ItemEvent ie)


{
repaint();
}
}

Answer optiond

Marks: 2

3025 Which of the following programm is correct for displaying all content of table "Student"?

import java.sql.*;
class ConDemo1
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:samarth");
PreparedStatement ps=con.prepareStatement("select * from Student");
ResultSet rs=ps.executeQuery();
while(rs.next());
{
A. System.out.println("Id="+rs.getInt(1));
System.out.println("Name="+rs.getString(2));
System.out.println("City="+rs.getString(3));
}
rs.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

import java.sql.*;
class ConDemo1
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:samarth");
PreparedStatement ps=con.prepareStatement("select * from Student");
ResultSet rs=ps.executeQuery();
while(rs.next())
{
B. System.out.println("Id="+rs.getInt(1));
System.out.println("Name="+rs.getString(2));
System.out.println("City="+rs.getString(3));
}
rs.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
import java.sql.*;
class ConDemo1
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:samarth");
PreparedStatement ps=con.prepareStatement(select * from Student);
ResultSet rs=ps.executeUpdate();
while(rs.next())
{
C. System.out.println("Id="+rs.getInt(1));
System.out.println("Name="+rs.getString(2));
System.out.println("City="+rs.getString(3));
}
rs.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

import java.sql.*;
class ConDemo1
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:samarth");
PreparedStatement ps=con.prepareStatement("select * from Student");
ResultSet rs=ps.executeUpdate();
while(rs.next())
{
D. System.out.println("Id="+getInt(1));
System.out.println("Name="+getString(2));
System.out.println("City="+getString(3));
}
rs.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

Answer optionb

Marks: 2

3026 Following diagram shows which type of the JDBC driver?

A. JDBC-Net pure java

B. JDBC-ODBC Bridge Driver

C. JDBC-Native API

D. 100% pure java

Answer optiona

Marks: 2

Which of the following program used to delete single row from table student having ID=15 in following table using prepareStatement
3027 method?

import java.sql.*;
class ConDemo5
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:samarth");
PreparedStatement ps=con.prepareStatement();
A. ps.executeUpdate("delete from student where ID=15");
ps.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
import java.sql.*;
class ConDemo5
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:samarth");
PreparedStatement ps=con.prepareStatement();
B. ps.executeUpdate("delete from student where ID=?");
close();
close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

import java.sql.*;
class ConDemo5
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:samarth");
PreparedStatement ps=con.prepareStatement("delete from student where ID=?");
ps.setInt(1,15);
C. ps.executeQuery();
ps.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

import java.sql.*;
class ConDemo5
{
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:samarth");
PreparedStatement ps=con.prepareStatement("delete from student where ID=?");
D. ps.setInt(1,15);
ps.executeUpdate();
ps.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

Answer optiond

Marks: 2

3028 Which of the following program is correct for displaying "Hello World" in JSP?

<html>
<head>
<title>HELLO MESSAGE TO USER</title>
</head>
<body>
<H2>
A. <%
System.println("Hello World");
%>
</H2>
</body>
</html>

<html>
<head>
<title>HELLO MESSAGE TO USER</title>
</head>
<body>
<H2>
B. <%
out.println("Hello World");
%>
</H2>
</body>
</html>
<html>
<head>
<title>HELLO MESSAGE TO USER</title>
</head>
<body>
<H2>
C. <%
System.out.println("Hello World");
%>
</H2>
</body>
</html>

<html>
<head>
<title>HELLO MESSAGE TO USER</title>
</head>
<body>
<H2>
D. <%
out.write("Hello World");
%>
</H2>
</body>
</html>

Answer optionb

Marks: 2

3029 Which of the following program is correct for displaying session id using servlets?

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionDemo extends HttpServlet
{

protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException


{
A. response.setContentType("text/html");
PrintWriter pw=request.getWriter();
String id=session.getId();
pw.println("Session ID="+id);
pw.close();

}
}

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionDemo extends HttpServlet
{

protected void doGet(ServletRequest request,ServletResponse response) throws ServletException,IOException


{
B. response.setContentType("text/html");
PrintWriter pw=response.getWriter();
HttpSession session=request.getSessionId();
String id=session.getId();
pw.println("Session ID="+id);
pw.close();

}
}

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionDemo extends HttpServlet
{

protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException


{
C. response.setContentType("text/html");
PrintWriter pw=response.getWriter();
HttpSession session=request.getSession();
String id=session.getId();
pw.println("Session ID="+id);
pw.close();

}
}

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionDemo extends HttpServlet
{

protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException


{
D. response.setContentType("text/html");
PrintWriter pw=response.getWriter();
HttpSession session=response.getSession();
String id=getId();
pw.println("Session ID="+id);
pw.close();

}
}

Answer optionc

Marks: 2
3030 Which of the following program is correct for displaying "Hello World" in servlet?

import java.io.*;
import javax.servlet.*;
public class ServletDemo extends GenericServlet
{
public void service(ServletRequest request,ServletResponse response) throws ServletException, IOException
{

response.setContentType("text/html");
A. PrintWriter pw=response.getWriter();
pw.println("Hello World");
pw.close();

import java.io.*;
import javax.servlet.*;
public class ServletDemo extends Servlet
{
public void service(ServletRequest request,ServletResponse response) throws ServletException, IOException
{

response.setContentType("text/html");
B. PrintWriter pw=response.getWriter();
pw.println("Hello World");
pw.close();

import java.io.*;
import javax.servlet.*;
public class ServletDemo extends GenericServlet
{
public void service(ServletRequest request,ServletResponse response) throws ServletException, IOException
{

request.setContentType("text/html");
C. PrintWriter pw=req.getWriter();
pw.println("Hello World");
pw.close();

import java.io.*;
import javax.servlet.*;
public class ServletDemo extends Servlet
{
public void service(ServletRequest request,ServletResponse response) throws ServletException, IOException
{

request.setContentType("text/html");
D. PrintWriter pw=response.getWriter();
pw.println("Hello World");
pw.close();

Answer optiona

Marks: 2

3031 To store the cookie object which method is used and of which class/interface?

A. add() method of HttpServletResponse

B. add() method of HttpServletRequest

C. addCookie() method of HttpServletResponse

D. addCookie() method of HttpServletRequest

Answer optionc

Marks: 2

3032 Which method is used to retrieve the Cookie object and of which class/interface?

A. get() method of HttpServletResponse

B. get() methods of HttpServletRequest

C. getCookies() methods of HtttServletResponse

D. getCookies() method of HttpServletRequest

Answer optiond
Marks: 2

3033 Which are various AWT controls from following?

A. Labels, Push buttons, Check boxes, Choice lists

B. Text components, Threads, Strings, Servelts, Vectors

C. Labels, Strings, JSP, Netbeans, Sockets

D. Push buttons, Servelts, Notepad, JSP

Answer optiona

Marks: 1

3034 By which method You can set the text in a Label?

A. setText()

B. b)getText()

C. setLabel()

D. both a and b

Answer optiona

Marks: 1

The Following steps are required to perform


3035 1) Implement the Listener interface and overrides its methods
2) Register the component with the Listener

A. Exception Handling

B. String Handling

C. Event Handling

D. None of the above

Answer optionc

Marks: 1

3036 The URLConnection class can be used to read and write data to the specified resource referred by the URL

A. TRUE

B. FALSE

C.

D.

Answer optiona

Marks: 1

3037 Which classes are used for connection-less socket programming?

A. DatagramSocket

B. DatagramPacket

C. Both A & B

D. None of the above

Answer optionc

Marks: 1

3038 JavaServer Pages often serve the same purpose as programs implemented using the Common Gateway Interface (CGI)?

A. true

B. false

C.

D.
Answer optiona

Marks: 1

3039 Who is responsible for creating request & response object for a web server?

A. Web server

B. Servlet

C. Container

D. Client

Answer optionb

Marks: 1

3040 The CheckboxGroup class is a subclass of the Component class.

A. True

B. False

C.

D.

Answer optionb

Marks: 2

3041 Which Component method is used to access a component's immediate Container?

A. getVisible()

B. getImmediate

C. getParent()

D. getContainer

Answer optionc

Marks: 2

3042 Which of these interfaces define a method actionPerformed()?

A. ComponenetListener

B. ContainerListener

C. ActionListener

D. InputListener

Answer optionc

Marks: 2

3043 How many bits are in a single IPv4 address?

A. 8

B. 16

C. 32

D. 64

Answer optionc

Marks: 2

Following methods belongs to which class?


public String getProtocol()
3044 public String getHost()
public String getPort()
public String getFile()

A. URL class

B. InetAddress class
C. DatagramPacket class

D. None of above

Answer optiona

Marks: 2

3045 A network node can have multiple ______ but each with unique _______.

A. NIC,MAC

B. MAC,NIC

C. All of the above

D. None of above

Answer optiona

Marks: 2

What's the difference between servlets and applets?


1.Servlets executes on Servers, where as Applets executes on Browser
3046 2.Servlets have no GUI, where as an Applet has GUI
3.Servlets creates static web pages, where as Applets creates dynamic web pages
4.Servlets can handle only a single request, where as Applet can handle multiple requests

A. 1,2,3 are correct

B. 1,2 are correct

C. 1,3 are correct

D. 1,2,3,4 are correct

Answer optionb

Marks: 2

What is difference between Get and Post method?


1)In case of Get request, only limited amount of data can be sent because data is sent in header. In case of post request, large
3047 amount of data can be sent because data is sent in body.
2) Get request is not secured because data is exposed in URL bar. Post request is secured because data is not exposed in URL bar.
3)Get request is more efficient and used more than Post Post request is less efficient and used less than get.

A. All of above

B. only 1 is correct

C. 1,3 are correct

D. 1,2 are correct

Answer optiona

Marks: 2

Consider the following program. What is use of setBounds() method?


import java.awt.*;
class First extends Frame{
First(){
Button b=new Button("click me");
b.setBounds(30,100,80,30);

3048 add(b);
setSize(300,300);
setLayout(null);
setVisible(true);
}
public static void main(String args[]){
First f=new First();
}}

A. setting button position

B. adding button into frame

C. to set visibility of frame

D. All of above

Answer optiona

Marks: 2

3049 Consider the following output. Write the code for it.
import javax.swing.*;
public class Radio {
JFrame f;

Radio(){
f=new JFrame();

JRadioButton r1=new JRadioButton("A) Male");


JRadioButton r2=new JRadioButton("B) FeMale");
r1.setBounds(50,100,70,30);
r2.setBounds(50,150,70,30);

ButtonGroup bg=new ButtonGroup();


A.
bg.add(r1);bg.add(r2);

f.add(r1);f.add(r2);

f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new Radio();
}
}

import javax.swing.*;
public class Radio {
JFrame f;

Radio(){
f=new JFrame();

JRadioButton r1=new JRadioButton("A) Male");


JRadioButton r2=new JRadioButton("B) FeMale");
r1.setBounds(50,100,70,30);
r2.setBounds(50,150,70,30);

B. ButtonGroup bg=new ButtonGroup();


bg.add(r1);bg.add(r2);

f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new Radio();
}
}

import javax.swing.*;
public class Radio {
JFrame f;

Radio(){
f=new JFrame();

JRadioButton r1=new JRadioButton("A) Male");


JRadioButton r2=new JRadioButton("B) FeMale");
r1.setBounds(50,100,70,30);
r2.setBounds(50,150,70,30);

C.
bg.add(r1);bg.add(r2);

f.add(r1);f.add(r2);

f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new Radio();
}
}

import javax.swing.*;
public class Radio {

Radio(){
f=new JFrame();

JRadioButton r1=new JRadioButton("A) Male");


JRadioButton r2=new JRadioButton("B) FeMale");
r1.setBounds(50,100,70,30);
r2.setBounds(50,150,70,30);

D. ButtonGroup bg=new ButtonGroup();


bg.add(r1);bg.add(r2);

f.add(r1);f.add(r2);

f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new Radio();
}
}

Answer optiona

Marks: 2

3050 Which is correct code for following output.


import java.awt.*;
import javax.swing.*;

public class Border {


JFrame f;
Border(){

JButton b1=new JButton("NORTH");;


JButton b2=new JButton("SOUTH");;
JButton b3=new JButton("EAST");;
JButton b4=new JButton("WEST");;
JButton b5=new JButton("CENTER");;
A.
f.add(b1,BorderLayout.NORTH);
f.add(b2,BorderLayout.SOUTH);
f.add(b4,BorderLayout.WEST);
f.add(b5,BorderLayout.CENTER);

f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new Border();
}
}

import java.awt.*;
import javax.swing.*;

public class Border {


JFrame f;
Border(){
f=new JFrame();

JButton b1=new JButton("NORTH");;


JButton b2=new JButton("SOUTH");;
JButton b3=new JButton("EAST");;
JButton b4=new JButton("WEST");;
JButton b5=new JButton("CENTER");;
B.

f.add(b2,BorderLayout.SOUTH);
f.add(b3,BorderLayout.EAST);
f.add(b5,BorderLayout.CENTER);

f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new Border();
}
}

import java.awt.*;
import javax.swing.*;

public class Border {


JFrame f;
Border(){
f=new JFrame();

JButton b1=new JButton("NORTH");;


JButton b2=new JButton("SOUTH");;
JButton b3=new JButton("EAST");;
JButton b4=new JButton("WEST");;
JButton b5=new JButton("CENTER");;
C. setLayout(new BorderLayout());
f.add(b1,BorderLayout.NORTH);
f.add(b2,BorderLayout.SOUTH);
f.add(b3,BorderLayout.EAST);
f.add(b4,BorderLayout.WEST);
f.add(b5,BorderLayout.CENTER);

f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new Border();
}
}

import java.awt.*;
import javax.swing.*;

public class Border {


JFrame f;
Border(){
f=new JFrame();

JButton b1=new JButton("NORTH");;


JButton b2=new JButton("SOUTH");;
JButton b3=new JButton("EAST");;
JButton b4=new JButton("WEST");;
JButton b5=new JButton("CENTER");;
D.
f.add(b1,BorderLayout.NORTH);
f.add(b2,BorderLayout.SOUTH);
f.add(b3,BorderLayout.EAST);
f.add(b4,BorderLayout.WEST);
f.add(b5,BorderLayout.CENTER);

f.setSize(300,300);
f.setVisible(true);
}
public static void main(String[] args) {
new Border();
}
}

Answer optionc
Marks: 2

3051 Which of these are constants defined in WindowEvent class?

A. WINDOW_ACTIVATED

B. WINDOW_CLOSED

C. WINDOW_DEICONIFIED

D. All of the mentioned

Answer optiond

Marks: 2

3052 Write the code for given output.

import java.awt.*;
import java.awt.event.*;

class AEvent extends Frame implements ActionListener{


TextField tf;
AEvent(){

tf=new TextField();
tf.setBounds(60,50,170,20);

Button b=new Button("click me");


b.setBounds(100,120,80,30);

b.addActionListener(this);

add(b);add(tf);
A.
setSize(300,300);
setLayout(null);
setVisible(true);

public void actionPerformed(ActionEvent e){


tf.setText("Welcome");
}

public static void main(String args[]){


new AEvent();
}
}
public void setBounds

import java.awt.*;
import java.awt.event.*;

class AEvent extends Frame implements ActionListener{


TextField tf;
AEvent(){

tf=new TextField();
tf.setBounds(60,50,170,20);

Button b=new Button("click me");


b.setBounds(100,120,80,30);

b.addActionListener(this);

B.
setSize(300,300);
setLayout(null);
setVisible(true);

public void actionPerformed(ActionEvent e){


tf.setText("Welcome");
}

public static void main(String args[]){


new AEvent();
}
}
public void setBounds
import java.awt.*;
import java.awt.event.*;

class AEvent extends Frame implements ActionListener{


TextField tf;
AEvent(){

tf=new TextField();
tf.setBounds(60,50,170,20);

b.setBounds(100,120,80,30);

b.addActionListener(this);

add(b);add(tf);
C.
setSize(300,300);
setLayout(null);
setVisible(true);

public void actionPerformed(ActionEvent e){


tf.setText("Welcome");
}

public static void main(String args[]){


new AEvent();
}
}
public void setBounds

import java.awt.*;
import java.awt.event.*;

class AEvent extends Frame implements ActionListener{


TextField tf;
AEvent(){

tf.setBounds(60,50,170,20);

Button b=new Button("click me");


b.setBounds(100,120,80,30);

b.addActionListener(this);

add(b);add(tf);
D.
setSize(300,300);
setLayout(null);
setVisible(true);

public void actionPerformed(ActionEvent e){


tf.setText("Welcome");
}

public static void main(String args[]){


new AEvent();
}
}
public void setBounds

Answer optiona

Marks: 2

3053 WindowListener interface belongs to which class?

A. WindowEvent

B. ComponentEvent

C. ContainerEvent

D. ItemEvent

Answer optiona

Marks: 2

3054 The example of connection-oriented protocol is __________

A. TCP

B. UDP

C. HTTP

D. FTP

Answer optiona

Marks: 2

3055 Which interface is responsible for transaction management in JDBC?


A. Connection interface

B. ResultSetMetaData interface

C. DatabaseMetaData interface

D. ResultSet interface

Answer optiona

Marks: 2

Following is example of which jdbc query?


ResultSet rs=stmt.executeQuery("select * from emp");
3056 while(rs.next()){
System.out.println(rs.getInt(1)+" "+rs.getString(2));
}

A. executeQuery() method

B. createStatement() method

C. close() method

D. createStatement() method

Answer optiona

Marks: 2

Write the output of following program?


import java.sql.*;

public class FuncSum {


public static void main(String[] args) throws Exception{

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
3057 CallableStatement stmt=con.prepareCall("{?= call sum4(?,?)}");
stmt.setInt(2,10);
stmt.setInt(3,43);
stmt.registerOutParameter(1,Types.INTEGER);
stmt.execute();

System.out.println(stmt.getInt(1));

}
}

A. 43

B. 10

C. 53

D. None of above

Answer optionc

Marks: 2

3058 Advantage of Servlet

A. better performance

B. Portability

C. Robust and secure

D. All of the above

Answer optiond

Marks: 1

3059 What is difference between include directive and include action?

A. 1) In the include directive includes the content at page translation time. In the include action includes the content at request time.

B. 2) In the include directive includes the original content of the page so page size increases at runtime. In the include action doesn't include the original

C. The include directive is better for static pages. The include action is better for dynamic pages.

D. All of above
Answer optiond

Marks: 2

Write the missing statement.


import java.io.*;
import javax.servlet.*;

public class First extends GenericServlet{


--------------------------------------------------------------------------
throws IOException,ServletException{

3060 res.setContentType("text/html");

PrintWriter out=res.getWriter();
out.print("<html><body>");
out.print("<b>hello generic servlet</b>");
out.print("</body></html>");

}
}

A. public void service(ServletRequest req)

B. public void service(ServletRequest req,ServletResponse res)

C. public void (ServletRequest req,ServletResponse res)

D. public void service(ServletResponse res)

Answer optionb

Marks: 2

3061 public void setMaxAge(int expiry)

A. Sets the maximum age of the cookie in minutes.

B. Sets the maximum age of the cookie in seconds.

C. Sets the maximum age of the cookie in hours.

D. None of above

Answer optionb

Marks: 2

3062 Which constructor is used to create a new label that presents the specified string of text with the specified alignment.

A. Label(int alignment, String text )

B. Label(String text ,int alignment)

C. Label(int alignment )

D. Label(String text)

Answer optionb

Marks: 1

3063 We can disable the echoing of the characters as they are typed in a TextField by calling following method

A. setEnabled()

B. setVisible()

C. disableEchoChar()

D. setEchoChar()

Answer optiond

Marks: 1

3064 Frame and DialogBox use ___________________ as their default layout

A. FlowLayout

B. BorderLayout

C. GridLayout

D. GridBagLayout
Answer optionb

Marks: 1

3065 ____________method can be used to disable or enable a menu item.

A. isEnabled()

B. setVisible()

C. setEnabled()

D. enabled()

Answer optionc

Marks: 1

3066 Swing has following features

A. Platform Independent

B. Pluggable look and feel

C. Lightweight components

D. All of these

Answer optiond

Marks: 1

3067 The setToolTipText() method is used ____________________

A. To set up a tool tip for any JComponent

B. To set up a label for any Jcomponent

C. To set up a tool button for any JComponent

D. To set up a tool bar

Answer optiona

Marks: 1

3068 Following constant is not defined in MouseEvent class

A. MOUSE_EXITED

B. MOUSE_RELEASED

C. MOUSE_MOVED

D. All of these

Answer optiond

Marks: 1

3069 AdjustmentEvent class has following constructor.

A. AdjustmentEvent (Adjustable src, int type , int id, int data)

B. AdjustmentEvent (Adjustable src, int id, int data)

C. AdjustmentEvent (Adjustable src, int type, int data)

D. AdjustmentEvent (Adjustable src, int id, int type, int data)

Answer optiond

Marks: 1

3070 ____________ method is called when a window is being closed.

A. windowClosed(WindowEvent we)

B. windowClosing(WindowEvent we)

C. windowDeactivated(WindowEvent we)
D. windowDeiconified(WindowEvent we)

Answer optionb

Marks: 1

3071 The getInputStream() method doesnt return all the data of the specified URL in the stream that can be read and displayed.

A. TRUE

B. FALSE

C.

D.

Answer optionb

Marks: 1

3072 If factory methods of InetAdress class are unable to resolve the host name ,they throw an________________

A. SocketException

B. MalformedURLException

C. UnknownHostException

D. IOException

Answer optionc

Marks: 1

3073 ___________ is used to create a socket which waits for clients to connect to them on published port.

A. ServerSocket (InetAddress addr, int port )

B. Socket (int port )

C. Socket (String hostname, int port )

D. ServerSocket (int port )

Answer optiond

Marks: 1

3074 Native-API driver converts JDBC calls into _________

A. ODBC calls

B. vendor specific database network protocol

C. user calls

D. native calls of the database API

Answer optiond

Marks: 1

3075 The executeQuery( String sql) method is used to execute _________ query & it returns _________

A. CREATE , integer

B. INSERT ,single row

C. SELECT , ResultSet object

D. DELETE , ResultSet object

Answer optionc

Marks: 1

3076 The ResultSet object maintains a cursor pointing to a particular row of data. Initially, cursor points to ___________

A. before the first row

B. next row from the current position


C. after the first row

D. previous row from the current position

Answer optiona

Marks: 1

3077 _________ object allows servlet to get initialization parameters.

A. ServletContext

B. Servlet

C. ServletRequest

D. ServletConfig

Answer optiond

Marks: 1

3078 Which of the following information is stored by cookie on user's machine.

A. Name and Value

B. Domain and Path

C. Expiration date and Maximum age

D. All of these

Answer optiond

Marks: 1

3079 Which request method is used to send the query string(name/value pairs ) in the URL

A. get()

B. post()

C. delete()

D. put()

Answer optiona

Marks: 1

3080 Which of the following is the JSP directive tag

A. <% @page…%>

B. <% page…%>

C. <% @page…@%>

D. None of these

Answer optiona

Marks: 1

3081 select code which creates mutually exclusive checkboxes.

ButtonGroup cbg=new ButtonGroup();


A. Checkbox c1=new Checkbox("A",cbg,false);
Checkbox c2=new Checkbox("B",cbg,true);

CheckboxGroup cbg=new CheckboxGroup();


Checkbox c1=new Checkbox("A",false);
B. Checkbox c2=new Checkbox("B",true);
cbg.add(c1);
cbg.add(c2);

ButtonGroup cbg=new ButtonGroup();


Checkbox c1=new Checkbox("A",false);
C. Checkbox c2=new Checkbox("B",true);
cbg.add(c1);
cbg.add(c2);

CheckboxGroup cbg=new CheckboxGroup();


D. Checkbox c1=new Checkbox("A",cbg,false);
Checkbox c2=new Checkbox("B",cbg,true);
Answer optiond

Marks: 2

3082 Which is true about JToggleButton?

A. It is a two-state button.

B. It can set a rollover icon.

C. It can display an icon and a text.

D. All of these

Answer optiond

Marks: 2

3083 What components will be needed to get following output?

A. JTree , JApplet , JScrollbar

B. JTree , JTextField , JScrollPane

C. JTextArea, JTree, JApplet

D. JTextArea, JScrollbar , JTree

Answer optionb

Marks: 2

Select the missing statement in given code

import java.awt.*;
import java.awt.event.*;

class SampleFrame extends Frame


{ SampleFrame(String title)
{ super(title);
MyWindowAdapter adapter=new MyWindowAdapter (this);
addWindowListener(adapter);
}
public void paint(Graphics g)
{ g.drawString(�This is Frame window�,10,40);
}
}

3084 class MyAdapter extends WindowAdapter


{ SampleFrame f;
MyAdapter(SampleFrame f)
{ this.f = f;
}
public void windowClosing(WindowEvent we)
{ f.setVisible(false);
}
}

class MyFrame
{ public static void main(String args[])
{ Frame f ;
f.setSize(300,400);
f.setVisible(true);
}
}

A. new Frame();

B. new SampleFrame();

C. new Frame(“A Frame Window”);

D. new SampleFrame(“A Frame Window”);

Answer optiond

Marks: 2

3085 Which of these constants is not defined in ComponentEvent class?

A. COMPONENT_HIDDEN

B. COMPONENT_MOVED

C. COMPONENT_RESIZED

D. COMPONENT_VISIBLE

Answer optiond

Marks: 2
To get the following output complete the code given below.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="CheckboxDemo" width=200 height=200>
</applet>*/
public class CheckboxDemo extends Applet implements ItemListener
{ String msg="";
Checkbox win98, winNT, solaris ,mac;
public void init()
{ win98= new Checkbox("Windows 98",true);
winNT= new Checkbox("Windows NT");
solaris= new Checkbox("Solaris");
mac= new Checkbox("MacOS");

add(win98);
add(winNT);
add(solaris);
add(mac);
3086 win98.addItemListener(this);
winNT.addItemListener(this);
solaris.addItemListener(this);
mac.addItemListener(this);
}

public void paint(Graphics g)


{ msg="Current State :";
g.drawString(msg,6,80);
msg="Windows 98 :"+ win98.getState();
g.drawString(msg,6,100);
msg="Windows NT :"+ winNT.getState();
g.drawString(msg,6,120);
msg="Solaris :"+ solaris.getState();
g.drawString(msg,6,140);
msg="MACOS :"+ mac.getState();
g.drawString(msg,6,160);

}
}

Container contentPane = getContentPane();


A. contentPane.setLayout(new GridLayout());

Paneljp = new Panel();


B. p.setLayout(new GridLayout(20, 20));

}
C. public void itemStateChanged(ItemEvent ie)
{ repaint();

public void itemChanged(ItemEvent ie)


D. { repaint(); }

Answer optionc

Marks: 2

3087 __________ constructor of DatagramPacket is used to send the packets.

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

B. DatagramPacket (byte data[], int offset, int size)

C. DatagramPacket (byte data[], int size, InetAddress addr, int port)

D. DatagramPacket (byte data[] )

Answer optionc

Marks: 2

3088 In ServerSocket, _________method is used as blocking call which will keep waiting for client communication.

A. wait()

B. receive()

C. accept()

D. send()

Answer optionc

Marks: 2

3089 Select the proper method to retrieve the ip address of local machine

A. getByName("localhost")

B. getLocalHost()

C. getByAddress()
D. both (i) & (ii)

Answer optiond

Marks: 2

What will be displayed in the output?


import java.net.*;
class URLDemo
{
public static void main (String args[]) throws Exception
{
3090 URL hp= new URL("http://www.rediffmail.com/index.html");
System.out.println(hp.getProtocol());
String host= hp.getHost();
System.out.println(hp.getPort());
String file = hp.getFile();
}
}

http
www.rediffmail.com
A. 80
index.html

http
B. 80

http
C. -1

http
www.rediffmail.com
D. -1
index.html

Answer optiond

Marks: 2

3091 Which is the Jdbc-Odbc bridge driver?

A. microsoft.jdbc.odbc.JdbcOdbcDriver

B. sun.jdbc.odbc.JdbcOdbcDriver

C. com.mysql.jdbc.Driver

D. oracle.jdbc.odbc.JdbcOdbcDriver

Answer optionb

Marks: 2

3092 All input parameters in JDBC are represented by the _____ symbol, which is known as the ______.

A. * , parameterized cursor

B. * , place holder

C. ? , parameterized cursor

D. ? , place holder

Answer optiond

Marks: 2

3093 Which is the method of HttpServlet class?

A. doGet(HttpServletRequest req , HttpServletResponse res)

B. doTrace(HttpServletRequest req , HttpServletResponse res)

C. doOptions(HttpServletRequest req , HttpServletResponse res)

D. All of these

Answer optiond

Marks: 2

3094 A session can be obtained by getSession() method of ____________. This method returns__________.

A. HttpServletRequest , HttpSession object

B. HttpSession , String
C. HttpServletResponse , HttpSession object

D. HttpServlet , String

Answer optiona

Marks: 2

What will be the output of following program ?

import java.awt.*;
import java.applet.*;

/*<applet code=ChoiceDemo width=250 height=200>


</applet>*/
public class ChoiceDemo extends Applet
{
public void init()
{
3095 Choice c = new Choice();
c.addItem("Cricket");
c.addItem("Football");
c.addItem("Hockey");
c.addItem("Tennis");

c.select(2);
add(c);

}
}

A. S1Q42O1.jpg

B. S1Q42O2.jpg

C. S1Q42O3.jpg

D. S1Q42O4.jpg

Answer optionc

Marks: 2

3096 Identify the layout manager used in the given output.

A. FlowLayout

B. BorderLayout

C. CardLayout

D. GridBagLayout

Answer optionb

Marks: 2

Select the missing statement in the program to get the following output

import java.awt.*;
import javax.swing.*;
/*
<applet code="JComboBoxdemo" width=300 height=200>
*/
public class JComboBoxdemo extends JApplet

public void init()


3097 {
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JComboBox jc = new JComboBox();
jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");

contentPane.add(jc);

A. </applet>

B. import java.awt.event.*;

C. }

D. {

Answer optiona

Marks: 2
3098 Select proper code for given output

import java.awt.*;
import javax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTableDemo extends JApplet
{
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] colHeads = { "emp_Name", "emp_id", "emp_salary" };
final Object[][] data = {
{ "Ramesh", "111", "50000" },
A. { "Sagar", "222", "52000" },
{ "Virag", "333", "40000" },
{ "Amit", "444", "62000" },
{ "Anil", "555", "60000" },
};
JTable table = new JTable( colHeads,data);
table.setBackground(Color.pink);
table.setForeground(Color.blue);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}

import java.awt.*;
import javax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTableDemo extends JApplet
{
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] colHeads = { "emp_Name", "emp_id", "emp_salary" };
final Object[][] data = {
B. { "Ramesh", "111", "50000" },
{ "Sagar", "222", "52000" },
{ "Virag", "333", "40000" },
{ "Amit", "444", "62000" },
{ "Anil", "555", "60000" },
};
JTable table = new JTable(data , colHeads);

int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}

import java.awt.*;
import javax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTableDemo extends JApplet
{
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] colHeads = { "emp_Name", "emp_id", "emp_salary" };
final Object[][] data = {
{ "Ramesh", "111", "50000" },
C. { "Sagar", "222", "52000" },
{ "Virag", "333", "40000" },
{ "Amit", "444", "62000" },
{ "Anil", "555", "60000" },
};
JTable table = new JTable(data);
table.setBackground(Color.pink);
table.setForeground(Color.blue);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}
import java.awt.*;
import javax.swing.*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTableDemo extends JApplet
{
public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
final String[] colHeads = { "emp_Name", "emp_id", "emp_salary" };
final Object[][] data = {
{ "Ramesh", "111", "50000" },
D. { "Sagar", "222", "52000" },
{ "Virag", "333", "40000" },
{ "Amit", "444", "62000" },
{ "Anil", "555", "60000" },
};
JTable table = new JTable(data , colHeads);
table.setBackground(Color.pink);
table.setForeground(Color.blue);
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(table, v, h);
contentPane.add(jsp, BorderLayout.CENTER);
}
}

Answer optiond

Marks: 2

Consider the following program. Find which statement contains error.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code="KeyDemo" width=300 height=100>
</applet>
*/
public class KeyDemo extends Applet
implements KeyListener
{
String msg = "";
int X = 10, Y = 20;
public void init()
{
addKeyListener(this);
requestFocus();
3099 }
public void keyPressed(KeyEvent ke)
{
showStatus("Key Down");
}
public void keyReleased(KeyEvent ke)
{
showStatus("Key Up");
}
public void keyTyped(KeyEvent ke)
{
msg += ke.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, X, Y);
}
}

A. Error in applet code

B. Error in import staments

C. Error in drawString()

D. Error in showStatus()

Answer optiond

Marks: 2

3100 Select proper code for given output


import java.awt.*;
import java.awt.event.*;
import java.swing.*;

/*
<applet code="JButtonDemo" width=200 height=200>
</applet>
*/
public class JButtonDemo extends JApplet implements ActionListener
{
JLabel l;
public void init()
{
Container c= getContentPane();
c.setLayout(new FlowLayout());

JButton add = new JButton("Add");


JButton sub = new JButton("Multiply");
JButton multi = new JButton("Subtract");
A. JButton div = new JButton("Division");
c.add(add);
c.add(multi);
c.add(sub);
c.add(div);
add.addActionListener(this);
multi.addActionListener(this);
sub.addActionListener(this);
div.addActionListener(this);
l=new JLabel();
c.add(l);
}

public void actionPerformed(ActionEvent ae)


{
l.setText("You pressed "+ae.getActionCommand());
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/*
<applet code="JButtonDemo" width=200 height=200>
</applet>
*/
public class JButtonDemo extends JApplet implements ActionListener
{
JLabel l;
public void init()
{
Container c= getContentPane();
c.setLayout(new FlowLayout());

JButton add = new JButton("Add");


JButton sub = new JButton("Multiply");
JButton multi = new JButton("Subtract");
B. JButton div = new JButton("Division");
c.add(add);
c.add(sub);
c.add(multi);
c.add(div);
add.addActionListener(this);
multi.addActionListener(this);
sub.addActionListener(this);
div.addActionListener(this);
l=new JLabel();
c.add(l);
}

public void actionPerformed(ActionEvent ae)


{
l.setText("You pressed "+ae.getActionCommand());
}

}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class JButtonDemo extends JApplet implements ActionListener


{
JLabel l;
public void init()
{
Container c= getContentPane();
c.setLayout(new FlowLayout());

JButton add = new JButton("Add");


JButton sub = new JButton("Multiply");
JButton multi = new JButton("Subtract");
JButton div = new JButton("Division");
c.add(add);
C. c.add(sub);
c.add(multi);
c.add(div);
add.addActionListener(this);
multi.addActionListener(this);
sub.addActionListener(this);
div.addActionListener(this);
l=new JLabel();
c.add(l);
}

public void actionPerformed(ActionEvent ae)


{
l.setText("You pressed "+ae.getActionCommand());
}

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code="JButtonDemo" width=200 height=200>
</applet>
*/
public class JButtonDemo extends JApplet implements ActionListener
{
JLabel l;
public void init()
{
Container c= getContentPane();
c.setLayout(new FlowLayout());

JButton add = new JButton("Add");


JButton sub = new JButton("Multiply");
JButton multi = new JButton("Subtract");
D. JButton div = new JButton("Division");
c.add(add);
c.add(multi);
c.add(sub);
c.add(div);
add.addActionListener(this);
multi.addActionListener(this);
sub.addActionListener(this);
div.addActionListener(this);
l=new JLabel();
c.add(l);
}

public void actionPerformed(ActionEvent ae)


{
l.setText("You pressed "+ae.getActionCommand());
}

Answer optionb

Marks: 2
Consider the following program. Find missing statement.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code="AdapterDemo" width=300 height=100>
</applet>
*/
public class AdapterDemo extends Applet
{

public void init()


{
addKeyListener(new MyKeyAdapter(this));
requestFocus();
3101 }

class MyKeyAdapter extends KeyAdapter


{
AdapterDemo a;
public MyKeyAdapter(AdapterDemo a)
{
this.a = a;
}

public void keyPressed(KeyEvent ke)


{
a.showStatus("Key Down");

A. Missing }

B. Missing 'implements KeyListener' statement

C. Missing KeyTyped() method

D. Missing keyReleased() method

Answer optiona

Marks: 2

find missing statements:

import java.net.*;
import java.io.*;
import ________.*;
public class HeaderViewer
{
public static void main(String args[])
{
try
{
URL u = new URL("http://www.rediffmail.com/index.html");
URLConnection uc = u.______;
System.out.println("Content-type: " +uc.getContentType( ));
System.out.println("Date: " + new Date(uc.getDate( )));
3102 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 (Exception ex)
{
System.out.println("I can't understand this URL...");
}
catch (MalformedURLException ex)
{
System.err.println(ex);
}
System.out.println( );
}
}

A. java.util,getConnection()

B. java.util,openConnection()

C. java.net,openConnection()

D. java.util,setConnection()

Answer optionb

Marks: 2
Consider the following program
select the proper missing statement in the program.

import java.net.*;
import java.io.*;
----------------
{
public static void main (String args[])
{
try
3103 {
InetAddress address = InetAddress.getByName("www.google.com");
System.out.println(address);
System.out.println(address.getHostName());
}
catch (UnknownHostException e)
{
System.out.println("Could not find this computer's address.");
}
}
}

class InetDemo
A.

B. class inetdemo

C. Class InetDemo

D. A or B

Answer optiond

Marks: 2

Consider the following program


Select the statement that should be added to the program to get correct output.
import java.sql.*;
public class MyDB1
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN");
PreparedStatement ps=c.prepareStatement( "insert into Student values(?,?,?)");
ps.setString(1,args[0]);
ps.setString(2,args[1]);
3104 ps.setString(3,args[2]);
int count= ps.executeUpdate();
System.out.println("Data inserted"+count);
ResultSet rs=s.executeQuery("select* from Student");
System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg");
while(rs.next())
{
System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3));
}
s.close();
c.close();
}
}

A. c.createStatement( )

B. {

C. }

D. c.prepareStatement()

Answer optiona

Marks: 2

Consider the following program


What should be the correction done in the program to get correct output?
import java.sql.*;
public class MyDB2
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN");
String s= "delete from Employee where emp_name=?";
PreparedStatement ps=c.preparedStatement(s) ;
ps.setString(1,args[0]);
3105 int count=ps.executeUpdate();
System.out.println("Data deleted"+count);
Statement st=c.createStatement();
s="select * from Employee ";
ResultSet rs= st.executeQuery(s);
while(rs.next())
{
System.out.println(rs.getInt(1)+" \t\t "+rs.getString(2));
}
ps.close();
c.close();
}
}

A. executeQuery()
B. Missing semicolon

C. createStatement(s)

D. prepareStatement(s)

Answer optiond

Marks: 2

3106 Select proper code for given output

import java.sql.*;
public class MyDB1
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN");
PreparedStatement ps=c.prepareStatement( "insert into Student values(?,?,?)");
int count= ps.executeUpdate();
System.out.println("Data inserted"+count);
A. Statement s=c.createStatement();
ResultSet rs=s.executeQuery("select * from Student");
System.out.println("\tName"+"\t\t"+"Roll no"+"\t\t"+"Avg \n");
while(rs.next())
{
System.out.println("\t"+rs.getString(1)+"\t\t"+rs.getInt(2)+"\t\t"+rs.getInt(3));
}
s.close();
c.close();
}
}

import java.sql.*;
public class MyDB1
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN");
PreparedStatement ps=c.prepareStatement( "insert into Student values(?,?,?)");
ps.setString(1,args[0]);
ps.setString(2,args[1]);
ps.setString(3,args[2]);
int count= ps.executeUpdate();
B. System.out.println("Data inserted"+count);
Statement s=c.createStatement();
ResultSet rs=s.executeQuery("select* from Student");
System.out.println("\tName"+"\t\t"+"Roll no"+"\t\t"+"Avg \n");
while(rs.next())
{
System.out.println("\t"+rs.getString(1)+"\t\t"+rs.getInt(2)+"\t\t"+rs.getInt(3));
}
s.close();
c.close();
}
}

import java.sql.*;
public class MyDB1
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN");
PreparedStatement ps=c.prepareStatement( "insert into Student values(?,?,?)");
ps.setString(1,args[0]);
ps.setString(2,args[1]);
ps.setString(3,args[2]);
int count= ps.executeUpdate();
C. System.out.println("Data inserted"+count);
Statement s=c.createStatement();
ResultSet rs=s.executeQuery("delete * from Student");
System.out.println("\tName"+"\t\t"+"Roll no"+"\t\t"+"Avg \n");
while(rs.next())
{
System.out.println("\t"+rs.getString(1)+"\t\t"+rs.getInt(2)+"\t\t"+rs.getInt(3));
}
s.close();
c.close();
}
}
import java.sql.*;
public class MyDB1
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN");
String a= "insert into Student values(?,?,?)"
PreparedStatement ps=c.prepareStatement();
ps.setString(1,args[0]);
ps.setString(2,args[1]);
ps.setString(3,args[2]);
D. int count= ps.executeUpdate(a);
System.out.println("Data inserted"+count);
Statement s=c.createStatement();
ResultSet rs=s.executeQuery("select* from Student");
System.out.println("\tName"+"\t\t"+"Roll no"+"\t\t"+"Avg \n");
while(rs.next())
{
System.out.println("\t"+rs.getString(1)+"\t\t"+rs.getInt(2)+"\t\t"+rs.getInt(3));
}
s.close();
c.close();
}
}

Answer optionb

Marks: 2

Consider the following program


What should be the correction done in the program to get correct output?
import java.sql.*;
public class MyDB4
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN");
String s= "delete from Employee where emp_id=2";
Statement st=c.createStatement();
3107 int count=ps.executeUpdate(s);
System.out.println("Data deleted"+count);
s="select * from Employee ";
ResultSet rs= st.executeQuery();
while(rs.next())
{
System.out.println(rs.getInt(1)+" \t\t "+rs.getString(2));
}
s.close();
c.close();
}
}

A. Missing Semicolon

B. Missing {

C. Missing }

D. Missing parameter

Answer optiond

Marks: 2

What will be output of program if user enters 'ABC' in Name & 'xyz' in Password
import java.io.*;
import java.servlet.*;
public class ServletDemo extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res) throws ServletException, IOException
{
res.setContenType("text/html");
PrintWriter pw = res.getWriter();
String user= "abc";
String password= "xyz";
String u = req.getParameter("t1");
String p = req.getParameter("t2");
if((u.equals(user))&&(p.equals(password)))
{
pw.println("<h1>Welcome to home page </h1>");
}
3108 else
{
pw.println("Invalid");
}
}
}

HTML File -->


<html>
<body>
<form action = "ServletDemo">
Name : <input type="text" name="t1">
Password : <input type="password" name="t2">
<input type = "submit" value="login">
</form>
</body>
</html>
*/

A. Welcome to home page


B. Invalid

C. Login succesful

D. It will give an error

Answer optionb

Marks: 2

Select the proper method in the blank space


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HttpServletDemo extends HttpServlet


{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException
{
res.setContentType("text/html");

3109 PrintWriter out= ___________ ;


out.println("<html>");
out.println("<head>");
out.println("<title>Hello World !</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World !</h1>");
out.println("</body>");
out.println("</html>");
}
}

A. req.getWriter()

B. res.getParameter()

C. res.getWriter()

D. req.getParameter()

Answer optionc

Marks: 2

Consider the following program and debug it.

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.http.*;
public class SessionDemo extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
3110 HttpSession hs = request.getSession(true);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. Error in method parameters

B. Error in method definition

C. Error in class declaration

D. Error in import statement

Answer optiond

Marks: 2

3111 Which is the super class of container class

A. Window

B. AWTComponent

C. Panel

D. Component

Answer optiond
Marks: 1

3112 Which is not the constant for Label component

A. Label.RIGHT

B. Label.LEFT

C. Label.CENTER

D. Label.TOP

Answer optiond

Marks: 1

3113 Which is the most common Exception thrown by AWT controls

A. NullPointerException

B. HeadlessException

C. ComponentException

D. ControlException

Answer optionb

Marks: 1

3114 What is the use of Tree Component in Swing

A. for retriving data

B. for storing data

C. for presenting heirachical view of data

D. none

Answer optionc

Marks: 1

3115 Which of the following is the legal adapter classes in Java?

A. ActionAdapter

B. ItemAdapter

C. TextAdapter

D. MouseAdapter

Answer optiond

Marks: 1

3116 Which of the following is the highest class in the event-delegation model

A. java.util.EventListener

B. java.util.EventObject

C. java.awt.AWTEvent

D. java.awt.event.AWTEvent

Answer optionb

Marks: 1

3117 Which is the reliable protocol of networking

A. TCP

B. UDP

C. IP

D. HTTP
Answer optiona

Marks: 1

3118 What is the port number of HTTP protocol

A. 80

B. 45

C. 81

D. 23

Answer optiona

Marks: 1

3119 Which is the correct form of methods

A. getAddress(byte[])

B. byte getAddress()

C. []byte getAddress()

D. byte[] getAddress()

Answer optiond

Marks: 1

3120 __________ method returns true if this internet address is multicast address else returns false.

A. boolean isMultiCastAddress()

B. long isMultiCastAddress()

C. String isMultiCastAddress()

D. boolean MultiCastAddress()

Answer optiona

Marks: 1

3121 Which package is/are used to build servelet program

A. javax.servlet

B. javax.servlet.http

C. java.servlet.http

D. both a & b

Answer optiond

Marks: 1

3122 What is JSDK ?

Java Service Devlopment Kit


A.

B. Java Servlet Devlopment Kit

C. Java Servlet Deployment Kit

D. Java Software Devlopment Kit

Answer optionb

Marks: 1

3123 Which is file required for servlet mapping in apache tomcat

A. web.xml

B. web-inf.xml

C. build.xml
D. webapp.xml

Answer optiona

Marks: 1

3124 The getItem() method returns _______________

A. string

B. int

C. object

D. event

Answer optionc

Marks: 2

3125 What is the code for following output

import java.applet.Applet;
import java.awt.Button;
/*
<applet code="CreateAWTButtonExample" width=200 height=200>
</applet>
*/
public class CreateAWTExample extends Applet
{
public void init()
A. {
Button button1 = new Button();

button1.setLabel("My Button 1");


Button button2 = new Button("My Button 2");
add(button1);
add(button2);
}

import java.applet.Applet;
import java.awt.Button;
/*
<applet code="CreateAWTButtonExample" width=200 height=200>
</applet>
*/
public class CreateAWTButtonExample extends Applet
{
public void init()
B. {
Button button1=new Button();

button1.setLabel("My Button 1");


Button button2 = new Button("My Button 2");

add(button2);
}

import java.applet.Applet;
import java.awt.Button;
/*
<applet code="CreateAWTButtonExample" width=200 height=200>
</applet>
*/
public class CreateAWTButtonExample extends Applet
{
public void init()
C. {

button1.setLabel("My Button 1");


Button button2 = new Button("My Button 2");
add(button1);
add(button2);
}

import java.applet.Applet;
import java.awt.Button;
/*
<applet code="CreateAWTButtonExample" width=200 height=200>
</applet>
*/
public class CreateAWTButtonExample extends Applet
{
public void init()
D. {
Button b = new Button();

button1.setLabel("My Button 1");


Button button2 = new Button("My Button 2");
add(b);
add(button2);
}

Answer optiona
Marks: 2

3126 What is the code for following output

import java.applet.Applet;
import java.awt.Checkbox;
import java.awt.Color;
/*
<applet code="ChangeCheckboxBackgroundExample" width=200 height=200>
</applet>
*/
public class ChangeCheckboxBackgroundExample extends Applet
{
public void init()
A. {

Checkbox checkbox1 = new Checkbox("Checkbox 1");


Checkbox checkbox2 = new Checkbox("Checkbox 2");

checkbox1.setBackground(Color.red);

add(checkbox1);
add(checkbox2);
}
}

import java.applet.Applet;
import java.awt.Checkbox;
import java.awt.Color;
/*
<applet code="ChangeCheckboxBackgroundExample" width=200 height=200>
</applet>
*/
public class ChangeCheckboxBackgroundExample extends Applet
{
public void init()
B. {

Checkbox checkbox1 = new Checkbox("Checkbox 1");


Checkbox checkbox2 ;

checkbox1.setBackground(Color.red);
checkbox2.setBackground(Color.green);
add(checkbox1);
add(checkbox2);
}
}

import java.applet.Applet;
import java.awt.Checkbox;
import java.awt.Color;
/*
<applet code="ChangeCheckboxBackgroundExample" width=200 height=200>
</applet>
*/
public class ChangeCheckboxBackgroundExample extends Applet
{
public void init()
C. {

Checkbox checkbox1 = new Checkbox("Checkbox 1");


Checkbox checkbox2 = new Checkbox("Checkbox 2");

checkbox1.setBackground(Color.red);
checkbox2.setBackground(Color.green);
add(checkbox1);
add(checkbox2);
}
}

import java.applet.Applet;
import java.awt.Checkbox;
import java.awt.Color;
/*
<applet code="ChangeCheckboxBackgroundExample" width=200 height=200>
</applet>
*/
public class ChangeCheckboxBackgroundExample extends Applet
{
public void init()
{
D.
Checkbox checkbox1 = new Checkbox("Checkbox 1");
checkbox2 = new Checkbox("Checkbox 2");

checkbox1.setBackground(Color.red);
checkbox2.setBackground(Color.green);

add(checkbox1);
add(checkbox2);
}
}

Answer optionc

Marks: 2
Find the statement in which there is error
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*<applet code="DemoButton.class" height=500 width=500></applet>*/

public class DemoButton extends Applet implements ActionListener


{

String msg= " ";


Button barr[]=new Button[3];

public void init()


{
Button yes=new Button ("YES");
Button no=new Button ("No");
Button undecided=new Button ("UNDECIDED");

barr[0]=(Button)add(yes);
barr[1]=(Button)add(no);
barr[2]=(Button)add(undecided);

for(int i=0;i<3;i++)
3127 {
barr.addActionListener(this);
}
}

public void actionPerformed(ActionEvent ae)


{

for(int i=0;i<3;i++)
{
if(ae.getSource()==barr[i])
{
msg=" You Pressed "+ barr[i].getLabel();
}//if end
}//for end
repaint();

}//method end

public void paint(Graphics g)


{
g.drawString(msg ,100,100);
}
}

A. barr.addActionListener(this);

B. barr[2]=(Button)add(undecided);

C. if(ae.getSource()==barr[i])

D. none

Answer optiona

Marks: 2

3128 getByName() method returns

A. retruns array of IP Adress

B. retruns Host name & IP Address

C. return Host Name

D. return array of Host Name

Answer optionb

Marks: 2

3129 The purpose of URL is

A. to make database connection

B. to recongnize server

C. a and b

D. recongnize network resource

Answer optiond

Marks: 2

3130 Which is the correct method of URLConnection class

A. String getHost()

B. int getLength()
C. Sting getProtocol()

String getContentType()
D.

Answer optiond

Marks: 2

What will be displayed in the output


import java.net.*;
class InetAddressTest
{
public static void main(String args[]) throws UnknownHostException {
3131 InetAddress SW[] = InetAddress.getAllByName("www.nba.com");
for (int i=0; i<SW.length; i++)
System.out.println(SW[i]);
}
}

A. The internet address of the client

B. The local host name

C. The array of IP address

D. The local host address

Answer optionc

Marks: 2

3132 Which is a correct component of JDBC API

A. DriverManager

B. Driver

C. PreparedStatement

D. both a & b

Answer optiond

Marks: 2

3133 The ResultSet is used to get information about a���������..

A. Database

B. Result Set

C. Table

D. ResultSetMetaData

Answer optionb

Marks: 2

3134 Which of the following methods is main method in life cycle of servlet

A. wait()

B. block()

C. service()

D. doGet()

Answer optionc

Marks: 2

3135 Which is the correct code for following output


import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class CBox1 extends Applet


{
TextField tf;
Checkbox c3,c4;
CheckboxGroup cbg;
public void init()
{
cbg=new CheckboxGroup();
A. c3=new Checkbox("yes",cbg,true);
c4=new Checkbox("no",cbg,false);
tf=new TextField();

add(c3);
add(c4);

}
}
/* <applet code=CBox1.class
height=500
width=500>
</applet>*/

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class CBox1 extends Applet


{
TextField tf;
Checkbox c3,c4;
CheckboxGroup cbg;
public void init()
{
cbg=new CheckboxGroup();
B. c3=new Checkbox("yes",cbg,true);
c4=new Checkbox("no",cbg,false);
tf=new TextField();

add(c3);
add(c4);
add(tf);
}
}
/* <applet code=CBox1.class
height=500
width=500>
</applet>*/

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class CBox1 extends Applet


{
TextField tf;
Checkbox c3,c4;
CheckboxGroup cbg;
public void init()
{
cbg=new Checkbox();
C. c3=new Checkbox("yes",cbg,true);
c4=new Checkbox("no",cbg,false);
tf=new TextField();

add(c3);
add(c4);
add(tf);
}
}
/* <applet code=CBox1.class
height=500
width=500>
</applet>*/

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class CBox1 extends Applet


{
TextField tf;
Checkbox c4;
CheckboxGroup cbg;
public void init()
{
cbg=new CheckboxGroup();
D. c3=new Checkbox("yes",cbg,true);
c4=new Checkbox("no",cbg,false);
tf=new TextField();

add(c3);
add(c4);
add(tf);
}
}
/* <applet code=CBox1.class
height=500
width=500>
</applet>*/

Answer optionb

Marks: 2
Find which statement contains error
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
class Sample extends Frame
{
Sample(String title)
{
super(title);
addWindowListener(new MyWindowAdapter());
}
public void paint(Graphics g)
{
g.drawString("Frame Window",10,40);
}
}
class MyWindowAdapter extends WindowAdapter
{
Sample s;
public MyWindowAdapter(Sample s)
{
this.s=s;
}
public void windowClosing(WindowEvent we)
{
3136 s.setVisible(false);
}
}
public class Ex3 extends Applet
{
Frame f;
public void init()
{
f=new Sample("Frame window");
f.setSize(400,400);
f.setVisible(true);
}
public void start()
{
f.setVisible(true);
}
public void stop()
{
f.setVisible(false);
}
public void paint(Graphics g)
{
g.drawString("Applet Window",10,20);
}
}/* <applet code=Ex3.class height=400 width=300>
</applet>*/

A. Error in the statement in which Adapter class is initalized

B. Error in the statement in which applet tag is declared

C. Error in the statement in which frame is initalized

D. None of the above

Answer optiona

Marks: 2

Which of the following statement is missing from the program to be correct?


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Jprogress extends JPanel
{
JProgressBar pb;
static final int min=50;
static final int max=100;
public Jprogress()
{
pb=new JProgressBar();
pb.setMinimum(min);
pb.setMaximum(max);
add(pb);
}
public void update(int value)
{
pb.setValue(value);
}
3137 public static void main(String a[])
{
final Jprogress p1=new Jprogress();
JFrame f=new JFrame("Demo");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(300,300);

f.setVisible(true);
for (int i=min;i<=max;i++)
{
final int percent=i;
try
{
p1.update(percent);
java.lang.Thread.sleep(100);
}
catch(Exception e){ }
}
}
}

A. f.setContentPane(p1);
B. add(min);

C. pb.setSize();

D. None of the above

Answer optiona

Marks: 2

For the following code select the method that can be used to handle event
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//<applet code=JCombobox1.class width=300 height=100></applet>
public class JCombobox1 extends JApplet implements ItemListener
{
JLabel jl;
ImageIcon yahoo;
public void init()
{
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
JComboBox jc= new JComboBox();
3138 jc.addItem("Yahoo mail");
jc.addItem("gmail");
jc.addItemListener(this);
cp.add(jc);
yahoo=new ImageIcon("Desert.jpg");
jl=new JLabel(yahoo);
cp.add(jl);
}
public void itemStateChanged(ItemEvent ie)
{
String s=(String)ie.getItem();
jl.setText(s);
}
}

A. actionPerformed(ItemEvent ie)

B. actionPerformed(ActionEvent ae)

C. itemStateChanged(ItemEvent ie)

D. adjustmentStateChanged(ItemEvent ie)

Answer optionc

Marks: 2

Select the missing Statement in the program for following output


import java.awt.*;
import java.awt.event.*;
public class MenuD extends Frame
{
MenuD( )
{
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
}
public static void main(String a[])
{
MenuD m=new MenuD();
CheckboxMenuItem debug,test;
m.setVisible(true);
3139 MenuBar mbr=new MenuBar();
m.setMenuBar(mbr);
Menu file=new Menu("File");
Menu edit= new Menu("edit");
mbr.add(file);
mbr.add(edit);
MenuItem new1=new MenuItem("New");
MenuItem open=new MenuItem("Open");
file.add(new1);
file.add(open);
MenuItem copy=new MenuItem("Copy");
MenuItem paste=new MenuItem("Paste");
copy.setEnabled(false);
edit.add(copy);
edit.add(paste);
debug =new CheckboxMenuItem("Debug");
test =new CheckboxMenuItem("Test");
edit.add(test);
}
}

A. import java.awt.applet.*;

B. ); and edit.add(debug);

C. edit.add(debug);

D. ()

Answer optionb
Marks: 2

Consider the following Program What will be displayed in the output


import java.net.*;
class UrlDemo
{
public static void main(String a[]) throws MalformedURLException
3140 {
URL ur= new URL("http://www.msbte.com/mainsite/");
System.out.println("Host:---"+ur.getHost());

}
}

A. To find out host of the another PC

B. To find out host of the client

C. To find out host of the local machine

D. To find out host of the website

Answer optiond

Marks: 2

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

import java.io.*;
class UrlDemo1
{
public static void main(String a[]) throws Exception
{
URL ur= new URL("http://www.msbte.com/mainsite/");
3141 URLConnection con=ur.openConnection();
System.out.println("Date : "+new 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);
}
}

A. Exception type is wrong

B. Missing import java.net.*;

C. Class Should not be public

D. Creation of object is not correct

Answer optionb

Marks: 2

Select the statement that should be added to program to get corrected output
import java.sql.*;
import java.io.*;
class Jdbc_ResultSet
{
public static void main(String arg[])
{
String s1;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
System.out.println("connection established");
s1="select comp_name,num,cost,capacity from company order by num";
Statement st=con.createStatement();

rs=st.getResultSet();
3142
System.out.println("Comp_name"+" "+"num"+" "+"cost"+ " "+"capacity");
System.out.println();
while(rs.next())
{
System.out.println(rs.getString("comp_name")+" "+rs.getInt("num")+" "+rs.getInt("cost")+" "+rs.getString("capacity"));
}
con.close();
}
catch(SQLException e)
{
System.out.println(" sql error");
}
catch(Exception e)
{
System.out.println(" connection error1");
}
}
}

A. st.close()

B. rs.createStatement()

C. ResultSet rs=st.executeQuery(s1);
D. st.executeUpdate(s1);

Answer optionc

Marks: 2

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


import java.sql.*;
import java.io.*;
class JdbcP
{
public static void main(String arg[])
{
try
{
DataInputStream in=new DataInputStream(System.in);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded");
String url="jdbc.odbc.abc";
Connection con=DriverManager.getConnection(url);
System.out.println("connection established");
PreparedStatement ps=con.prepareStatement("create table movie6(num Integer,mvnm Varchar(30))");
ps.executeUpdate();
System.out.println("Table Created");
String sql="insert into movie6 VALUES(?,?)";
3143 PreparedStatement ps2=con.prepareStatement(sql);
System.out.println("Enter movie code");
int mcd=Integer.parseInt(in.readLine());
ps2.setInt(1,mcd);
System.out.println("Enter movie name");
String name=in.readLine();
ps2.setString(2,name);
ps2.executeUpdate();
con.close();
}
catch(SQLException e)
{
System.out.println(" sql error");
}
catch(Exception e)
{
System.out.println(" connection error1");
}
}
}

A. Class.forName("sun.jdbc.odbc.JdbcOdbcDriverManger");

B. Class.forName("sun:jdbc:odbc:JdbcOdbcDriver");

C. String url="jdbc:jdbcodbcDriver:abc";

D. String url="jdbc:odbc:abc";

Answer optiond

Marks: 2

Choose missing statements in following code from given options


public class HelloServlet extends GenericServlet {
public void service(ServletRequest request,
ServletResponse response)
throws ServletException, IOException {
3144 response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

A. import java.util.*;import javax.servlet.*;

B. import java.io.*;import javax.servlet.*;

C. import java.io.*;import java.servlet.*;

D. import java.applet.*;import java.servlet.*;

Answer optionb

Marks: 2

Which Staement is missing from following code showing *****


<html>
<body>
<H1><center>Result for <%=request.getParameter("a1")%></center></H1>
<%
int i=Integer.parseInt(request.getParameter("t1"));
int j=Integer.parseInt(request.getParameter("t2"));
int k=0;
3145 String str=****** ;
if(str.equals("add"))
k=i+j;
if(str.equals("mul"))
k=i*j;
if(str.equals("div"))
k=i/j;
%>
A. request.getParameter("a1");

B. response.getParameter("a1");

C. request.getCookie("a1");

D. request.getParameter();

Answer optiona

Marks: 2

3146 Which are the interfaces contained in HttpServlet

ServletRequest ,HttpServlet ,HttpSession,


A. HttpSessionBinding

HttpServletRequest ,HttpServletResponse ,HttpSession,


B. HttpSessionBindingListener

HttpServletRequest ,ServletResponse ,ServletSession,


C. HttpSessionBindingListener

HttpRequest ,HttpResponse ,HttpSession,


D. HttpSessionBindingListener

Answer optionb

Marks: 2

What is the output of following program on the web page


import java.util.*;
import javax.servlet.*;
public class HelloServlet extends GenericServlet {
public void service(ServletRequest request,
ServletResponse response)
3147 throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

A. Hello!

B. Error in the code

Hello
C.

D. No ouput on web page

Answer optiona

Marks: 2

3148 _______ are the component that allows a user to interact with applications.

A. Frame

B. Controls

C. Window

D. Component

Answer optiond

Marks: 1

3149 _________is used to represent GUI application window ,which is optionally resizable and an have a title bar , icon, and menus.

A. Panel

B. Frame

C. Dialog

D. Window

Answer optionb

Marks: 1

3150 To change the name of the MenuItem ________method is uesd.


A. getLabel()

B. setlabel()

C. getlabel()

D. setLabel()

Answer optiond

Marks: 1

3151 _________method is used to set menuBar on window.

A. setMenu()

B. GetMenubar()

C. setMenuBar()

D. getMenubar()

Answer optionc

Marks: 1

3152 _________is a super class for all layout manager interface.

A. Layout

B. Container

C. Component

D. Window

Answer optionb

Marks: 1

3153 _______method of______class is used to leave a small amount of space between container that hold component.

A. z

B. getInset(),Container

C. setInset(),Container

D. getInset(),Window

Answer optionb

Marks: 1

3154 add() method which used to add component to window which is defined by_______class.

A. Frame

B. Component

C. Window

D. Container

Answer optiond

Marks: 1

3155 When an event occurs,all registered listeners are notified this is known as �����. The event.

A. multicasting

B. unicasting

C. A & B

D. None of the above

Answer optionb

Marks: 1
3156 Constructor of ComponentEvent is �����....

A. ComponentEvent(Component src,int type)

B. componentevent(Component src,int type)

C. componentEvent(component src,int type)

D. Componentevent(Component src,int type)

Answer optiona

Marks: 1

3157 �����.. Interfaces defines a method itemStateChanged().

A. ComponentListener

B. ContainerListener

C. ActionListener

D. ItemListener

Answer optiond

Marks: 1

3158 The �.. Class is used to encapsulate both the numerical IP address the domain name for that address.

A. InetAddress

B. Adapter

C. Factory

D. Proxy

Answer optiona

Marks: 1

3159 To return the currently installed policy object �� method is used.

A. public Policy getpolicy()

B. public static Policy GetPolicy()

C. public Policy getPolicy()

D. public static Policy getPolicy()

Answer optionb

Marks: 1

3160 Which interfae gives information related to the database.

A. DatabaseSetMetaData

B. DatabaseMetaData

C. ResultSetMetaData

D. ResultSet

Answer optionb

Marks: 1

3161 Which parameter takes the _jspService() method ?

A. HttpServletRequest

B. HttpServletResponse

C. All of these

D. None of these

Answer optionc
Marks: 1

3162 Which method is called to process the HTTP request ?

A. destroy

B. service()

C. init()

D. None of these

Answer optionb

Marks: 1

3163 Which packages contains the methods & interfaces that are required to built servlets.

A. javax.servlet

B. javax.servlet.http

C. All of these

D. None of these

Answer optionc

Marks: 1

State the missing statement in the following code

import java.awt.*;
import java.applet.*;
import javax.swing.*;
/*<applet code="Exp4.class" width=400 height=300></applet>*/
public class Exp4 extends JApplet
{
public void init()
3164 {
Container co=getContentPane();
co.setLayout(new FlowLayout());
JComboBox jc =new JComboBox();
jc.addItem("Cricket");
jc.addItem("Football");
jc.addItem("Hockey");
jc.addItem("tennis");
}
}

A. co.addItem(jc);

B. import java.awt.event.*;

C. co.add(jc);

D. all of above

Answer optionc

Marks: 2

3165 A tree is a component that used to

A. displays rows of data

B. represent data in hieharchical view

C. displays columns of data

D. displays rows and columns of data.

Answer optionb

Marks: 2
Select the missing statement in given code:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code=Choice11.class height=600 width=800></applet>
*/
public class Choice11 extends Applet
{
Choice name;
3166 public void init()
{
name=new Choice();
name.add("Trupti");
name.add("Geeta");
name.add("Shaila");
name.add("Sangita");
name.add("Megha");
}
}

A. add(name);

B. add(address);

C. }

D. import java.net.*;

Answer optiona

Marks: 2

3167 CallableStatement interface used for

A. sending prepared statement

B. calling procedure on database

C. sending statement

D. all of above

Answer optionb

Marks: 2

3168 Records can be updated using statement with following method

A. CreateStatement()

B. executeUpdate()

C. Both i & ii

D. None of these

Answer optionc

Marks: 2
Consider the following Code,Find the missing Statement in program
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class MouseEvent1 extends Applet implements MouseListener,MouseMotionListener


{
String msg=" ";
int mx=0,my=0;
public void init()
{
addMouseListener(this);
addMouseMotionListener(this);
}
public void mouseClicked(MouseEvent me)
{
mx=0;
my=10;
msg="mouse clicked";
repaint();
}
void mouseEntered(MouseEvent me)
{
mx=0;
my=10;
msg="mouse entered";
repaint();
}
public void mousePressed(MouseEvent me)
{
mx=me.getX();
my=me.getY();
msg="mouse pressed";
repaint();
}

{
3169 mx=me.getX();
my=me.getY();
msg="mouse Released";
repaint();
}
public void mouseExited(MouseEvent me)
{
mx=0;
my=10;
msg="mouse Exited";
repaint();
}
public void mouseDragged(MouseEvent me)
{
mx=me.getX();
my=me.getY();
msg="*";
showStatus("Dragging mouse at"+mx+","+my);
repaint();
}
public void mouseMoved(MouseEvent me)
{
mx=me.getX();
my=me.getY();
showStatus("moving mouse at"+mx+","+my);
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,mx,my);
}
}

/* <applet code=MouseEvent1.class
height=400
width=300>
</applet>*/

A. }

B. public void mouseReleased(MouseEvent me)

C. addMouseMotionListener(this);

D. ()

Answer optionb

Marks: 2
What correction should be done in the program to get corrected output
import java.sql.*;
import java.io.*;
class JdbcP
{
public static void main(String arg[])
{
try
{
DataInputStream in=new DataInputStream(System.in);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded");
String url="jdbc:odbc:abc";
Connection con=DriverManager.getConnection(url);
System.out.println("connection established");
ps.executeUpdate();
System.out.println("Table Created");
String sql="insert into movie6 VALUES(?,?)";
PreparedStatement ps2=con.prepareStatement(sql);
3170 System.out.println("Enter movie code");
int mcd=Integer.parseInt(in.readLine());
ps2.setInt(1,mcd);
System.out.println("Enter movie name");
String name=in.readLine();
ps2.setString(2,name);
ps2.executeUpdate();
con.close();
}
catch(SQLException e)
{
System.out.println(" sql error");
}
catch(Exception e)
{
System.out.println(" connection error1");
}
}
}

A. Missing {

B. Missing Semicolon

C. Missing Statement

D. Missing }

Answer optionc

Marks: 2

Choose missing statements in following code from given options


public class HelloServlet extends GenericServlet {
public void service(ServletRequest request,
ServletResponse response)
throws ServletException, IOException {
3171 response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>Hello!");
pw.close();
}
}

A. import java.util.*;import javax.servlet.*;

B. import java.io.*;import javax.servlet.*;

C. import java.io.*;import java.servlet.*;

D. import java.applet.*;import java.servlet.*;

Answer optionb

Marks: 2

3172 Which method is used to change text associated with button

A. setLabel()

B. setText()

C. setCaption()

D. setValue()

Answer optiona

Marks: 1

3173 insert method applicable to which class

A. TextField

B. TextArea
C. Scrollbar

D. checkbox

Answer optionb

Marks: 1

3174 Which type of mode applicable to File Dialog

A. Modless

B. Modal and Modeless

C. load and save

D. Modal

Answer optiond

Marks: 1

3175 In swing MVC architecture use in that M stand for

A. Modless

B. Model

C. Master

D. Meta

Answer optionb

Marks: 1

3176 Which class used to create drop down list component in swing

A. Jchoice

B. Jcombo

C. JComboBox

D. Jdrop

Answer optionc

Marks: 1

3177 States of JToggleButon are

A. 1

B. 0

C. no state

D. true or false

Answer optiond

Marks: 1

3178 Which class is used to create Jtree nodes

A. TreeNode

B. MutableTreeNode

C. DefaultMutableTreeNode

D. DefaultNode

Answer optionc

Marks: 1

3179 ___________method that is invoked when the mouse wheel is moved.

A. mouseWheelMoved()
B. mouseMoved()

C. mouseDragged()

D. none of the above

Answer optiona

Marks: 1

3180 Which of the method not applicabe to MouseListener

A. mouseEntered()

B. mouseExited()

mouseDrop()
C.

D. mouseClicked()

Answer optionc

Marks: 1

3181 Which listener is applicable to container

A. ItemListener

B. FocusListener

C. AdjustmentListener

D. ContainerListener

Answer optiond

Marks: 1

3182 URLConnection class used to

A. Send message to server

B. Accept message from server

C. Access header information of URL

D. Connect with server

Answer optionc

Marks: 1

3183 Policy class used for

A. Authentication

B. Connecting with server

C. set permission to access system resources

D. to search client

Answer optionc

Marks: 1

3184 Return type of execute() method is

A. int

B. boolean

C. void

D. String

Answer optionb

Marks: 1

3185 Servlet is _______ side scripting language


A. Client

B. Server

C. Client and Server

D. None of this

Answer optionb

Marks: 1

3186 getContentPane() is method of which class

A. Container

B. JApplet

C. javax.swing

D. JFrame

Answer optionb

Marks: 2

3187 Identify correct constructor to create vertical progressbar

A. JProgressBar()

B. JProgressBar(int orient)

C. JProgressBar(int orient, int min, int max)

D. All of the above

Answer optiond

Marks: 2

3188 Identify correct constructor to create table of 3 columns and 4 rows

A. JTable(4,3)

B. JTable(3,4)

C. JTable(0,3,4)

D. JTable(0,4,3)

Answer optiona

Marks: 2

3189 Which awt components are required to generate following output:

A. Button,List,TextField

B. Label,TextArea,Choice

C. Label,TextArea,List

D. Label,List,TextField

Answer optionc

Marks: 2

3190 Which packages are required in order to design calculator in applet which work as event driven program

A. java.applet.*

B. java.awt.*, java.awt.event.*

C. java.awt, java.applet, java.awt.event.*

D. java.awt.*, java.applet.*

Answer optionc

Marks: 2
3191 keyTyped event means

A. key pressed

B. key released

C. key pressed and released

D. key removed

Answer optionc

Marks: 2

3192 following class is not an adapter class

A. FocusAdapter

B. ItemAdapter

C. KeyAdapter

D. WindowAdapter

Answer optionb

Marks: 2

3193 Subnet mask address of following IP address is: 194.212.27.2

A. 255.0.0.0

B. 255.255.255.0

C. 255.255.0.0

D. 255.255.255.255

Answer optionb

Marks: 2

3194 java.security package mainly used for

A. Authentication

B. Access Control

C. Put hardware device for protection

D. Both option A & B

Answer optiona

Marks: 2

Which method will require of URL class in order to execute following program

import java.net.*;
class ur
{
public static void main(String ar[])
3195 {
URL u=New URL("www.msbte.com");
URLConnection uc=u.____________();
System.out.println("Content type"+uc.getContentType());
}
}

A. openConnection()

B. typeConnection()

C. getFile()

D. None of This

Answer optiona

Marks: 2

Identify constructor of which class:


3196 (int port, int maxqueue)

A. URL
B. Socket

C. ServerSocket

D. InetAddress

Answer optionc

Marks: 2

3197 Which method will use of ResultSet class to jump from 4th record to 2nd record in database table

A. first()

B. previous()

C. getRecord(2)

D. relative()

Answer optiond

Marks: 2

3198 Which type of exception will generate if sql query is written wrong in syntax

A. SQLException

B. QueryException

C. StringException

D. ResultSetException

Answer optiona

Marks: 2

3199 Which of following constructor of scrollbar is incorrect

A. ScrollBar()

B. ScrollBar(0)

C. ScrollBar(0,10,5,10,100)

D. ScrollBar(0,20)

Answer optiond

Marks: 2

3200 setToolTipText() method not applicable for

A. Panel

B. Frame

C. JApplet

D. All of this

Answer optiond

Marks: 2

// Identify Error in following Program


import javax.swing.*;
import java.applet.*;
import java.awt.*;
public class sample1
{
public void init()
{
3201 JProgressBar p1=new JProgressBar(1);
Container c=getContentPane();
setLayout(new FlowLayout());
c.add(p1);
}
}
/* <applet code="sample1.java" width=300 height=300>
</applet> */

A. Package declaration required

B. Class must extend JApplet class


C. JProgressBar is not valid class

D. FlowLayout is not applicable in swing

Answer optionb

Marks: 2

3202 Following listener are applicable to Button class

A. ActionListener,FocusListener,ContainerListener

B. ItemListener,FocusListener,AdjustmentListeer

C. ActionListener,MouseMotionListener,ComponentListener

D. ActionListener,KeyListener,WindowListener

Answer optionc

Marks: 2

// Which is correct output if user execute following program first time


import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class sample extends Applet implements FocusListener
{
Button b1;
public void init()
{
b1=new Button("RED");
add(b1);
3203 b1.addFocusListener(this);
}
public void focusLost(FocusEvent ae)
{
b1.setBackground(Color.green);
}
public void focusGained(FocusEvent ae)
{
b1.setBackground(Color.red);
}
}
/* <applet code="sample.java" width=500 height=500></applet>*/

A. Background color of button will become green

B. Background color of button will become red

C. Program will not run

D. Background color of button will not change

Answer optionb

Marks: 2

// Which is correct output if user execute following program and select item with name 2
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class sample extends Applet implements ItemListener
{
Choice c1;
int i;
TextField t1;
public void init()
{
c1=new Choice();
for(i=1;i<=5;i++)
3204 { c1.addItem(""+i); }
c1.addItemListener(this);
add(c1);
t1=new TextField(10);add(t1);
}
public void itemStateChanged(ItemEvent ae)
{
if(c1.getSelectedIndex()==1)
{ t1.setText(""+(c1.getItem(2))); }
if(c1.getSelectedIndex()==3)
{ t1.setText(""+(c1.getItem(4)));}
}
}
/* <applet code="sample.java" width=500 height=500></applet>*/

A. S1Q49O1

B. S1Q49O2

C. S1Q49O3

D. Erroe

Answer optiona
Marks: 2

What will be output of following program:

import java.net.*;
class ajp
{
3205 public static void main(String ar[])throws UnknownHostException
{
InetAddress a=InetAddress.getByName("www.google.com");
System.out.println(""+a);
}
}

A. www.google.com

B. www.google.com/209.85.171.100

C. 209.85.171.100

D. WWW.GOOGLE.COM/209.85.171.100

Answer optionb

Marks: 2

//What will be output of following program:

import java.net.*;
class ajp
{
public static void main(String ar[])throws Exception
{
3206 URL u=new URL("http://yahoo.com/index.html");
System.out.println(""+u.getProtocol());
System.out.println(""+u.getHost());
System.out.println(""+u.getPort());
System.out.println(""+u.getFile());
}
}

http
A. yahoo.com
index.html

http
yahoo.com
B. 80
index.html

http
yahoo.com
C. -1
index.html

http
yahoo.com
D. -1
/index.html

Answer optiond

Marks: 2

PreparedStatement=con.prepareStatement("Select * from Test where rno=?");


ps.setInt(1,1);
3207
In above code the parametrs of setInt() method represent:

A. 1st parameter: Actual Data , 2nd parameter: Question mark positiion

B. 1st parameter: Question mark positiion , 2nd parameter: Actual Data

C. 1st parameter: column number , 2nd parameter: Actual Data

D. 1st parameter: Actual Data , 2nd parameter: column number

Answer optionb

Marks: 2

// what will be output for following program if it contain table Test with 5 records

import java.sql.*;
class data
{
public static void main(String ar[])throws Exception
{
3208 class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:AJP");
Statement st=con.createStatement();
int a=st.executeQuery("delete * from Test");
System.out.println(""+a);
}
}
A. 4

B. 5

C. 3

D. Error

Answer optiond

Marks: 2

Consider above table and to extract marks of student whose name AJP, which will be correct form of ResultSet class method:
3209
Note: r1 is object of ResultSet class

A. r1.absolute(4), r1.getInt(2)

B. r1.absolute(3), r1.getInt(2)

C. r1.absolute(3), r1.getInt(3)

D. r1.absolute(4), r1.getInt(3)

Answer optiond

Marks: 2

3210 Identify Correct steps in sequnce to connect application to database

A. Driver Registration, Statement Creation, Connecting to DSN, Execute Queries

B. Connecting to DSN, Driver Registration, Statement Creation, Execute Queries

C. Driver Registration, Connecting to DSN, Statement Creation, Execute Queries

D. Driver Registration,, Connecting to DSN, Execute Queries, Statement Creation

Answer optionc

Marks: 2

What will be output for following program of servlet:


import javax.servlet.*;
public class Pract15 extends GenericServlet
{
public void service(ServletRequest r, ServletResponse res) throws IOException, ServletException
{

3211 res.setContentType("text/html");
PrintWriter p = res.getWriter();
p.println("<HTML>");
p.println("<HEAD> HELLO </HEAD>");
p.println("</HTML>");
}
}

A. HELLO will display in web browser

B. HELLO will print in command prompt

C. Runtime Error will occur

D. Compile time error will occur

Answer optiond

Marks: 2

Which parameter will come for following mehtod of servlet:


3212 public void init( ? )

A. ServletConfig Object

B. ServletRequest Object

C. ServletResponse Object

D. ServletContext Object

Answer optiona

Marks: 2
Which method will come in place of *** in following program:
PrintWriter out= response.getWriter()
Cookie c[]= ***;
for( int i=0; i<c.length; i++)
3213 {
Cookie c1=c[i];
out.println (��+ c1. getName());
out.println (��+ c1. getValue());
}

A. receive()

B. add()

C. addCookies()

D. receiveCookies()

Answer optionc

Marks: 2

3214 If HttpServlet program contains doPost(), doGet() and doTrace() method then which method first get executed

A. doGet()

B. doPost()

C. doTrace()

D. None of this

Answer optiona

Marks: 2

3215 CheckboxGroup used to create _________________________

A. CheckboxGroup

B. Checkbox

C. Button

D. RadioButtonGroup

Answer optiond

Marks: 1

3216 Identify wrong type of Adjustment event of scroll bar

A. TRACK

B. TRACE

C. BLOCK_DECREMENT

D. BLOCK_INCREMENT

Answer optionb

Marks: 1

3217 List control need to implement _______________________ listener to return value

A. AdjustmentListener

B. ActionListener

C. ItemListener

D. None of Above

Answer optionb

Marks: 1

3218 Identify return type of getText()

A. Label

B. int
C. boolean

D. String

Answer optiond

Marks: 1

3219 Identify wrong AWT control

A. List

B. Checkbox

C. Button

D. Radio button

Answer optiond

Marks: 1

3220 Default Layout of Applet

A. FlowLayout

B. GridLayout

C. CardLayout

D. Broderlayout

Answer optiona

Marks: 1

3221 Swing contols are ___________________

A. Platform Dependant

B. Platform Independant

C. Both(I & II)

D. None of above

Answer optionb

Marks: 1

3222 _____________ pane can be used to add component to container

A. Glass

B. ContentPane

C. Container

D. All of above

Answer optionb

Marks: 1

3223 Label implements ____________ type of Listener

A. ActionListener

B. ItemListener

C. Event Listener

D. None of Above

Answer optiond

Marks: 1

3224 ______________unreliable routing protocol.

A. Datagram Protocol (UDP)


B. Internet Protocol (IP)

C. Transmission Control Protocol (TCP)

D. Datagram Protocol (UDP)

Answer optionb

Marks: 1

3225 Return type of instance method getHostName()

A. TCP

B. IP

C. String

D. int

Answer optionc

Marks: 1

3226 Identify wrong type of JDBC driver

A. 100% pure java

B. JDBC-Net pure java

C. JDBC-Native API

D. JDBC-Native pure java

Answer optiond

Marks: 1

3227 For execution of INSERT SQL query in JDBC, ............. method must be used.

A. executeQuery()

B. executeDeleteQuery()

C. executeUpdate()

D. executeDelete()

Answer optionc

Marks: 1

3228 PreparedStatement is used for _____________

A. Precompiled Query

B. Precompiled Update

C. Postcompiled Update

D. Postcompiled Query

Answer optiona

Marks: 1

3229 ________________ method execute at beginning of servlet life cycle.

A. dispose()

B. init()

C. service()

D. destroy()

Answer optionb

Marks: 1

3230 Identify secure method to send data from client to server.


A. doGet()

B. doPost()

C. Service()

D. None of Above

Answer optionb

Marks: 1

3231 Which component required to get folowing output

A. Checkbox,CheckboxGroup

B. Radio,Checkbox

C. CheckboxGroup, label

D. None of Above

Answer optiona

Marks: 2

3232 Identify controls used in following output

A. CheckboxMenuItem

B. Popup Menu

C. Both

D. None of Above

Answer optiona

Marks: 2

3233 Which method is used to display icon on a component like JLabel ?

A. rollOverIcon(ImageIcon i)

B. setIcon(ImageIcon i)

C. displayIcon(ImageIcon i)

D. removeIcon (ImageIconi )

Answer optionb

Marks: 2

3234 Which listener is used to implemet following output

A. ActionListener

B. MouseListener

C. MouseMotionListener

D. ItemListener

Answer optiond

Marks: 2

3235 ________________ speak from the client side to the real server.

A. Proxy

B. Host

C. Server

D. HTTP

Answer optiona

Marks: 2
3236 _________________________ identify component

A. Application Server

B. DBMS

C. Host

D. Proxy

Answer optionb

Marks: 2

3237 ExecuteUpdate() method returns_____________________

A. Single row

B. ResultSet object

C. Integer

D. Single Column

Answer optionc

Marks: 2

3238 ____________________object store session ID.

A. Cookies

B. Session

C. request

D. response

Answer optionb

Marks: 2

3239 Identify cookies, which removed each time when user closes the browser?

A. Persistent cookie

B. Non-persistent cookie

C. Both A & B

D. None of Above

Answer optionb

Marks: 2

3240 Identify components used

A. JTabbedPane,JComboBox

B. JButton

C. JButton,ScrollPane

D. JButton,ScrollBars

Answer optiona

Marks: 2
Identify currect output for given code
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
//<applet code=rcolor.class width=300 height=300></applet>
public class rcolor extends Applet
{
int R,B,G;
3241 public void init()
{
Random r=new Random();
R=r.nextInt(255);
G=r.nextInt(255);
B=r.nextInt(255);
Color c=new Color(R,G,B);
setBackground(Color.RED);
}
}

A. S1Q43O1.jpeg

B. S1Q43O2.jpeg

C. S1Q43O3.jpeg

D. S1Q43O4.jpeg

Answer optiona

Marks: 2

3242 Identify currect code sequence for given output

import java.awt.*;
import javax.swing.*;
//<applet code=scrollpane.class width=500 height=500></applet>
public class scrollpane extends JApplet
{
public void init()
{
Container c=getContentPane();
c.setLayout(new BorderLayout());
JPanel j=new JPanel();
j.setLayout(new GridLayout(10,10));
int a=0;
for(int i=0;i<10;i++)
A. {
for(int k=0;k<10;k++)
{
j.add(new JButton("Button"+a));
a++;
}
}
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane js=new JScrollPane(j,v,h);
c.add(js,BorderLayout.CENTER);
}
}

import java.awt.*;
import javax.swing.*;
//<applet code=scrollpane.class width=500 height=500></applet>
public class scrollpane extends JApplet
{
public void init()
{
Container c=getContentPane();
c.setLayout(new BorderLayout());
JPanel j=new JPanel();
j.setLayout(new GridLayout(10,10));
int a=0;
for(int i=0;i<10;i++)
B. {
for(int k=0;k<10;k++)
{
j.add(new JButton("Button"+a));

}
}
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane js=new JScrollPane(j,v,h);
c.add(js,BorderLayout.CENTER);
}
}
import java.awt.*;
import javax.swing.*;
//<applet code=scrollpane.class width=500 height=500></applet>
public class scrollpane extends JApplet
{
public void init()
{
Container c=getContentPane();
c.setLayout(new BorderLayout());
JPanel j=new JPanel();
j.setLayout(new GridLayout(10,10));
int a=0;
C.
for(int k=0;k<10;k++)
{
j.add(new JButton("Button"+a));
a++;
}

int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane js=new JScrollPane(j,v,h);
c.add(js,BorderLayout.CENTER);
}
}

import java.awt.*;
import javax.swing.*;
//<applet code=scrollpane.class width=500 height=500></applet>
public class scrollpane extends JApplet
{
public void init()
{
Container c=getContentPane();
c.setLayout(new BorderLayout());
JPanel j=new JPanel();
j.setLayout(new GridLayout(10,10));
int a=0;
for(int i=0;i<20;i++)
D. {
for(int k=0;k<20;k++)
{
j.add(new JButton("Button"+a));
a++;
}
}
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane js=new JScrollPane(j,v,h);
c.add(js,BorderLayout.CENTER);
}
}

Answer optiona

Marks: 2

3243 Which component and type of listener is used for given output

A. Image,JTextField,ItemListener

B. Image,JTextField,ActionListener

C. ImageIcon,JTextField,ActionListener

D. ImageIcon,JLabel,ActionListener

Answer optionc

Marks: 2

Consider the following program


What will be displayed in the output?

import java.net.*;
class myAddress
{
public static void main (String ar[])
{
try
3244 {
InetAddress address = InetAddress.getLocalHost();
System.out.println(address);
}
catch (UnknownHostException e)
{
System.out.println("Could not find this computer's address.");
}
}
}

A. HostName

B. IP addess

C. URL

D. Error

Answer optionb
Marks: 2

Consider the following program


and identify output
import java.net.*;
import java.io.*;

public class URLTest


{
3245 public static void main(String args[]) throws MalformedURLException
{
URL url = new URL("http://www.msbte.com/download");
System.out.print("Protocol:"+ url.getProtocol());
System.out.print("Port:"+ url.getPort());

}
}

A. Protocol: http Port:80

B. Protocol: smtp Port:80

C. Protocol: smtp Port:8080

D. Protocol: html Port:8080

Answer optiona

Marks: 2

3246 _____________________ statement responsible to load Drivers.

A. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

B. ResultSet rs=s.executeQuery("select *from StudTable");

C. Statement s=c.createStatement();

D. Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");

Answer optiona

Marks: 2

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("oracle.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
3247 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();
}
}

A. main()

B. Class.forName

C. Connection String

D. ResultSet Type

Answer optionb

Marks: 2
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.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=# where Roll_no=#");
Statement s=c.createStatement( );
s.setString(1,args[0]);
3248 s.setString(2,args[1]);
s.setString(3,args[2]);
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.getDouble(3));
}
s.close();
c.close();
}
}

A. use ? in PreparedStatement

B. use values in PreparedStatement

C. use :? in PreparedStatement

D. None of Above

Answer optiona

Marks: 2

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.OdbcJdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
Statement s=c.createStatement( );
s.setString(1,args[0]);
3249 s.setString(2,args[1]);
s.setString(3,args[2]);
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.getDouble(3));
}
s.close();
c.close();
}
}

A. Currect PreparedStatement

B. use values in PreparedStatement

C. Use statement Class.forName("sun.odbc.jdbc.OdbcJdbcDriver");

D. Use satement Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Answer optiond

Marks: 2

In following Java program fill statement showing ***.Select any one option fro given options

import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void ****(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
3250 String data = request.getParameter("data");
Cookie cookie = new Cookie("MyCookie", data);
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. POST

B. doPost()
C. ActionListener

D. HTMLServlet

Answer optionb

Marks: 2

In following Java program identify missing statement


import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
3251 String data = request.getParameter("data");
//Statement Missing
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. Session s = new Session("MyCookie", data);

B. Cookie cookie = new Cookie("MyCookie", data);

C. Cookie c = new Cookie("MyCookie", data);

D. Session session = new Session("MyCookie", data);

Answer optionb

Marks: 2

Identify which method used to send data from one page to another by url http://localhost:8080/examples/servlet/test.html?
3252 uid=xyz?pass=vvpp?

A. get()

B. post()

C. service()

D. None of Above

Answer optiona

Marks: 2

Choose missing statements in following code from given options.

public class session1 extends HttpServlet


{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException
{
response.setContentType("text/html");
HttpSession hs = request.getSession(true);

3253
pw.print("<B>");
Date date = (Date)hs.getAttribute("date");
if(date != null) {
pw.print("Last access: " + date + "<br>");
}
date = new Date();
hs.setAttribute("date", date);
pw.println("Current date: " + date);
}
}

A. main()

B. PrintWriter pw = response.getWriter();

C. implements HTML

D. response.setContentType("text/html");

Answer optionb

Marks: 2

1. What does the following line of code do?


3254 TextField text = new TextField(10);
A. Creates the object text and initializes it with the value 10

B. Creates text object that can hold 10 columns of text

C. Creates text object that can hold 10 rows of text

D. The code is illegal

Answer optionb

Marks: 1

3255 3. Which of the following methods can be used to remove java.awt.Component object from display?

A. hide()

B. disappear()

C. remove()

D. delete()

Answer optionc

Marks: 1

_______________type of menus which are given as follows: a)Pop-up menus


3256 b. Regular menus c. Menu d. MenuItem

A. a only

B. Both b & c

C. Both a & b

D. Both c & d

Answer optionc

Marks: 1

3257 What are the subclasses of the Container class?

A. Windows, Panel, ScrollPane

B. ScrollPane, Vector, String

C. Thread, Vector, String

D. Applet, InetAddress, Vector

Answer optiona

Marks: 1

3258 Swing Components are_______________________

A. Platform dependent

B. Platform Independent

C. Both a & b

D. Platform oriented

Answer optionb

Marks: 1

11. Which of the following methods can be used to change the size of a java.awt.Component object?
3259 (A) dimension() (B) setSize() (C) area() (D) size()
(E) resize()

A. (A), (B) & (E)

B. (B), (D) & (E)

C. (B) & ( E )

D. (D) & (E)

Answer optionc
Marks: 1

3260 Which of these methods are used to register a keyboard event listener?

A. KeyListener()

B. addKistener()

C. addKeyListener()

D. eventKeyboardListener()

Answer optionc

Marks: 1

3261 Which of these events will be notified if scroll bar is manipulated?

A. ActionEvent

B. ComponentEvent

C. AdjustmentEvent

D. WindowEvent

Answer optionc

Marks: 1

3262 InetAddress can handle_____________________ a) IPV3 b)IPV4 c)IPV5 d)IPV6

A. a only

B. a and b

C. b and d

D. c and d

Answer optionc

Marks: 1

3263 A proxy server ____________________________________

A. speaks the client side of a protocol to another server.

B. which provides resources such as HTML files and other content

C. is to deliver web pages on the request of clients using the Hypertext Transfer Protocol

D. is one end-point of a two-way communication link between two programs running on the network

Answer optiona

Marks: 1

3264 The Prepared statement object is used _____________________________________

A. to call the stored procedures from within a JDBC application program

B. IN, OUT, INOUT parameters when calling a stored procedure

C. to execute dynamic SQL statement against the database.

D. to both pass information and retrieve information from a stored procedure.

Answer optionc

Marks: 1

3265 Driver Manager manages_______________________________________

A. the set of Java Database Connectivity (JDBC) drivers that are available for an application to use.

B. establish connection between data source and application

C. that employs the ODBC driver to connect to the database.

D. converts JDBC method calls into ODBC function calls


Answer optiona

Marks: 1

3266 public void beforeFirst() method of ResultSet is used to _________________

A. Move record pointer or cursor to the end of first row of the result set

B. Move record pointer or cursor to the beginning of last row of the result set

C. Move record pointer or cursor to the beginning of the result set that is before first row

D. Move record pointer or cursor to the end of the result set .

Answer optionc

Marks: 1

3267 Select proper code for given output

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JButtondemo extends JApplet implements ActionListener
{
JTextField jtf;
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JButton jb = new JButton("france");
jb.addActionListener(this);
contentPane.add(jb);
A. jb = new JButton("germany");
jb.addActionListener(this);
contentPane.add(jb);
jb = new JButton("italy");
jb.addActionListener(this);
contentPane.add(jb);
jtf = new JTextField(15);
contentPane.add(jtf);
}
public void actionPerformed(ActionEvent ae)
{
jtf.setText(ae.getActionCommand());
}
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/* <applet code="JButtondemo" width=250 height=300>
</applet> */
public class JButtondemo extends JApplet implements ActionListener
{
JTextField jtf;
public void init()
{
contentPane.setLayout(new FlowLayout());
JButton jb = new JButton("france");
jb.addActionListener(this);
contentPane.add(jb);
B. jb = new JButton("germany");
jb.addActionListener(this);
contentPane.add(jb);
jb = new JButton("italy");
jb.addActionListener(this);
contentPane.add(jb);
jtf = new JTextField(15);
contentPane.add(jtf);
}
public void actionPerformed(ActionEvent ae)
{
jtf.setText(ae.getActionCommand());
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/* <applet code="JButtondemo" width=250 height=300>
</applet> */
public class JButtondemo extends JApplet implements ActionListener
{
JTextField jtf;
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JButton jb = new JButton("france");
jb.addActionListener(this);
contentPane.add(jb);
C. jb = new JButton("germany");
jb.addActionListener(this);
contentPane.add(jb);
jb = new JButton("italy");
jb.addActionListener(this);
contentPane.add(jb);
jtf = new JTextField(15);
contentPane.add(jtf);
}
public void actionPerformed(ActionEvent ae)
{
jtf.setText(ae.getActionCommand());
}
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/* <applet code="JButtondemo" width=250 height=300>
</applet> */
public class JButtondemo extends JApplet implements ActionListener
{
JTextField jtf;
public void init()
{
Container contentPane = getContentPane();
D. contentPane.setLayout(new FlowLayout());
JButton jb = new JButton("france");
jb.addActionListener(this);
contentPane.add(jb);
jb = new JButton("germany");
jb.addActionListener(this);
contentPane.add(jb);
jb = new JButton("italy");
jb.addActionListener(this);
contentPane.add(jb);
}
}

Answer optionc

Marks: 2

3268 Select Correct code for given output

import java.io.*;
import java.lang.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class BDemo extends Applet implements ActionListener
{
String msg="";
Button large;
Label num1,num2;
TextField n1,n2;
public void init()
{
large=new Button("largest");
num1=new Label("Number1");
num2=new Label("Number2");
n1=new TextField(15);
n2=new TextField(15);
add(num1);
add(n1);
add(num2);
add(n2);
add(large);
large.addActionListener(this);
}
A.
public void actionPerformed (ActionEvent ae)
{
String str=ae.getActionCommand();
String no1=n1.getText();
String no2=n2.getText();
int a=Integer.parseInt(no1);
int b=Integer.parseInt(no2);
if(a>b)
{
msg="largest Number"+a;
}
else
{
msg="largest Number"+b;
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,100,100);
}
}
/*<Applet code="BDemo" width=300 height=300>
</Applet>*/
import java.io.*;
import java.lang.*;
import java.awt.event.*;
public class BDemo extends Applet implements ActionListener
{
String msg="";
Button large;
Label num1,num2;
TextField n1,n2;
public void init()
{
large=new Button("largest");
num1=new Label("Number1");
num2=new Label("Number2");
n1=new TextField(15);
n2=new TextField(15);
add(num1);
add(n1);
add(num2);
add(n2);
add(large);
large.addActionListener(this);
}
public void actionPerformed (ActionEvent ae)
B.
{
String str=ae.getActionCommand();
String no1=n1.getText();
String no2=n2.getText();
int a=Integer.parseInt(no1);
int b=Integer.parseInt(no2);
if(a>b)
{
msg="largest Number"+a;
}
else
{
msg="largest Number"+b;
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,100,100);
}
}
/*<Applet code="BDemo" width=300 height=300>
</Applet>*/

import java.io.*;
import java.lang.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class BDemo extends Applet
{
String msg="";
Button large;
Label num1,num2;
TextField n1,n2;
public void init()
{
large=new Button("largest");
num1=new Label("Number1");
num2=new Label("Number2");
n1=new TextField(15);
n2=new TextField(15);
add(num1);
add(n1);
add(num2);
add(n2);
C. add(large);
String str=ae.getActionCommand();
String no1=n1.getText();
String no2=n2.getText();
int a=Integer.parseInt(no1);
int b=Integer.parseInt(no2);
if(a>b)
{
msg="largest Number"+a;
}
else
{
msg="largest Number"+b;
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,100,100);
}
}
/*<Applet code="BDemo" width=300 height=300>
</Applet>*/
import java.io.*;
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
public class BDemo
{
String msg="";
Button large;
Label num1,num2;
TextField n1,n2;
public void init()
{
large=new Button("largest");
num1=new Label("Number1");
num2=new Label("Number2");
n1=new TextField(15);
n2=new TextField(15);
add(num1);
add(n1);
add(num2);
add(n2);
add(large);
large.addActionListener(this);
D. }
public void actionPerformed (ActionEvent ae)
{
String str=ae.getActionCommand();
String no1=n1.getText();
String no2=n2.getText();
int a=Integer.parseInt(no1);
int b=Integer.parseInt(no2);
if(a>b)
{
msg="largest Number"+a;
}
else
{
msg="largest Number"+b;
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,100,100);
}
}

Answer optiona

Marks: 2

Find the missing statement in the program.


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/* <applet code="AdapterDemo" width=300 height=300>
</applet> */
public class AdapterDemo extends Applet
{
public void init()
{
addMouseListener(new MyMouseAdapter(this));

}
class MyMouseAdapter extends MouseAdapter
{
AdapterDemo ad;
public MyMouseAdapter(AdapterDemo ad)
{
this.ad=ad;
3269 }
public void mouseClicked (MouseEvent me)
{
ad.showStatus("mouse clicked");
}
}
class MyMouseMotionAdapter extends MouseMotionAdapter
{
AdapterDemo ad1;
public MyMouseMotionAdapter(AdapterDemo ad1)
{
this.ad1=ad1;
}
public void mouseDragged (MouseEvent me)
{
ad1.showStatus("mouse dragged");
}
}
}

A. addMouseMotionListener(MyMouseMotionAdapter(this));

B. addMouseMotionListener(new MyMouseMotionAdapter());

C. registerMouseMotionListener(new MyMouseMotionAdapter(this));

D. addMouseMotionListener(new MyMouseMotionAdapter(this));

Answer optiond

Marks: 2

3270 select the correct syntax of URL

A. URL(String protocolName, String hostName, intport, String path)


B. URL(String protocolName, String hostName, int port)

C. URL(int port)

D. URL(URL urlObj)

Answer optiona

Marks: 2

Select proper output for the following program:-


import java.net.*;
class InetAddressTest
{
public static void main(String args[])throws UnknownHostException
{
InetAddress add=InetAddress.getLocalHost();
System.out.println(add);
3271 add=InetAddress.getByName("osborne.com");
System.out.println(add);
InetAddress sw[]=InetAddress.getAllByName("www.google.com");
for(int i=0;i<sw.length;i++)
{
System.out.println(sw[i]);
}
}
}

A. S1Q34O1.jpg

B. S1Q34O2.jpg

C. S1Q34O3.jpg

D. S1Q34O4.jpg

Answer optionc

Marks: 2

3272 URLConnection is ___________________________ and the connection object is created by invoking ____________________.

a)a general-purpose class for accessing the attributes of a remote resource


A. b) URLConnection()

a)a general-purpose class for accessing the attributes of a remote resource .


B.
b) openConnection() on a URL

a)a general-purpose class for accessing the attributes of a remote resource .


C. b)URL()

a)a general-purpose class for accessing the attributes of a remote resource .


D. b) URL(String urlSpecifier)

Answer optionb

Marks: 2

DriverManager.getConnection(_______ , ______ , ______)


3273 What are the two parameters that are included ?

A. URL or machine name where server runs, Password, User ID

B. User ID, Password, URL or machine name where server runs

C. URL or machine name where server runs, User ID, Password

D. Password, URL or machine name where server runs, User ID

Answer optionc

Marks: 2

Which statements about JDBC are true?


[i] JDBC is an API to connect to relational-, object- and XML data sources
3274 [ii] JDBC stands for Java DataBase Connectivity
[iii] JDBC is an API to access relational databases, spreadsheets and flat files
[iv] JDBC is an API to bridge the object-relational mismatch between OO programs and relational databases

A. i-true, iv-true

B. ii-true, iii-true

C. i-true, ii-true

D. iii-true, iv-true

Answer optionb
Marks: 2

JDBC facilitates to store the java objects by using which of the methods of PreparedStatement
3275 1. setObject () 2. setBlob() 3. setClob()

A. 1, 2

B. 1,2,3

C. 1,3

D. 2,3

Answer optionb

Marks: 2

Which of the following methods are main methods in life cycle of servlet?
1. init()
2. service()
3276 3. destroy()
4.stop()
5.wait()

A. 1,2,3,4,5

B. 1,2,3

C. 3,4,5

D. 1,4,5

Answer optionb

Marks: 2

To get the following output complete the below code

importjava.awt.*;
importjavax.swing.*;
/*
<applet code="jscroll" width=300 height=250>
</applet>
*/
public class jscroll extends JApplet
{
public void init()
{
3277 Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
}
}
// Add panel to a scroll pane
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPanejsp = new JScrollPane(jp, v, h);
// Add scroll pane to the content pane
contentPane.add(jsp, BorderLayout.CENTER);
}
}

JPaneljp = new JPanel();


A. jp.setLayout(new GridLayout(20, 20));

int b = 0;
for(int i = 0; i < 20; i++) {
B. for(int j = 0; j < 20; j++) {
jp.add(new JButton("Button " + b));
++b;

JPaneljp = new JPanel();


jp.setLayout(new GridLayout(3,3));
int b = 0;
C. for(int i = 0; i <3; i++) {
for(int j = 0; j <3; j++) {
jp.add(new JButton("Button " + b));
++b;

Container contentPane = getContentPane();


D. contentPane.setLayout(new BorderLayout());

Answer optionc

Marks: 2

3278 Select proper code for given output


import java.awt.*;
import javax.swing.*;
public class JTableDemo extends JApplet
{
public void init()
{
Container ContentPane=getContentPane();
ContentPane.setLayout(new BorderLayout());
final String colHeads={"emp_Name","emp_id","emp_Salary"};
final Object data={
{"Ramesh",111 , 50000},
{"sagar", 222 , 52000},
A. {"viraj", 333 , 40000 },
{"Amit", 444 , 62000 },
{"Anil", 555 , 60000 },
};
JTable table=new JTable(data,colHeads);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(table,v,h);
ContentPane.add(jsp,BorderLayout.CENTER);
}
}
/*<Applet code="JTableDemo" width=400 height=200>
</applet>*/

import java.awt.*;
import javax.swing.*;
public class JTableDemo extends JApplet
{
public void init()
{
Container ContentPane=getContentPane();
ContentPane.setLayout(new BorderLayout());
final String[]colHeads={"emp_Name","emp_id","emp_Salary"};
final Object [][] data={
{"Ramesh","111","50000"},
{"sagar","222","52000"},
B. {"viraj","333","40000"},
{"Amit","444","62000"},
{"Anil","555","60000"},
};
JTable table=new JTable(data,colHeads);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(table,v,h);
ContentPane.add(jsp,BorderLayout.CENTER);
}
}
/*<Applet code="JTableDemo" width=400 height=200>
</applet>*/

import java.awt.*;
import javax.swing.*;
public class JTableDemo extends JApplet
{
public void init()
{
Container ContentPane=getContentPane();
ContentPane.setLayout(new BorderLayout());
final String[]colHeads={"emp_Name","emp_id","emp_Salary"};
final Object [][] data={
C. {"Ramesh","111","50000"},
{"sagar","222","52000"},
{"viraj","333","40000"},
{"Amit","444","62000"},
{"Anil","555","60000"},
};
JTable table=new JTable(data,colHeads);
JScrollPane jsp=new JScrollPane(table);
ContentPane.add(jsp,BorderLayout.CENTER);
}
}

import java.awt.*;
import javax.swing.*;
public class JTableDemo extends JApplet
{
public void init()
{
Container ContentPane=getContentPane();
ContentPane.setLayout(new BorderLayout());
final String[]colHeads={"emp_Name","emp_id","emp_Salary"};
final Object [][] data={
{"Ramesh","111","50000"},
D. {"sagar","222","52000"},
{"viraj","333","40000"},
{"Amit","444","62000"},
{"Anil","555","60000"},
};
JTable table=new JTable(data,colHeads);
ContentPane.add(table,BorderLayout.CENTER);
}
}
/*<Applet code="JTableDemo" width=400 height=200>
</applet>*/

Answer optionb

Marks: 2

3279 Select proper code for given output


import java.awt.*;
class myFrame extends Frame
{
myFrame()
{ }
public static void main(String args[])
A. {
myFrame f=new myFrame();
f.setSize(200,200);
f.setName("My frame");
f.setVisible(true);
}
}

import java.awt.*;
class myFrame extends Frame
{
myFrame()
{ }
public static void main(String args[])
B. {
myFrame f=new myFrame();
f.setSize(200,200);
f.setTitle("My frame");
f.setVisible(true);
}
}

import java.awt.*;
class myApplet extends Applet
{
myFrame()
{ }
public static void main(String args[])
C. {
myFrame f=new myFrame();
f.setSize(200,200);
f.setTitle("My frame");
f.setVisible(true);
}
}

import java.awt.*;
class myFrame extends Frame
{
myFrame()
{ }
public static void main(String args[])
D. {
myFrame f=new myFrame();
f.setSize(200,200);
f.setTitle("My frame");
f.setVisible(false);
}
}

Answer optionb

Marks: 2

Debug following program and find out the error


import java.io.*;
import java.lang.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class ButtonDemoError extends Applet implements ActionListener
{

Button square;
Label num1;
TextField n1;
public void init()
{
square=new Button("square");
num1=new Label("Enter number");
n1=new TextField(15);
add(num1);
add(n1);
3280 add(square);
square.addActionListener(this);
}
public void actionPerformed (ActionEvent ae)
{
String str=ae.getActionCommand();
String no1=n1.getText();
int a=Integer.parseInt(no1);
int result=a*a;
msg="square number-"+result;
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,100,100);
}
}
/*<Applet code="ButtonDemo" width=300 height=300>
</Applet>*/

A. statement missing semicolon ;

B. Cannot find symbol ‘msg’

C. cannot accessed 'msg'


D. undefined symbol num1

Answer optionb

Marks: 2

Select the missing statement in the program for following output


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
<applet code="combodemo" width=300 height=100>
</applet>
*/
public class combodemo extends JApplet
implements ItemListener {
JLabeljl;
ImageIconfrance, germany, italy, japan;
public void init()
{
// Get content pane
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
3281 // Create a combo box and add it
// to the panel
JComboBoxjc = new JComboBox();
jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");
jc.addItemListener(this);
contentPane.add(jc);
// Create label
contentPane.add(jl);
}
public void itemStateChanged(ItemEventie) {
String s = (String)ie.getItem();
jl.setIcon(new ImageIcon(s + ".gif"));
}
}

A. jl = new JLabel("star.gif");

B. jl = new JLabel(new ImageIcon("star.gif"));

C. jl = new JLabel( ImageIcon("star.gif"));

D. JLabel(new ImageIcon("star.gif"));

Answer optionb

Marks: 2

Find the missing statement in the 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");
___________________________________________________
System.out.println("Content-type: " +uc.getContentType( ));
System.out.println("Content-encoding: "+ uc.getContentEncoding( ));
System.out.println("Date: " + new Date(uc.getDate( )));
3282 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( ));
} // end try
catch (MalformedURLException ex)
{
System.out.println("I can't understand this URL...");
}
catch (IOException ex)
{
System.err.println(ex);
}
System.out.println( );
} // end main
}

A. URLConnection uc = u.getConnection( );

B. URLConnection uc = new URLConnection();

C. URLConnection uc = u.openConnection( );

D. URLConnection uc = u.openURLConnection( );

Answer optionc

Marks: 2
Select the missing statement in the program
import java.sql.*;
import java.io.*;
public class JDBCDemo
{
public static void main(String args[])
{
try
{

Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from Student");
System.out.println("Name \t\tRollNumber \t\t Percentage");
3283 while(rs.next())
{
System.out.println(rs.getString(1) + "\t\t" + rs.getString(2) + "\t\t\t" + rs.getString(3));
}
rs.close();
st.close();
con.close();
}
catch(Exception e)
{ e.printStackTrace();
}
}
}

Class.forName("JdbcOdbcDriver");
A. Connection con = DriverManager.getConnection("jdbc:odbc:IIT");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
B. Connection con = DriverManager.getConnection("jdbc:odbc:IIT");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
C. Connection con = con.getConnection("jdbc:odbc:IIT");

forName("sun.jdbc.odbc.JdbcOdbcDriver");
D. Connection con = DriverManager("jdbc:odbc:IIT");

Answer optionb

Marks: 2

3284 Select Correct code for given output

import java.io.*;

public class EmployeeTableUpdate


{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String URL = "jdbc:odbc:EmployeeDatabase";

Connection con = DriverManager.getConnection(URL);


System.out.println("Connection to database created.");

String sql = "update Employee set Name=? where Name=?";


PreparedStatement state = con.prepareStatement(sql);
System.out.println("PreparedStatement Object Created.");

state.setString(1, "Ram");
state.setString(2, "Ramesh");
state.executeUpdate();
A. System.out.println("Entry Updated.");

System.out.println("Contents Of Database After Updating");


System.out.println("NAME\tAGE");
sql = "select * from Employee";
state = con.prepareStatement(sql);
ResultSet results = state.updateQuery();
String text = "" ;
while(results.next())
{
text += results.getString(1) + "\t" + results.getInt(2) + "\n";
}

System.out.println(text);
state.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
import java.sql.*;

public class EmployeeTableUpdate


{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String URL = "jdbc:odbc:EmployeeDatabase";

Connection con = DriverManager.getConnection(URL);


System.out.println("Connection to database created.");

String sql = "update Employee set Name=? where Name=?";


Statement state = con.createStatement(sql);
System.out.println("PreparedStatement Object Created.");

state.setString(1, "Ram");
state.setString(2, "Ramesh");
state.executeUpdate();
B. System.out.println("Entry Updated.");

System.out.println("Contents Of Database After Updating");


System.out.println("NAME\tAGE");
sql = "select * from Employee";
state = con.Statement(sql);
ResultSet results = state.executeQuery();
String text = "" ;
while(results.next())
{
text += results.getString(1) + "\t" + results.getInt(2) + "\n";
}

System.out.println(text);
state.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

import java.sql.*;

public class EmployeeTableUpdate


{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
String URL = "jdbc:odbc:EmployeeDatabase";

Connection con = DriverManager.getConnection(URL);


System.out.println("Connection to database created.");

String sql = "update Employee set Name=? where Name=?";


PreparedStatement state = con.prepareStatement(sql);
System.out.println("PreparedStatement Object Created.");

state.setString(1, "Ram");
state.setString(2, "Ramesh");
state.executeUpdate();
System.out.println("Entry Updated.");
C.
System.out.println("Contents Of Database After Updating");
System.out.println("NAME\tAGE");
sql = "select * from Employee";
state = con.prepareStatement(sql);
ResultSet results = state.executeQuery();
String text = "" ;
while(results.next())
{
text += results.getString(1) + "\t" + results.getInt(2) + "\n";
}

System.out.println(text);
state.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
import java.sql.*;

public class EmployeeTableUpdate


{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded");
Connection con = DriverManager.getConnection(URL);
System.out.println("Connection to database created.");

String sql = "update Employee set Name=? where Name=?";


PreparedStatement state = con.prepareStatement(sql);
System.out.println("PreparedStatement Object Created.");

state.setString(1, "Ram");
state.setString(2, "Ramesh");
state.executeUpdate();
System.out.println("Entry Updated.");
D.
System.out.println("Contents Of Database After Updating");
System.out.println("NAME\tAGE");
sql = "select * from Employee";
state = con.prepareStatement(sql);
ResultSet results = state.executeQuery();
String text = "" ;
while(results.next())
{
text += results.getString(1) + "\t" + results.getInt(2) + "\n";
}

System.out.println(text);
state.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

Answer optionc

Marks: 2

3285 Triggers ___________________________

A. are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table.

B. can be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.

C. are not generally used to implement business rules, auditing

D. can not also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constrain

Answer optiona

Marks: 2

To create a DSN we would be required to follow some basic steps. complete the missing steps :
[Here using the MS-Access as database system. Before creating DSN to use MS-Access with JDBC technology the database file should be
created in advance.]
1] First step is to go through the Control Panel -> Administrative Tools -> Data Sources (ODBC).
3286 2]
3] In the next step a dialog box ODBC Microsoft Access Setup will be opened then provide the field's values corresponding to the
field's label (i.e. provide the DSN name as you wish) and then click on the "Select" button.
4] In the next step a new dialog box "Select database" will be opened. Here you have to select the directory where you have stored
your file and provide the name in the place of the Database Name and then press ok -> ok -> ok.

A. Go to the tab Uer DSN in the ODBC Data Source Administrator dialog box then, Click on Add button -> select Microsoft dBase Diver (*.dbf) -> click on Finish

B. Go to the tab System DSN in the ODBC Data Source Administrator dialog box then, Click on Add button -> click on Finish button.

C. Go to the tab System DSN in the ODBC Data Source Administrator dialog box then, Click on Add button -> select MS Access Driver (*.mdb) -> click on Finish b

D. Go to the tab File DSN in the ODBC Data Source Administrator dialog box then, Click on Add button -> select MS Access Driver (*.mdb) -> click on Finish but

Answer optionc

Marks: 2

3287 Why cannot java.util.Date match with java.sql.Date?

Because java.util.Date represents both date and time. SQL has three types to represent date and time.
java.sql.Date -- (00/00/00)
A. java.sql.Time -- (00:00:00)
java.sql.Timestamp -- in nanoseconds

B. Because java.util.Date represents date . And java.sql.Date represent time.

C. both formats are different

D. none
Answer optionb

Marks: 2

Select the missing statement in the program for following output


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException
3288 {
String data = request.getParameter("data");
Cookie cookie = new Cookie("MyCookie", data);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
} }

A. request.addCookie(cookie);

B. response.addCookie(cookie);

C. Both of the above.

D. None

Answer optionb

Marks: 2

3289 . _____________ pane can be used to add component to container

A. � GlassPane

B. CotentPane

C. Container

D. � � All of above

Answer optionb

Marks: 1

3290 Which layout manager places components in one of five regions: north, south, east, west, and center?

A. AbsoluteLayout

B. GridLayout

C. BorderLayout

D. FlowLayout

Answer optionc

Marks: 1

3291 The setBackground() method is a part of the following class in java.awt package:

A. Container

B. Applet

C. Object

D. Graphics

Answer optiond

Marks: 1

3292 Which of these are integer constants defined in ActionEvent class?

A. ALT_MASK

B. CTRL_MASK

C. SHIFT_MASK

D. All of above

Answer optiond
Marks: 1

3293 From following which methods are of MouseMotionListener

A. mouseDragged() and mouseMoved()

B. mouseDragged() and mouseClicked()

C. mouseClicked() and mouseMoved()

D. mouseEntered() and mouseExited()

Answer optiona

Marks: 1

__________________ methods returns size in bytes of contents assosiated with resource in URLConnection class.
3294

A. int getContentLength()

B. String getContentlength()

C. long getContentLength()

D. byte getContentLength()

Answer optiona

Marks: 1

3295 java.security.Permission this statement represent access to_____________________

A. Database

B. system resources

C. program

D. package

Answer optionb

Marks: 1

3296 Disadvantage of Type 1 jdbc-odbc driver is__________________________

A. Easy to use

B. It is free, no charges

C. Dependent on ODBC driver

D. easy connectivity

Answer optionc

Marks: 1

3297 what is return type of execute() method?

A. object of ResultSet class

B. integer

C. void

D. object of Connection class

Answer optiona

Marks: 1

3298 what is return type of executeUpdate() method?

A. object of ResultSet class

B. integer

C. void
D. object of Connection class

Answer optionb

Marks: 1

3299 Which five interfaces are there in javax.servlet package?

A. Servlet,ServletConfig,ServletContext, ServletRequest,ServletResponse,SingleThreadModel

B. Servlet,ServletConfig,ServletContext, ServletReq, ServletResponse

C. Request,Servlet,ServletConfig,ServletContext, ServletReq

D. RequestDispatcher,Servlet,ServletConfig,ServletContext, ServletR

Answer optiona

Marks: 1

3300 Life cycle of servlet consists of ____________________________

A. init(), service() ,destroy(), methods

B. init(), disable(), start()

C. destroy(), start(),close()

D. init(), paint(), start()

Answer optiona

Marks: 1

3301 Cookie is simplest technique of maintaining ______________

A. interface information

B. state information

C. class information

D. object information

Answer optionb

Marks: 1

3302 The syntax of setLayout() method is _________________

A. void setLayout()

B. public void setLayout()

C. public void setLayout(int left, int right)

D. public void setLayout(LayoutManager object)

Answer optiond

Marks: 2

3303 Which is the constructer of Frame class?

A. void Frame()

B. public setframe()

C. public Frame(String title)

D. void Frame(String tiltle)

Answer optionc

Marks: 2

3304 Which is a method of Checkbox class?

A. public String getLabel()

B. public String setLabel()


C. public boolean retriveLabel()

D. a & c

Answer optiona

Marks: 2

3305 Match 1, 2, 3 with a, b, c from following: 1 Button 2 Checkbox 3 Scrollbar a. ItemListener b. ActionListener c. AdustmentListener

A. 1-a, 2-b,3-c

B. 1-b, 2-c, 3-a

C. 1-c, 2-a, 3-b

D. 1-b, 2-a, 3-c

Answer optiond

Marks: 2

3306 For handling List, Checkbox related event, ___________ must be implemented

A. ActionListener interface

B. ActionEvent interface

C. ItemListener interface

D. None of the above

Answer optionc

Marks: 2

3307 What is return type of getAddress() instance method of InetAddress class?

A. byte[]

B. int

C. float

D. String

Answer optiona

Marks: 2

3308 Which method is needed to retrive IP address of local machine

A. getByName()

B. getAllByName()

C. getLocalHost()

D. getLocal()

Answer optionc

Marks: 2

3309 Advantages of Type4 driver are

A. Completely written in Java and no need of ODBC

B. Completely written in Java and need of ODBC

C. Partially written in java and ODBC is needed

D. ODBC and JDBC are to be installed

Answer optiona

Marks: 2

3310 Which of the following is true about HTTP Post method?

A. POST method sends encoded user information as a seperate message to page request
B. The POST method is used to submit form data normally.

C. Both of above

D. None of above

Answer optionc

Marks: 2

3311 When sevice() method gets called?

A. The service() method is called when the servlet is first created

B. The service() method is called whenever the servlet is invoked.

C. Both of above

D. None of above

Answer optionb

Marks: 2

Debug the given program so as to get the following output


import java.awt.*; import javax.swing.*; /*<applet code="test" width=200 height=200> </applet>*/
public class test extends JApplet { public void init(){ Container c=getContentPane();JTabbedPane jp=new JTabbedPane(); JButton
3312 b1=new JButton("COMP.TECH"); p1.add(b1); JButton b2=new JButton("INFO.TECH"); p1.add(b2); JButton b3=new JButton("ELEC.ENGG");
p1.add(b3); JButton b4=new JButton("FIRST"); p2.add(b4); JButton b5=new JButton("SECOND"); p2.add(b5); JButton b6=new
JButton("THIRD"); p2.add(b6); jp.addTab("Branch",p1); jp.addTab("Year",p2); c.add(jp); } }

A. � JPanel p2=new JPanel();JButton b3=new JButton("ELEC.ENGG");

B. JPanel p2=new JPanel(); JPanel p1=new JPanel();

� � � � /*<applet code="test" width=200 height=200> </applet>*/


C.

D. jp.addTab("Branch");jp.addTab("Year");

Answer optionb

Marks: 2

3313 Select proper code/program from given options

import java.awt.*;
import java.applet.*;
public class layoutdemo extends Applet
{
Button left,right,top,bottom;
public void init()
{
left = new Button("left");
right = new Button("right");
A. top = new Button("top");
bottom = new Button("bottom");
BorderLayout b = new BorderLayout();
setLayout(b); add(left,BorderLayout.EAST);
add(right,BorderLayout.WEST);
add(top,BorderLayout.NORTH);
add(bottom,BorderLayout.SOUTH);
}
}
/* <APPLET CODE ="layoutdemo.class" HEIGHT=100 WIDTH=200></APPLET>*/

import java.awt.*;
import java.applet.*;
public class app2 extends Applet
{

public void init()


{
Button b1=new Button("b1");
Button b2=new Button("b2");
Button b3=new Button("b3");
B. Button b4=new Button("b4");
Button b5=new Button("b5");
setLayout(new GridLayout());
add(b1);add(b2);add(b3);add(b4);
add(b5);
}
}
/*<applet code=app2.class height=300 width=300>

</applet>*/
import java.awt.*;
public class MenuDemo extends Frame
{
public static void main(String args[])
{
MenuDemo m = new MenuDemo();
m.setVisible(true);
MenuBar mbr = new MenuBar();
m.setMenuBar(mbr);
//Creating menus
Menu filemenu = new Menu("File");
Menu editmenu = new Menu("Edit");
C. Menu viewmenu = new Menu("View");
// Adding Menus to Menubar
mbr.add(filemenu);
mbr.add(editmenu);
mbr.add(viewmenu);
// CreatingmenuItem for file menu.
MenuItem new1 = new MenuItem("New");
MenuItem open1 = new MenuItem("Open");
//Adding these to the Filemenu
filemenu.add(new1);
filemenu.add(open1);
} }

import java.awt.*;
import java.applet.*;
import java.util.*;
/*
<applet code = BorderLayoutDemo width = 400 height = 200>
</applet>
*/
public class BorderLayoutDemo extends Applet
{
public void init()
{
D. setLayout(new BorderLayout());

add(new Button("Header Portion"), BorderLayout.NORTH);


add(new Button("Footer Portion"), BorderLayout.SOUTH);
add(new Button("Right"), BorderLayout.EAST);
add(new Button("Left"), BorderLayout.WEST);

String msg = "Advanced Java Programming";


add(new TextArea(msg), BorderLayout.CENTER);
}
}

Answer optiona

Marks: 2

Identify proper output from given options import java.awt.*;


import java.awt.event.*;
import java.applet.*;
/*<applet code=tan7.class height=400 width=400></applet>*/
public class tan7 extends Applet implements ActionListener
{
Label l1,l2,l3;
TextField t1,t2,t3;
Button b1;
public void init()
{
l1=new Label("Enter Number: ");
l2=new Label("Enter Number: ");
l3=new Label("Result");
t1=new TextField();
t2=new TextField();
t3=new TextField();
b1=new Button("Largest");
GridLayout g=new GridLayout(4,2);
setLayout(g);
3314
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
int n1=Integer.parseInt(t1.getText());
int n2=Integer.parseInt(t2.getText());
if(n1>n2)
{
t3.setText(Integer.toString(n1));
}

A. S1Q48O1.jpg

B. S1Q48O2.jpg

C. S1Q48O3.jpg

D. S1Q48O4.jpg

Answer optiona

Marks: 2

3315 Identify proper syntax of actionPerformed() and keyPressed() method


A. void ActionPerformed() and void KeyPressed()

B. void actionPerformed(ActionEvent ae) and void keyPressed(KeyEvent e)

C. int actionPerformed(ActionEvent ae) and int keyPressed(KeyEvent e)

D. void ActionPerformed(actionevent ae) and void KeyPressed(keyevent e)

Answer optionb

Marks: 2

Select proper statements for implementing following: 1. Create JChekbox with name Pune 2. one user clicks on it message will be
3316 displayed as "You have selected Pune"

JCheckBox c1= new JCheckBox("Pune");public void itemStateChanged(ItemEvent ie){ c1 = (JCheckBox)ie.getItem();


A. if(c1.isSelected())
jlab.setText(cb.getText() + " is selected");}

B. public void actionPerformed(ActionEvent ae)

CheckBox c1= new CheckBox("Pune");public void itemStateChanged(ItemEvent ie){ c1 = (JCheckBox)ie.getItem();


C. if(c1.isSelected())
jlab.setText(cb.getText() + " is selected");}

JCheckBox c1= new JCheckBox("Pune");public void actionPerformed(ItemEvent ie){ c1 = (JCheckBox)ie.getItem();


D. if(c1.isSelected())
jlab.setText(cb.getText() + " is selected");}

Answer optiona

Marks: 2

Select proper statements for implementing following: 1. Create the server Socket and begin listing 2. Creat the client socket for
3317 connection

1. ServerSocket ss=new ServerSocket(5555);


A. Socket s1=ss.accept();
2. Socket s= new Socket(“111.112.1.113”, 5555);

B. if(ae.getSource()==b1)

1. Socket s= new Socket(“111.112.1.113”, 5555);


C. 2. ServerSocket ss=new ServerSocket(5555);
Socket s1=ss.accept();

D. 1.Socket s1=ss.accept(); 2. socket s

Answer optiona

Marks: 2

3318 Difference between Statement and PreparedStatement interface is

A. Statement interface is used for dyamaic Query and preparedStatement interface is used for static query

B. Both have same.

C. Statement interface is used for Static Query and preparedStatement interface is used for static query

D. both are useful for connection with JDBC

Answer optionc

Marks: 2

Select proper statements for implementing following: 1. Load the driver for JDBC
3319 2.Established the connection with the database by using getConnection() method of DriverManager class.
3.Create SQL statement

1. Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
System.out.println(“driver loaded”);
2.String url=”jdbc:odbc:insert1”;
Connection con=DriverManager.getConnection(url);
A. System.out.println(“connection created”);
3.int r1=11,r2=22;
String s1=”madras”,s2=”delhi”;
String str=”insert into if6g values(?,?)”;

B. int n1=Integer.parseInt(t1.getText());

1. Class.forName(“sun.jdbc.odbc”);
System.out.println(“driver loaded”);
2. String url=”jdbc:odbc:insert1”;
Connection con=getConnection(url);
C. System.out.println(“connection created”);
3. int r1=11,r2=22;
String s1=”madras”,s2=”delhi”;
String str=”insert into if6g values(?,?)”;
1.int r1=11,r2=22;
String s1=”madras”,s2=”delhi”;
String str=”insert into if6g values(?,?)”;
2. String url=”jdbc:odbc:insert1”;
D. Connection con=getConnection(url);
System.out.println(“connection created”);
3. Class.forName(“sun.jdbc.odbc”);
System.out.println(“driver loaded”);

Answer optiona

Marks: 2

3320 Write a SQL query to delete name= "ABC" from studentInfo table and write a code to execute it with JDBC

A. String sql = "delete * from StudInfo where Name = 'ABC' ";

B. if(n1>n2)

Statement state = con.createStatement();


System.out.println("Statement Object Created.");
C. String sql = "delete * from StudInfo where Name = 'ABC' ";
state.executeUpdate(sql);
System.out.println("Entry Deleted.");

D. state.executeUpdate(sql);

Answer optionc

Marks: 2

3321 Identify proper syntax of execute(), excuteUpadate() and excuteQuery() method

A. public ResultSet executeQuery(String sql)throws SQLException , int executeUpdate(String sql)throws SQLException , boolean execute(String SQL)

B. int execute(String SQL)

C. public ResultSet executeQuery(String sql)throws SQLException

D. Int executeUpdate(String sql)throws SQLException , boolean execute(String SQL)

Answer optiona

Marks: 2

What is output of code given in program:


import java.servlet.*;
import java.servlet.http*;
import java.io.*;
public class Registers extends HTTPServlet
{
public void doGet(HTTPServletRequest res, HTTPServletResponse res)throws ServletException, IOException
{
String F1=res.getParameter(�First�);
String L1=res.getParameter(�Last�);
res.getContentType(�text\html�);
PrintWriter pw=res.getWriter();
pw.println(�The centered name is:�);
pw.println(F1 + � � +F1);
3322 pw.close();
}
}
HTML code
<html>
<body>
<form action="Registers" method="GET">
First Name: <input type="text" name="first_name">
<br />
Last Name: <input type="text" name="last_name" />
<input type="submit" value="Submit" />
</form>
</body>
</html>

A. Enter First and Last Name and then click submit button to see the result on your local machine where tomcat is running.

B. }

C. Enter First and Last Name to see the result on your local machine where tomcat is running.

D. Enter Last Name and then click submit button to see the result on your local machine where tomcat is running.

Answer optiona

Marks: 2

What is meaning of following code:


public void doGet(HTTPServletRequest res, HTTPServletResponse res)throws ServletException, IOException
{
3323 String F1=res.getParameter(�First�);
String L1=res.getParameter(�Last�);
res.getContentType(�text\html�);
A. 1. get the value of request parameter names First and Last 2.set response type as text\html

B. 1. set the value of request parameter names First and Last 2.get response type as text\html

C. 1. display parameter names First and Last 2.set response type as text\html

D. 1. display text boxes for parameter names First and Last 2.set response type as text\html

Answer optiona

Marks: 2

What is output of following code:


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class AddCookieServlet extends HttpServlet


{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
3324 String data = request.getParameter("data");
Cookie cookie = new Cookie("MyCookie", data);
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. this code will add Cookie named MyCookie

B. this code will delete Cookie named MyCookie

C. this will only create Cookie

D. this will destroy Cookie

Answer optiona

Marks: 2

3325 The AWT container is an instance of the ___________ class which holds various components and other containers

A. Graphics

B. Container

C. Event object

D. none of the above

Answer optionb

Marks: 1

3326 Which method is used to set the text of a Label object?

A. setText()

B. setLabel()

C. setTextLabel()

D. setLabelText()

Answer optiona

Marks: 1

3327 Which of the following are true?

A. Window extends Frame

B. Applet extends Window.

C. Panel extends Container.

D. ScrollPane extends Panel.

Answer optionc

Marks: 1

3328 Which of the following components generate action events?


A. Button

B. Label

C. Check box

D. Both A & B

Answer optiona

Marks: 1

3329 _______ method causes the policy object to refresh its current configuration

A. void refresh()

B. int refresh()

C. boolean refresh()

D. float refresh()

Answer optiona

Marks: 1

3330 Which of the following is a prepared statements ?

A. Insert into department values(?,?,?)

B. Insert into department values(x,x,x).

C. SQLSetConnectOption (conn, SQL AUTOCOMMIT, 0)

D. SQLTransact (conn, SQL ROLLBACK)

Answer optiona

Marks: 1

3331 Which of the following invokes functions in sql ?

A. Prepared Statements

B. Connection statement

C. Callable statements

D. All of these

Answer optionc

Marks: 1

3332 What are the correct statements about filter?

A. It checks Security

B. It modifies the request or response

C. It is used for Logging and auditing

D. All of these

Answer optiond

Marks: 1

3333 Which of these exception is thrown by URL class�s constructors?

A. URLNotFound

B. URLSourceNotFound

C. MalformedURLException

D. URLNotFoundException

Answer optionc

Marks: 2
Which of the following is used to access the database server at time of executing the program and get the data from the server
3334 accordingly ?

A. Embedded SQL

B. Dynamic SQL

C. SQL declarations

D. SQL data analysis

Answer optionb

Marks: 2

3335 A user types the URL http://www.withoutbook.com/Blog.php . Which HTTP request gets generated. Select the one correct answer.

A. GET method

B. POST method

C. HEAD method

D. PUT method

Answer optiona

Marks: 2

Which error should occur if we run the following code


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
/*
<applet code="commmand1.class" width=300 height=100>
</applet>
*/
public class combodemo11 extends JApplet
{
3336 public void init()
{
Container co = getContentPane();
co.setLayout(new FlowLayout());
JComboBoxjc=new JComboBox();
jc.addItem("cricket");
jc.addItem("football");
jc.addItem("hockey");
jc.addItem("tennis");
co.add(jc);
}
}

A. A. Compile time error

B. B. Run time error

C. C. Error on applet initialization

D. D. All of above

Answer optiond

Marks: 2

Where the panel add on frame?


import java.awt.*;
public class CompLay extends Frame{
CompLay(){
Panel p = new Panel();
p.add(new Button("One"));
p.add(new Button("Two"));
p.add(new Button("Three"));
3337 add("South",p);
setLayout(new FlowLayout());
setSize(300,300);
setVisible(true);
}
public static void main(String argv[]){
CompLay cl = new CompLay();
}
}

A. A.On left side of Frame

B. B.On Right side of Frame

C. C.On Upper side of Frame

D. D. On Bottom side of Frame

Answer optiond
Marks: 2

Select the missing statement in the program


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class combodemo extends JApplet


implementsItemListener
{
JLabeljl;
ImageIconfrance, germany, italy, japan;
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
3338 JComboBoxjc = new JComboBox();
jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");
jc.addItemListener(this);
contentPane.add(jc);
contentPane.add(jl);
}
public void itemStateChanged(ItemEventie)
{
String s = (String)ie.getItem();
jl.setIcon(new ImageIcon(s + ".gif"));
}
}

A. Package defination

/*
<applet code="combodemo" width=300 height=100>
B. </applet>
*/

C. Class declaration

D. JLabel(new ImageIcon("star.gif"));

Answer optionb

Marks: 2

1.Which line of code is missing in following code and error statement code line
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="KeyEventDemo.class" width=400 height=400>
</applet>*/
public class KeyEventDemo extends Applet implements _____________
{
String msg="";
public void init()
{
addKeyListener(this);
}
public void keyPressed(KeyEvent e)
{
3339
showStatus("Key Down");
int key=e.getKeyCode();
repaint();
}
public void keyTyped(KeyEvent e)
{
msg+=e.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,10,20);
}
}

a) MouseListener and public void keyShow(KeyEvent e)


{
A. showStatus("Key up");
} and

b)KeyListener and public void keyReleased(KeyEvent e)


{
B. showStatus("Key up");
}

c) MouseListener and public void keyMoved(KeyEvent e)


{
C. showStatus("Key up");
}

D. d)None of this

Answer optionb

Marks: 2
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.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," ");
Statement s=c.createStatement();
3340 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();
}
}

A. Missing semicolon

B. Missing {

C. Missing }

D. Missing statement.

Answer optiond

Marks: 2

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.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:MyDSN","","");
PreparedStatement s=c.prepareStatement( "update db3 set Name=? where Roll_no=?");
Statement s=c.createStatement( );
s.setString(1,args[0]);
3341 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.getDouble(3));
}
s.close();
c.close();
}
}

A. s.executeUpdate()

B. c.createStatement( )

C. s.close()

D. c.close()

Answer optiona

Marks: 2

Consider the following program and identify the missing statement.


public class HelloWorld extends HttpServlet {

private String message;

public void init() throws ServletException


{
message = "Hello World";
}

public void doGet(HttpServletRequest request,


HttpServletResponse response)
3342 throws ServletException, IOException
{
response.setContentType("text/html");

PrintWriter out = response.getWriter();


out.println("<h1>" + message + "</h1>");
}

public void destroy()


{
}
}

A. Missing semicolon

B. Missing package statement

C. Missing initialization
D. None of the above

Answer optionb

Marks: 2

In following Java program fill statement showing ***.Select any one option from given options

import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookieServlet extends HttpServlet
{
public void doPost(*****,*****)
throwsServletException, IOException
{
3343 String data = request.getParameter("data");
Cookie cookie = new Cookie("MyCookie", data);
response.addCookie(cookie);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>MyCookie has been set to");
pw.println(data);
pw.close();
}
}

A. request.getParameter("HttpServletRequest)

B. HttpServletRequest request, HttpServletResponse response

C. request.getHeaderNames()

D. response.getWriter()

Answer optionb

Marks: 2

You might also like