0% found this document useful (0 votes)
8 views

ajpqb_syllabus

The document contains a series of questions related to Java programming, specifically focusing on AWT, Swing, JDBC, and applet development. It includes questions about components, methods, event handling, and code corrections. The questions are structured in a quiz format, likely intended for assessing knowledge in Java programming concepts.

Uploaded by

sayalipawar757
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

ajpqb_syllabus

The document contains a series of questions related to Java programming, specifically focusing on AWT, Swing, JDBC, and applet development. It includes questions about components, methods, event handling, and code corrections. The questions are structured in a quiz format, likely intended for assessing knowledge in Java programming concepts.

Uploaded by

sayalipawar757
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 75

Sr. No.

Question
Which class can be used to represent the Checkbox with a textual label that can
appear in a menu?
1
Which are various AWT controls from following?

2
3 JPanel and Applet use ___________________ as their default layout
Which of the following is true about AWT and Swing Component?

4
5 Which of these methods cannot be called on JLabel object?
6 _____________ pane can be used to add component to container
7 Which of the following is not a constructor of JTree
Swing Components are_______________________
8
Which of these methods is used to obtain the object that generated a WindowEvent?
9
10 Which of these methods is used to get x coordinate of the mouse?
Which of these are constants defined in WindowEvent class?
11
12 Which of these is super class of WindowEvent class?
Which of these is a return type of getAddress method of DatagramPacket class?
13
14 In the format for defining the URL what is the last part?
15 What is the first part of URL address?
Which of these methods of DatagramPacket is used to obtain the byte array of data
contained in a datagram?
16
Native – protocol pure Java converts ……….. in to the ………… used by DBMSs directly.
17
18 The JDBC-ODBC bridge driver resolves……….. and makes equivalent ………..
For execution of DELETE SQL query in JDBC, ............. method must be used.
19
20 Prepared Statement object in JDBC used to execute........... queries.
Name the class that includes the getSession() method that is used to get the
HttpSession object
21
A user types the URL http://www.msbte.com/result.php. Which HTTP request gets
generated? Select the one correct answer
22
Which of these is a protocol for breaking and sending packets to an address across a
network?
23
in a web application, running in a webserver, who is responsible for creating request
and response object
24
Which components are used in the following output? Y
25
What is the purpose of JTable?

26
Which method is used to display icon on a component?
27
What components will be needed to get following output? Y
28
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.";
repaint();
}
public void mousePressed(MouseEvent me)
29 {
Select the proper output for following code Y
importjava.awt.*;
importjava.applet.*;
public class list2 extends Applet
{
public void init()
{
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>*/

30
To get the following output complete the code given below. Y

import java.awt.*;
import javax.swing.*;
/*
<applet code="jscroll" width=300 height=250>
</applet>
*/
public class jscroll extends JApplet
{
public void init()
{
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);
}
}

31
Select the proper method to retrieve the host name of local machine

32
Select the proper constructor of URL class

33
Select the proper constructor of serversocket
34
What will be displayed in the output?
import java.net.*;
classmyAddress
{
public static void main (String args[])
{
try
{
InetAddress address = InetAddress.getLocalHost();
System.out.println(address);
}
catch (UnknownHostException e)
{
System.out.println("Could not find this computer's address.");
}
}
}

35
36 executeQuery() method returns_____________________
37 PreparedStatement interface extends____________________ interface
38 executeUpdate() method returns_____________________
Identify correct syntax of service() method of servlet class

39
Advantage of JSP over Servlet is____________

40
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.
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

41
Choose the correct sequence for the following output Y

42
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" };
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);
}
}

43
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()
{
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);
}
}

44
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));
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?

45
Select proper code for given output Y

46
Select the missing statement in the program to get the following output Y

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();
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"));
}
}

47
Select the missing statement in the program for following output Y
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");
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);
}
}

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

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();
}
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);
}
}
49
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);
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>*/

50
Consider the following program
What will be displayed in the output?

