AJP (22517) QB (Unit 3,4,5,6)
AJP (22517) QB (Unit 3,4,5,6)
1) Which of these packages contains all the classes and methods required for event
handling
a) java.applet
b) java.awt
c) java.event
d) java.awt.event
Page 1 of 27
Advanced Java Programming (22517) MCQ
c) ActionEvent
d) ItemEvent
13) _____ method return the name on component on which event is generated
a)getActionCommand()
b)getSource()
c)getName()
d)getByName()
Page 2 of 27
Advanced Java Programming (22517) MCQ
Page 3 of 27
Advanced Java Programming (22517) MCQ
d)mouseListener(MouseEvent me)
Page 4 of 27
Advanced Java Programming (22517) MCQ
d)MouseEvent
Page 5 of 27
Advanced Java Programming (22517) MCQ
b) import java.awt.*;
import java.awt.event.*;
class DemoAction extends Frame implements ActionListener
{
Label l1=new Label();
DemoAction()
{
setTitle("Demo Event");
setSize(500,500);
setVisible(true);
setLayout(null);
Button b1=new Button("ok");
Button b2=new Button("Cancel");
b1.setBounds(100,50,50,20);
b2.setBounds(200,50,50,20);
add(b1);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
String str1=ae.getActionCommand();
if(str1.equals("ok"))
{
l1.setText("You press Ok");
}
else if(str1.equals("Cancel"))
{
l2.setText("You press Cancel");
}
else
{
l3.setText("please press on any button ");
}
add(l1);
l1.setBounds(100,100,250,20);
}
public static void main(String args[])
Page 6 of 27
Advanced Java Programming (22517) MCQ
{
DemoAction d1=new DemoAction();
}
}
c) import java.awt.*;
import java.awt.event.*;
class DemoAction extends Frame implements ActionListener
{
Label l1=new Label();
DemoAction()
{
setTitle("Demo Event");
setSize(500,500);
setVisible(true);
setLayout(null);
Button b1=new Button("ok");
Button b2=new Button("Cancel");
b1.setBounds(100,50,50,20);
b2.setBounds(200,50,50,20);
add(b1);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
String str1=ae.getActionCommand();
if(str1.equals("ok"))
{
l1.setText("You press Ok");
}
else if(str1.equals("Cancel"))
{
l1.setText("You press Cancel");
}
else
{
l1.setText("please press on any button ");
}
add(l1);
l1.setBounds(100,100);
}
public static void main(String args[])
{
DemoAction d1=new DemoAction();
Page 7 of 27
Advanced Java Programming (22517) MCQ
}}
d) import java.awt.*;
import java.awt.event.*;
class DemoAction extends Frame implements ActionListener
{
Label l1=new Label();
DemoAction()
{
setTitle("Demo Event");
setSize(500,500);
setVisible(true);
setLayout(null);
Button b1=new Button("ok");
Button b2=new Button("Cancel");
b1.setBounds(100,50,50,20);
b2.setBounds(200,50,50,20);
add(b1);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
String str1=ae.getActionCommand();
if(str1.equals("ok"))
{
l1.setText("You press Ok");
}
else if(str1.equals("Cancel"))
{
l1.setText("You press Cancel");
}
else
{
l1.setText("please press on any button ");
}
add(l1);
l1.setBounds(100,100,250,20);
}
public static void main(String args[]);
{
DemoAction d1=new DemoAction();
}
}
33) Choose the correct Error in below code
Page 8 of 27
Advanced Java Programming (22517) MCQ
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class DemoMouseEvent extends Applet implements MouseListener
{
public void init()
{
setVisible(true);
this.addMouseListener(this);
}
public void mouseEntered (MouseEvent me)
{
showStatus("Mouse Entered ");
}
public void mousePressed(MouseEvent me)
{
showStatus("Mouse Pressed ");
}
public void mouseReleased(MouseEvent me)
{
showStatus("Mouse Released ");
}
public void mouseClicked(MouseEvent me)
{
int x,y;
x=me.getX();
y=me.getY();
showStatus("Mouse Clicked at x="+x+" y="+y);
}
public void mouseExited(MouseEvent me);
{
}
}
/*<applet code="DemoMouseEvent" width=400 height ="400"></applet>*/
Page 9 of 27
Advanced Java Programming (22517) MCQ
c)ItemEvent
d)InputEvent
35) The____ is an object that is notified when an event occure
a)Listener
b)Source
c)Event
d)Model
36) Clicking the closing button on the upper right corner of frame generates _____ event
a)ItemEvent
b)WindowEvent
c)MouseMotionEvent
d)ComponentEvent
a) import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
Page 10 of 27
Advanced Java Programming (22517) MCQ
}
public void mouseDragged (MouseListener me)
{
showStatus("Mouse Dragged");
}
}
/*<applet code="DemoMouseMotionEvent" width=400 height ="400"></applet>*/
b)import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class DemoMouseMotionEvent extends Applet implements
MouseMotionListener
{
public void init()
{
setVisible(true);
this.addMouseMotionListener(this);
}
public void mouseMoved (MouseEvent me)
{
int x,y;
x=me.getX();
y=me.getY();
showStatus("Mouse moved at x="+x+" y="+y);
}
public void mouseDragged (MouseEvent me)
{
}
}
Page 11 of 27
Advanced Java Programming (22517) MCQ
d) import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class DemoMouseMotionEvent extends Applet implements
MouseMotionListener
{
public void init()
{
setVisible(true);
this.addMouseMotionListener(this);
}
public void mouseMoved (MouseEvent me)
{
int x,y;
x=me.getX();
y=me.getY();
showStatus("Mouse moved at x="+x+" y="+y);
Page 12 of 27
Advanced Java Programming (22517) MCQ
40) void keyTyped(KeyEvent ke) called when a key on the keyboard is ______
a)Pressed
b)Released
c)Pressed and Released
d)No Action Taken from Keyboard
Page 13 of 27
Advanced Java Programming (22517) MCQ
4) SocketAddress is combination of
a)Ip address and port no
b)ip address
c)port no
d)none
Page 14 of 27
Advanced Java Programming (22517) MCQ
Page 15 of 27
Advanced Java Programming (22517) MCQ
Page 16 of 27
Advanced Java Programming (22517) MCQ
Page 17 of 27
Advanced Java Programming (22517) MCQ
b)23
c)25
d)80
Page 18 of 27
Advanced Java Programming (22517) MCQ
Page 19 of 27
Advanced Java Programming (22517) MCQ
b)Statement
c)PreparedStatement
d)None
Page 20 of 27
Advanced Java Programming (22517) MCQ
d)above all
26) Which of the following method is used to perform DML command in jdbc
a)executeQuery()
b)executeResult()
c)executeUpdate()
Page 21 of 27
Advanced Java Programming (22517) MCQ
d)none
Page 22 of 27
Advanced Java Programming (22517) MCQ
b)Driver
c)Connection
d)JDBC API
1) Which of the following code can be used to send an error response to the client using
the specified status code and clearing the buffer.
Page 23 of 27
Advanced Java Programming (22517) MCQ
a) request.sendError(statusCode)
b) response.sendError(statusCode)
c) header.sendError(statusCode)
d) None of the above.
Page 24 of 27
Advanced Java Programming (22517) MCQ
Page 25 of 27
Advanced Java Programming (22517) MCQ
18) When the data of client request is send through GET method the handling method in
servlet is __
a)doGet()
b)doPost()
c)DoGetServlet()
d)DoGetPost()
Page 26 of 27
Advanced Java Programming (22517) MCQ
25) All the configuration values of servlet(used by ServletConfig and ServletContext) are
available in ____
a)web.xml(Deployment Descriptor)
b)Web Container
c)Web Server
d)Web App
29) Session between web client and web Server can be created through
a)Cookie object
b)Session object
c)Generic servlet object
d)Connection object
30) Session between web client and web Server can be created through
a)Session object
b)HttpSession
c)Generic servlet object
d)Connection object
Page 27 of 27