AJP Unit-III ByOmiii
AJP Unit-III ByOmiii
Program: CO5I Course: Advanced Java Programming (22517) Course Co-ordinator: Mrs.Chavan P.P.
Unit III- Event Handling
Question Bank
Sr. A
Question Option A Option B Option C Option D
No n
j
1 Which of these packages contains all the event handling interfaces? java.lang java.awt java.awt.event java.event a
vA
2 Where can the event handling code be written? Same class Other class Anonymous class All mentioned above l
l
E
3 Which of these class is super class of all the events? EventObject EventClass ActionEvent ItemEvent
v
j
Which package provides many event classes and Listener interfaces for
4 java.awt java.awt.Graphics java.awt.event None of the above a
event handling?
vC
Which of these interfaces handles the event when a component is added to
5 ComponentListener ContainerListener FocusListener InputListener o
a container?
n
A
6 Which of these interfaces define a method actionPerforme() ? ComponentListener ContainerListener ActionListener InputListener
c
C
7 Which of these interfaces define four methods? ComponentListener ContainerListener ActionListener InputListener
o
W
8 Which of these events will be generated if we close an applet's window? ActionEvent ComponentEvent AdjustmentEvent Window Event i
n
A
9 Which of these events is generated when a button is pressed ? ActionEvent KeyEvent Window Event AdjustmentEvent
c
g
Which of these methods can be used to obtain the command name for getAction
10 getCommand() getActionCommand() getActionEvent() e
invoking ActionEvent object? EventCommand()
tI
Which of these interfaces define a method
11 ComponentListener ContainerListener ActionListener ItemListener t
itemStateChanged()?
ek
12 Which of these methods will be invoked if a character is entered ? keyPressed() keyReleased() keyTyped() keyEntered() e
y
A
13 Which of these are constants defined in Window Event class? WINDOW_ACTIVATED WINDOW_CLOSED WINDOW_DEICONIFIED All of the mentioned
l
A
14 Which of these events is generated by scroll bar? ActionEvent KeyEvent Window Event AdjustmentEvent
d
U
Which of these constant value will change when the button at the end of
15 BLOCK_DECREMENT BLOCK_INCREMENT UNIT_DECREMENT UNIT_INCREMENT N
scroll bar was clicked to increase its value?
Im
16 Which of these methods is defined in MouseMotionAdapter class? mouseDragged() mousePressed() mouseReleased() mouseClicked() o
u
A
17 Which of these methods will respond when you click any button by mouse ? mouseClicked() mouseEntered() mousePressed() All of the mentioned l
l
A
18 Which of these is superclass of all Adapter classes? Applet ComponentEvent Event InputEvent
p
g
19 Which of these methods can be used to obtain the coordinates of a mouse? getPoint() getCoordinates() getMouseXY() getMouseCordinates() e
t
I
20 MouseEvent is subclass of which of these classes? ComponentEvent Containerfivent ItemEvent InputEvent
n
T
21 Which of these are integer constants of TextEvent class? TEXT_CHANGED TEXT_FORMAT_CHANGED TEXT_VALUE_CHANGED TEXT_SIZE_CHANGED
E
g
Which of these methods is used to obtain the object that generated a
22 getMethod() getWindow() getWindowEvent() getWindowObject() e
Window Event ?
tg
23 Which of these methods is used to get x coordinate of the mouse? getX() getXCoordinate() getCoordinateX() getPointX() e
t
C
24 Which of these is superclass of Window Event class? WindowEvent ComponentEvent ItemEvent InputEvent
o
K
25 Which event gets generated when the key is typed? KEY_PRESSED KEY_TYPED KEY_RELEASED None of these
E
g
What method is used to distinguish between single, double and triple mouse
26 getButton() getPoint() getClickCount() getX() e
clicks?
t
W
27 The getNewState() method belongs to __ . TextEvent Class MouseEvent Class WindowEvent Class KeyEvent Class
i
A
28 For scrollbars___________event class is used ActionEvent TextEvent AdjustmentEvent ContainerEvent
d
j
29 Which of the following is the highest class in the event-delegation model ? java.util.EventListener java.util.EventObject java.awt.AWTEvent java.awt.event.AWTEvent a
v
T
There is no way to It is impossible to have
When two or more objects are added as listeners for the same event, which The first object that was The last object that was h
30 determine which listener more than one listener for
listener is first invoked to handle the event? added as listener. added as listener. e
will be invoked first. a given event.
r
I
31 MouseEvent is subclass of which of these classes? ComponentEvent ContainerEvent ItemEvent InputEvent n
p
g
32 Which of these methods is used to get x coordinate of the mouse? getX() getXCoordinate() getCoordinateX() getPointX() e
t
B
33 In Java, events are all the actives that occur between: The user The application Both a and b None of the above
o
T
34 Which of these methods can be used to change location of an event? ChangePoint() TranslatePoint() ChangeCordinates() TranslateCordinates() r
a
A
35 Which of these events is generated by scroll bar? ActionEvent KeyEvent WindowEvent AdjustmentEvent
d
g
Which of these methods is used to obtain the object that generated a
36 getMethod() getWindow() getWindowEvent() getWindowObject() e
WindowEvent?
t
Complete the following code
public class Buttonl extends Applet implements
{ Button button=new Button("change the color");
boolean flag=true;
public void init() A
{ add(button); c
button.addActionListener(this); . t
} i
public void paint(Graphics g) o
{ if(flag) n
setBackground(Color. yellow); L
37 ActionListener ItemListener MouseListener None of these
else i
setBackground(Color.red); s
} t
public void actionPerformed(ActionEvent e) e
{ String str=e.getActionCommand(); n
if(str.equals("change the color")) e
{ flag = !flag; r
//toggle the flag values on every click of button
repaint();
}
}}
g
38 Which of these methods can be used to know which key is pressed? getKey() getModifier() getActionKey() getActionEvent() e
tW
39 Which of these events is generated when the a window is closed? TextEvent MouseEvent FocusEvent WindowEvent i
n
A
40 Which of these are integer constants of ComponentEvent class? COMPONENT_HIDDEN COMPONENT_MOVED COMPONENT_RESIZE All of the mentioned l
lF
Which of these events is generated when computer gains or losses input
41 ComponentEvent ContainerEvent FocusEvent InputEvent o
focus?
cg
Which of these methods can be used to know the degree of adjustment
42 getValue() getAdjustmentType() getAdjustmentValue() getAdjustmentAmount() e
made by the user?
tg
Which of these methods can be used to obtain the reference to
43 getContainer() getContainerCommand() getActionEvent() getContainerEvent() e
the container that generated a ContainerEvent?
gt
Which of these methods can be used to get reference to a component that
44 getComponent() getchild() getContainerComponent() getComponentChild() e
was removed from a container?
tC
Which of these events is generated when the component is added or
45 ComponentEvent ContainerEvent FocusEvent InputEvent o
removed?
n
i
t
Consider following code arid fill up the correct event listener method e
/* <applet code = "checkgroup" width = 300 height =250 > </applet> */ m
public class checkgroup extends Applet implements S
ItemListener t
{ String msg=" "; a
CheckboxGroup,.gr=new CheckboxGroupO; t
Checkbox boxl =new Checkbox("Candy" ,gr,true); e
Checkbox box2 = new Checkbox("Ice-cream" ,gr,false); C
Checkbox box3=new Checkbox(" Juice ",gr,false); h
public void init() a
{ add(boxl); n
add(box2); actionPerformed(ActionEv itemStateChanged(ItemEv textValueChanged(TextEv g
46 action(Event e,Object O)
add(box3); ent e) ent e) ent e) e
boxl.addItemListener(this); d
box2.addItemListener(this); (
box3.addItemListener(this); I
} t
public void _ e
{ repaint(); } m
public void paint(Graphics g) E
{ msg="I like "; v
msg+ =gr.getSelectedCheckbox().getLabeI(); e
g.drawString(msg,10,100); n
}} t
e
)W
47 Which of these events will be generated if we close an applet’s window? ActionEvent ComponentEvent AdjustmentEvent WindowEvent i
nC
Which of these events is generated when the size of a component is
48 ComponentEvent ContainerEvent FocusEvent InputEvent o
changed?
Cm
Which of these events is generated when the component is added or
49 ComponentEvent ContainerEvent FocusEvent InputEvent o
removed?
n