import java.net.*;
class myAddress
{
public static void main (String args[])
{
try
{
InetAddress address = InetAddress.getLocalHost();
System.out.println(address);
}
catch (UnknownHostException e)
{
System.out.println("Could not find this computer's address.");
}
}
}

51
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
{
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());
}
}

52
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();
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();
}
}

53
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();
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();
}
}

54
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();
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();
}
}

55
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();
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();
}
}

56
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]);
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();
}
}

57
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");
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);
}
}

58
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
{
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();
}
}

59
Consider the following program. Identify the exception that might be thrown

import java.net.*;
class URLDemo
{
public static void main(String args[]) throws ______________________
{
URL netAddress= new URL(“http://www.sun.com:8080//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());
}
}

60
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());
System.out.println(“File :”+netAddress.getFile());
}
}

Output of the Program


Protocol :http
Host :www.sun.com
File :/index.html

61
Consider the following program and identify the missing statement.

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());
System.out.println("File :"+netAddress.getFile());
}
}

62
Option A B C D
MenuBar MenuItem CheckboxMenuItem Menu

Labels, Push buttons, Text components, Labels, Strings, JSP, Push buttons, Servelts,
Check boxes, Choice lists Threads, Strings, Netbeans, Sockets Notepad, JSP
Servelts, Vectors

FlowLayout GridLayout BorderLayout GridBagLayout


AWT Components create AWT Components create Both AWT and Swing Both AWT and Swing
a process where as a thread where as Swing Component create a Component create a
Swing Component create Component create a process thread
a thread process

setIcon() getText() setLabel() setBorderLayout()


Glass Cotent Container All of above
JTree(Object obj[]) JTree(TreeNodetn) JTree(Vector v) JTree(int x)
Platform dependent Platform Independent Both a & b Platform oriented

getMethod() getWindow() getWindowEvent() getWindowObject()

getX() getXCoordinate() getCoordinateX() getPointX()


WINDOW_ACTIVATED WINDOW_CLOSED WINDOW_DEICONIFIED All of the mentioned

WindowEvent ComponentEvent ItemEvent InputEvent


DatagramPacket DatagramSocket InetAddress ServerSocket

Protocol File path Port number Host name


Host name Port number File path Protocol
getData() getBytes() getArray() recieveBytes()

JDBC calls, network ODBC class, network ODBC class, user call JDBC calls, user call
protocol protocol
JDBC call, ODBC call ODBC call, ODBC call ODBC call, JDBC call JDBC call, JDBC call
executeQuery() executeDeleteQuery() executeUpdate() executeDelete()

Executable Simple High level Parameterized


HttpServletRequest HttpServletResponse SessionContext SessionConfig

GET method POST method HEAD method PUT method

TCIP/IP DNS Socket Proxy Server

Web server Servlet Container Client

Label, TextField, Button Applet, Label Applet, Button Grid Layout, Label,
Button
JTable object displays JTable object displays JTable object displays JTable object displays
rows of data. columns of data rows and columns of data in Tree form.
data.

