AJP UNIT 3
AJP UNIT 3
Event Handling
A) KeyAdapter B) FocusAdapter
C) ItemAdapter D)
MouseMotionAdapter
Q12. Which of the following method does not belongs to WindowListerner interface?
A) windowActivated B) windowClosed
C) windowClosing D) windowReactivated
Q13. Which of the following method is invoked when a window is changed from a normal to
aminimized state?
A) windowActivated() B) windowClosed()
C) windowClosing() D) windowIconified()
A) Component B) ComponentAdapter
C) ComponentListenerAdapter D) None
Q17. If an adapter class is inherited , there is no need of implementing all the methods of
listenerinterfaces .
Q19. In an adapter class program, if it contains 5 methods, how many methods are to be
overriden?
A) 1 B) 2 C) 4 D) 5
Q20. Which is the abstract adapter class for receiving keyboard focus events.
Q21. Following are the integer constants which does not belong to ComponentEvent class .
A) COMPONENT_HIDDEN B)
COMPONENT_ICONIFIED C) COMPONENT_MOVED
D)COMPONENT_SHOWN
Q22. A class which adapts methods of another class by giving different names to essentially
the samemethods is called as
A) this.addWindowListener(new MyWindowAdapter());
B) this.addWindow(new MyWindowAdapter());
C)this.addWindowAdapter(new MyWindowAdapter());
D) this.addWindowWindow(new MyWindowAdapter());
A) WHEEL_BLOCK_SCROLL,WHEEL_UNIT_SCROLL B)
BLOCK_SCROLL,UNIT_SCROLL C)WHEEL_SCROLL,BLOCK_SCROLL
D) WHEEL_PAGE_SCROLL,WHEEL_TRACK_SCROLL
Q25. To handle any events of mouse, you must implement following interfaces.
Q28. Following four methods belongs to which class? 1) public void add(Component c) 2)
public voidsetSize(int width,int height) 3) public void setLayout(LayoutManager m) 4)
public void setVisible(boolean)
Q29. Following methods belongs to which class? 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) ComponentListener B)
ContainerListener C) ItemStateListener D)
AdjustmentListener
Q35. Which of these interfaces define a method keyPressed()?
A) mouseMoved() B) MouseMotionListener()
C) MouseClick() D) MousePressed()
Q38. Assuming we have a class which implements the ActionListener interface, which
method shouldbe used to register this with a Button? ;
A) addListener(*) B) addActionListener(*);
C) addButtonListener(*); D) setListener(*);
A) WindowInterface B) WindowFocused
Interface C) WindowFocusListener D)
WindowAction Interface
A) 2 B) 5 C) 7 D) 4
A) windowListener() B) addListener()
C) addWindowListener() D)
eventWindowListener()
Q43. Which of these methods are used to register a mouse motion listener?
A) addMouse() B)
addMouseListener() C) addMouseMotionListner() D)
eventMouseMotionListener()
D) None of thementioned.
A) textChange() B) textModified()
C) textValueChanged() D)
textValueModified()
A) VK_UNDEFINED B)
CHAR_UNDEFINED C) VK_CONTROL
D) CHAR_ERROR
Q55. Which method not use to obtain the coordinates of the mouse-
Q56. Which of these method are used to register a keyboard event Listener ?
A) KeyListener() B) addKeyListener()
C) RegisterKeyListener() D) addKeyBoard()
Q58. Which is the correct general form of method of the ActionListener interface?
Q59. The TextEvent Constructor- TextEvent(Object src, int type) Here type means-
Q62. The Following steps are required to perform 1) Implement the Listener interface and
overrides itsmethods 2) Register the component with the Listener
Q63. Consider following three statement 1) ActionListener Interace defines one method to
receive action event 2) ItemListener Interface defines one method to recognize when the state
of item change.. 3)MouseListener interface defines mouseMoved() method
Q65. ItemEvent constructor- ItemEvent(ItemSelectable src, int type, Object entry, int state)
Here srcmeans......
Q66. Which of the following are true? A. The event-inheritance model has replaced the
event- delegation model. B. The event-inheritance model is more efficient than the event-
delegation model. C. Theevent-delegation model uses event listeners to define the methods of
event-handling classes. D. The event-delegation model uses the handleEvent( ) method to
support event handling.
A) Statement 1 is true B) Statement 2 is true
C) Statement 3 is true D) Statement 4 is
true
Q69. Which of the following are true? A) The MouseListener interface defines methods for
handling mouse clicks. B) The MouseMotionListener interface defines methods for handling
mouse clicks. C) The MouseClickListener interface defines methods for handling mouse
clicks. D) The ActionListener interfacedefines methods for handling the clicking of a button.
A) getOppositeWindow() B) getNewState()
C) getOldState() D) All of above
Q71. Match the correct pairs- a. getKeyLocation() i. Set the keyCode value to indicate a
physical key.
b. getKeyCode() ii. Returns the character associated with the key in this event. c.
getKeyChar() iii. Returnsthe location of the key that originated this key event. d.
setKeyCode(int keyCode) iv. Returns the integer keyCode associated with the key in this
event.
Q74. Select correct general form of Mouse Entered method of Mouse Listener interface.
A) There are syntax errors on line no. 1 B) There are syntax errors on line
no. 2 C) There are syntax errors on line no . 4 D) There are syntax errors on line no.
5
Q76. Consider following code segment-
public void mousePressed(MouseEvent event)
{
System.out.println(event.getPoint());
}
Following code segement output is-
Q79. Which top-level class provides methods to add and remove keyboard and mouse event
listeners-
Q83. ItemEvent constructor- ItemEvent(ItemSelectable src, int type, Object entry, int state)
Here entrymeans......
Q84. The example of user interface elements that implement the ItemSelectable interface-
Q85. Consider the following code segment. Insert correct code at blank space.
if (checkbox.getState() == true)
else
});
2. Checkbox ch = (Checkbox)ie.setItemSelectable();
3. if(ch.getState()==true) {
6. jf.setVisible(true);
7 .}
4. // Line no 4
5. System.out.println(cb.getText( ) + "selected");
6. else
7.System.out.println(cb.getText( ) + "cleared");
8. }
Q91. KeyEvent Constructor- KeyEvent(Component src, int type, long when, int modifiers, int
code, charch) Here when means-
A) a reference to the component that generated the event. B) The type of event
occured. C) virtual key codes D) The system time at which the key
was pressed.
Q96. Which of the following statements are true? 1) The MouseMotionListener interface
defines methods for handling mouse clicks. 2) The ActionListener interface defines methods
for handling the clicking of a button. 3) The MouseClickListener interface defines methods
for handling mouse clicks. 4) TheMouseListener interface defines methods for handling
mouse dragged
Q97. Which of the following statements are false 1)windowlistener define seven method
2)mouseMotionListerne define 2 method 3) ActionListener Interace defines three method to
receive actionevent 4)KeyListener Interface define Three method
Q100. WindowEvent Constructor- WindowEvent(Window src, int type, Window other, int
fromState, inttoState) Here fromState means-