rollOverIcon(ImageIcon setIcon(ImageIcon i) displayIcon(ImageIcon i) removeIcon


i) (ImageIconi )
Label, TabbedPane, TabbedPane, List, Applet Panel, TabbedPane, List Applet, TabbedPane,
CheckBox Panel
addMouseMotionListene addMouseListener(this); import java.awt.event.*; all of above
r(this);
Container contentPane = JPaneljp = new JPanel(); int b = 0; JPaneljp = new JPanel();
getContentPane(); jp.setLayout(new for(int i = 0; i < 20; i++) { jp.setLayout(new
contentPane.setLayout(n GridLayout(20, 20)); for(int j = 0; j < 20; j++) { GridLayout(3,3));
ew GridLayout()); jp.add(new int b = 0;
JButton("Button " + b)); for(int i = 0; i <3; i++)
++b; {
for(int j = 0; j <3; j++)
{
jp.add(new
JButton("Button " + b));
++b;
static static static InetAddress[ ] string getHostAddress()
InetAddressgetLocalHost InetAddressgetByName( getAllByName(String
( )throws String hostName)throws hostname throws
UnknownHostException UnknownHostException UnknownHostException

URL(String URL(String urlSpecifier) URL(String All of above


protocolName, String protocolName, String
hostName, intport, hostName, String path)
String path)

ServerSocket(intport, Socket(InetAddressipAd Socket(int port) ServerSocket()


intmaxQueue) dress, intport)
The internet address of The internet address of The internet address of The internet address of
the server the client the host any other PC

Single row ResultSet object Single Column Database Table


Connection Statement ResultSet Driver
Single row ResultSet object Integer Single Column
void void void void
service(ServletRequestre service(ServletResponse service(ServletRequestre service(ServletResponser
q, ServletResponse res) res ServletRequestreq, ) q, ServletRequestreq ) eq, ServletResponse res)

JSP is web page and JSP is web page scripting JSP is web page scripting JSP is program and
servlets are Java language and servlets language and servlets servlets are scripting
programs are Java programs are simple programs language
All above are valid Only A and B Only C and D A, B, C are valid
differences differences.

importjava.awt.*; importjava.awt.*; importjava.awt.*; All of above


importjava.applet.*; importjava.applet.*; importjava.applet.*;
public class app1 public class app1 public class app1
extends Applet extends Applet extends Applet
{ { {
public void init() public void init() public void init()
{ { {
TextFieldtf = new TextFieldtf = new TextFieldtf = new
TextField(); TextField(); TextField();
TextArea t1=new TextArea t1=new TextArea t1=new
TextArea(3,20); TextArea(3,20); TextField();
Checkbox c=new Checkbox c=new Checkbox c=new
Checkbox("a",true); Checkbox("a",true); Checkbox("a",true);
Checkbox c1=new Checkbox c1=new Checkbox c1=new
Checkbox("b",false); Checkbox("b",false); Checkbox("b",false);
add(t1); add(tf); add(tf);
add(c); add(t1); add(t1);
add(tf); add(c); add(c);
add(c1); add(c1); add(c1);
} } }
} } }
/*<applet /*<applet
code=app1.class code=app1.class
width=200 height=200> width=200 height=200>
</applet>*/ </applet>*/
Error in statement in Error in statement in Error in statement in None of the above
which JTable is created which JScrollPane is which applet tag is
created declared
Javac java combodemo11 appletviewer All of above
combodemo11.java combodemo11.java
The output is obtained in The output is obtained in The output is obtained in The output is obtained in
Frame with two layouts: Applet with two layouts: Applet with two layouts: Applet with two layouts:
Frame layout and Flow Frame layout and Flow Frame layout and Border Border layout and Flow
Layout. Layout. Layout. Layout.
importjava.awt.*; importjava.awt.*; importjava.awt.*; importjava.awt.*;
importjava.applet.*; importjava.applet.*; importjava.applet.*; importjava.applet.*;
public class choice11 public class choice11 public class choice11 public class choice11
extends Applet extends Applet extends Applet extends Applet
{ { { {
public void init() public void init() public void init() public void init()
{ { { {
Choice os=new Choice(); Choice os=new Choice(); Choice os=new Choice(); Choice os=new Choice();
os.add("wnn18"); os.add("wnn18"); os.add("wnn18"); os.add("wnn18");
os.add("wnnxp"); os.add("wnnxp"); os.add("wnnxp"); os.add("wnnxp");
os.add("wnnnt"); add(os); os.add("wnnnt"); os.add("wnnnt");
os.add("win 2000"); } os.add("win 2000"); os.add("win 2000");
add(os); } add(os); }
} /*<applet } }
} code="choice11" } /*<applet
/*<applet height=200 width=300> code="choice11"
code="choice11" </applet>*/ height=200 width=300>
height=200 width=300> </applet>*/
</applet>*/
jl = new JLabel(new jl = new jl = new JLabel(new
ImageIcon("star.gif")); JLabel("star.gif"); JLabel( ImageIcon("star.g ImageIcon("star.gif"));
if"));
mbr.add(view); mbr.add(menu); mbr.add(vieweditmenu); mbr.add(viewmenu);
Missing Semicolon } { ()
actionPerformed(Action itemStateChanged(Actio itemStateChanged(ItemE adjustmentPerformed(A
Event ae) nEvent ie) vent ie) djustmentEvent ae)
The internet address of The internet address of The internet address of The internet address of
the server the client the host any other PC

Exception type is wrong. Class should not be Creation of object is not Use of created object
public. correct. not correct
Missing semicolon Missing { Missing } Missing statement.

Missing semicolon Missing { Missing } Missing statement.


Error in main() Error in loop Error in connection Error in close()
statement

Missing semicolon Missing { Missing } Missing package


statement.
s.executeUpdate() c.createStatement( ) s.close() c.close()
import java.io.*; import import java.Vector.* ; import import
java.util.*; import import java.Thread.*; javax.servlet.http.*; javax.servlet.http.*;
javax.servlet.*; import import javax.servlet.*; import java.String.*; import java.Thread.*;
javax.servlet.http.*; import java.Vector; import javax.Client.*;

new Cookie("MyCookie", new Cookie("MyCookie", new Cookie("MyCookie", new Cookie("MyCookie",


data); data1); data2); database);
IoException MalformedURLException Arithmetic Exception UnknownHostException

Port :8080 Port :1024 Port: -1 None of the above


Missing semicolon Missing package Missing initialization None of the above
statement
Ans.
CheckboxMenuItem

Labels, Push buttons,


Check boxes, Choice lists

FlowLayout

setBorderLayout()

InetAddress

File path
Protocol
getData()
setIcon(ImageIcon i)

all of above
C
static
InetAddressgetLocalHost
( )throws
UnknownHostException

All of above

ServerSocket(intport,
intmaxQueue)
The internet address of
the host

ResultSet object
Statement
Integer
All above are valid
differences
Error in statement in
which JTable is created
appletviewer
combodemo11.java
importjava.awt.*;
importjava.applet.*;
public class choice11
extends Applet
{
public void init()
{
Choice os=new Choice();
os.add("wnn18");
os.add("wnnxp");
os.add("wnnnt");
os.add("win 2000");
add(os);
}
}
/*<applet
code="choice11"
height=200 width=300>
</applet>*/
jl = new JLabel(new
ImageIcon("star.gif"));
mbr.add(viewmenu);
{
itemStateChanged(ItemE
vent ie)
The internet address of
the host

Use of created object


not correct
Missing }
Error in main()

Missing package
statement.
import java.io.*; import
java.util.*; import
javax.servlet.*; import
javax.servlet.http.*;

new Cookie("MyCookie",
data);
MalformedURLException

Port: -1
Missing package
statement
Sr. No. Question
What is API

1
2 Which of the following is false about GridbagLayout
which of these methods use in cardlayout
3
4 _____________________ is not a Swing Component
5 JCheckBox is _______________________Component
MutableTreeNode is extends__________________interface
6
7 whichof the following is not in AWT package
8 Canvas is a ________________
Which of these not a constants defined in ComponentEvent class?
9
10 KeyListener interface has got _______________methods
11 Which of these a AdapterClass
12 ___________________class is a super class of all event class
13 Which of these is a factory methods
14 Which of these is a return type of getData method of DatagramPacket class
15 __________is class used for accessing the attribute of a remote resource.
16 How many ports are reserves by TCP/IP
17 forName is a_______________________type method
For execution of INSERT SQL query in JDBC, ............. method must be used.
18
prepareStatement method is from which class
19
20 which are above use "middle-tier"
21 _________is Known as JSP
22 How many variablescan be set in JSP programs
23 Which is interface of following
24 Tomcat is a _____________
Which method is use to display menubar
25
Which Component are present in following image y
26
Which are the steps for Jtable Component with applet

27
MVC Stand for
28
Which of these methods can be used to obtain the coordinates of a mouse?
29
Which of these are integer constants of TextEvent class?
30
Which of these methods can be used to know the degree of adjustment made by user?
31
Select the proper constructor for receive Datagram Packets

32
33 Which one is not a method of URLConnection class
34 select the proper method to retrive the data from DatagramPacket
What will be the output of following code?
import java.net.*;

class URLDemo {
public static void main(String args[])
throws MalformedURLException {
URL hp = new URL("http://www.msbte.com/mainsite/");
System.out.println(hp.getFile());

System.out.println(hp.getHost());
System.out.println(hp.getPort());
35 } }
What is, in terms of JDBC, a DataSource

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

37
What is the meaning of Resultset. TYPE_SCROLL_INSENSITIVE

38
The Life Cycle of a Servlet Managed by
39
What is the limit of data to be passed from HTML when doGet() method is used
40
Which of the following are the session tracking techniques

41
Using the Java graphics method which statement would you write to create a circle of
radius 20, centered at x=100 and y=100
42
Consider the following code fragment
Rectangle r1 = new Rectangle();

r1.setColor(Color.blue);
Rectangle r2=r1;

r2.setColor(Color.red);
After the above piece of code is executed,
43 what are the colors of r1 and r2?(in this order)?
which is correct code for following image y

44
45 what would be used as the top-level Swing component in a Java application
46 which of the following components generate item event
which of these methods are used to register a mouse motion listener?
47
48 which of these events will be generated if we close an applet's window?
Suppose that you want to have an object ch handle the TextEvent of TextArea object t.
How should you add ch as the event handler for?
49
50 Which of these is superclass of all Adapter classes?
import java.net.*;
class networking1 {
public static void main(String[] args) throws UnknownHostException {
InetAddress obj1 = InetAddress.getByName("www.google.com");
InetAddress obj2 = InetAddress.getByName("www.google.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}

51
import java.net.*;
class networking2 {
public static void main(String[] args) throws UnknownHostException {
InetAddress obj1 = InetAddress.getByName("google.com");
System.out.print(obj1.getHostName());
}
}

52
How can you execute a stored procedure in the database?

53
What is correct about DDL statements (create, grant,…)?

54
What happens if you call deleteRow() on a ResultSet object?

55
How do you use a savepoint?

56
How can you execute DML statements (i.e. insert,delete,update)in the database?

57
Dynamic interception of requests and responses to transform the information is done
by
58
What's the difference between servlets and applets?
1.Servlets executes on Servers, where as
Applets executes on Browser
2. Servlets have no GUI, where asan 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
59 multiple requests
60 Which method is used to specify before any lines that uses the PrintWriter?
The major difference between servlet and CGI is

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

62
Option A B C D
Application Application Application None Of These
Programming Programming Intraction Programming Interface
Interchange

gridx gridy ipadx widthx


add(Component C, String add(Component C) add(Card c1, Component add(String s, Component
s) c) c)
ButtonGroup Jlabel Jbutton CheckboxGroup
lightweight heavyweight awt abstract
TreeNode DefaultMutableTreeNod TreePath Jtree
e
ButtonGroup CheckBoxGroup CheckBox Button
Applet Panel Window Frame
COMPONENT_HIDDEN COMPONENT_SHOWN COMPONENT_SIZED COMPONENT_RESIZED

2 4 1 3
KeyAdapter class TextAdapter class ActionAdapter class ItemAdapter class
AWTEvent class Event class EventObject class AWTObject class
getAddress() getHostName() getLocalHost() getHostAddress()
Object String byte metadata
URL Class URLConnection Class Connection Class ConnectionUrl Class
1000 1024 24 124
final static abstract super
executeQuery() executeDeleteQuery() executeUpdate() executeDelete()

PreparedStatement class PrepareStatement class Connection Class Statement Class

Three-Tier Foure-Tier n-Tier All of above


Java Server Page Java Server Program Java Sevlet Page Java Sevlet Program
3 6 8 None Of These
Servlet GenericServlet ServletInputStream HttpServlet
Servlet Web Server mail Server File Server
addMenubar() setMenubar() addMenuBar(MenuBar setMenuBar(MenuBar
mb) mb)
Button, Label, JTable, JButton, JLabel, JTable, JButton, JLabel, JTable, JButton, JLabel, Table,
JProgressbar Progressbar JProgressBar Progressbar
1. Create JScrollPane 1.Create Jtable object 1.Create Jtable object 1.Create Jtable object
object with appropriate
constructor 2. 2.Create 2.Create 2.Create
Create Jtable object JScrollPane object with JScrollPane object with JScrollPane object with
appropriate constructor appropriate constructor appropriate constructor
3. Add Jtable
object to contentpane 3. Add 3. Add 3. Add
Jtable object to Jtable object to Jtable object to
4. add JScrollPane to contentpane scrollpane scrollpane
contentpane 4. add 4. add
JScrollPane to JScrollPane to
contentpane contentpane
Model Verify Controller Model View Controller Most Verify Controller Most Visual Component

getPoint() getCoordinates() getMouseXY() getMouseCordinates()

TEXT_CHANGED TEXT_FORMAT_CHANGE TEXT_VALUE_CHANGED TEXT_SIZE_CHANGED


D
getValue() getAdjustmentType() getAdjustmentValue() getAdjustmentAmount()

DatagramPacket(byte DatagramPacket(byte DatagramPacket(byte DatagramPacket(byte


data[],int size) data[],int data[],int data[],int offset,int size,
size,InetAddress offset,InetAddress InetAddress ipAdr,int
ipAdr,int port) ipAdr,int port) port)

getDate() getContentType() getFile() getExpiration()


getContent() getData() getFile() getInfo()
mainsite /mainsite/ /mainsite /mainsite/

msbte.com
msbte.com www.msbte.com www.msbte.com

-1 -1 -1 -1

A DataSource is the basic A DataSource is the java A DataSource is a A DataSource is a factory


service for meanging a representation of registry point for JNDI- of connections to a
set of JDBC drivers physical data source services physical data source

the method close() does the database and JDBC you will get a the ResultSet, together
not exist for a ResultSet. resources are released SQLException, because with the Statement
Only Connections can be only Statement objects which created it and the
closed can close ResultSets Connection from which
the Statement was
retrieved, will be closed
and release all database
andJDBC resources

This means that the This means that the This means that the The meaning depends
ResultSet is insensitive Resultset is sensitive to ResultSet is sensitive to on the type of data
to scrolling scrolling, but insensitive scrolling, but insensitive source, and the type and
to updates, i.e. not to changes made by version of the driver you
updateable others use with this data source

Servlet Context Servlet Container the supporting protocol All of the above
4k 8k 2k 1k

URL rewriting, using URL rewriting, using UrL rewriting, using URL rewriting, using
session object, using session object, using servlet object, using request object, using
response object, using cookies, using hidden response object, using response object, using
hidden fields fields cookies session object

g.drawOval(80,80,40,40) g.drawOval(80,80,20,20) g.drawOval(120,120,20,2 g.drawOval(100,100,20,2


0) 0)
Color.blue Color.blue Color.red Color.red

Color.red Color.blue Color.red Color.blue

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

import import import import


java.applet.*; java.applet.*; java.applet.*; java.applet.*;

public class Demogr public class Demogr public class Demogr public class Demogr
extends Applet extends Applet extends Applet extends Applet
{ { { {

public void public void public void public void


init() init() init() init()
{ setLayout(new { setLayout(new { setLayout(new { setLayout(new
GridLayout(3,0)); GridLayout(0,3)); GridLayout(1,3)); BorderLayout());
add(new add(new add(new add(new
Button("NORTH")); Button("NORTH")); Button("NORTH")); Button("NORTH"),Border
add(new add(new add(new Layout.NORTH);
Button("CENTER")); Button("CENTER")); Button("CENTER")); add(new
add(new add(new add(new Button("CENTER"),Borde
Button("SOUTH")); } Button("SOUTH")); } Button("SOUTH")); } rLayout.CENTER);
} } } add(new
/*<applet /*<applet /*<applet Button("SOUTH"),Border
code="Demogr" code="Demogr" code="Demogr" Layout.SOUTH); }
width=200 height=200> width=200 height=200> width=200 height=200> }
</applet>*/ </applet>*/ </applet>*/ /*<applet
code="Demogr"
Jobject Jwindow ContentPane Jframe
MenuItem CheckableMenuItem CheckableMenu CheckboxMenuItem
addMouseMotion() addMouseListener() addMouseMotionListene addMotionListener()
r()
ActionEvent ComponentEvent AdjustmentEvent WindowEvent
t.addTextListener(ch) ch.addTextListener(t) addtextListener(ch.t) addtextListener(t,ch)
Applet ComponentEvent Event InputEvent
0 0 1 1

google google.com www.google.com None of above

Call method execute() on Call method Call method execute() on Call method run() on a
a CallableStatement executeProcedure() on a a StoredProcedure ProcedureCommand
object Statement object object object

DDL statements are To execute DDL DDL statements cannot Support for DDl
treated as normal SQL statements, you have to be executed by making satements will be a
statements, and are install additional support use of JDBC,you should feature of a future
executed by calling the files use the native databse release of JDBC
execute() method on a tools for this.
Statement(or a sub
interface thereof) object

The row you are The row you are The result depends on You will get a compile
positioned on is deleted positioned on isdeleted whetherthe property error:the method does
from the ResultSet,but form the ResultSet and synchronizeWithDataSou not exist because you
not from the database. from the database. rce is set to true or false. can not delete rows
from a ResultSet.
A savepoint is realised by A savepoint is activated A savepoint is used to A savepoint triggers an
calling by the method set mark intermediate automatic
setAutoCommit(true) on SavePoint("mysavepoint points inside a synchronisation with the
the connectiion. ") on the transaction. transaction,in order to database.
get a more fine-grained
control.Transactions can
br rolled back to a
previous savepoint
without affecting
preceding work.

By making use of the By invoking the By invoking the By making use of the
InsertStatement,DeleteS execute(...) or executeInsert(...),execut execute(...) statement of
tatement or executeUpdate(...) eUpdate(...) methods of the
UpdateStatement method of a normal the DataModificationStatem
classes Statemant object or a DataModificationStatem ent object
sub-interface object ent object
thereof

servlet container servlet config servlet context servlet filter

1,2,3 are correct 1,2 are correct 1,3 are correct 1,2,3,4 are correct

setPageType() setContextType() setContentType() setResponseType()


Servlets are thread Servlets executes slower Servlet has no platform All of the above
based and CGI is process compared to CGI specific API, where as
based CGI has

If a servlet or jsp is If a servlet or jsp is If a servlet or jsp If a servlet or jsp invoked


invoked using invoked using forword isinvoked using a if when form submits.
sendRedirect method. method hyperlink in the page.
Ans.
Application
Programming Interface

widthx
add(String s, Component
c)
CheckboxGroup
lightweight

static
executeUpdate()

Connection Class
Model View Controller

getPoint()

TEXT_VALUE_CHANGED

/mainsite/

www.msbte.com

-1

A DataSource is a factory
of connections to a
physical data source

the database and JDBC


resources are released

This means that the


ResultSet is sensitive to
scrolling, but insensitive
to changes made by
others

Servlet Container
2k

URL rewriting, using


session object, using
cookies, using hidden
fields

g.drawOval(80,80,40,40)

Color.red

Color.red

import java.awt.*;

import
java.applet.*;

public class Demogr


extends Applet
{

public void
init()
{ setLayout(new
GridLayout(3,0));
add(new
Button("NORTH"));
add(new
Button("CENTER"));
add(new
Button("SOUTH")); }
}
/*<applet
code="Demogr"
width=200 height=200>
</applet>*/

Jframe
CheckboxMenuItem
addMouseMotionListene
r()
WindowEvent
addtextListener(t,ch)
Applet
TRUE

google.com

You might also like