Sanjivani Rural Education Society’s
SANJIVANI K. B. P. POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST: AHMEDNAGAR
2023-2024
/64
Sub : AJP (22517) Pratice Test: [Unit III – Event Handling] Date : / /2023
Name : Course Code : CM-5-I
Roll No : Set : II
1. Till now, two models have been introduced in Java for
Answer: a
a. Receiving and Processing events b. Deleting and Processing events
c. Receiving and Deleting events d. Modifying and Receving events
2. An event is generated whe the internal state of the event source is________
Answer: b
a. Not changed b. Changed c. Either changed or not d. None of these
3. EventObject class belongs to:
Answer: a
a. [Link] b. [Link] c. [Link] d. [Link]
4. The ___________ interface handles list events:
Answer: d
a. ContainerListener b. FocusListener c. ActionListener d. ItemListener
5. The ___________ interface handles choice events:
Answer: b
a. ContainerListener b. ItemListener c. ActionListener d. WindowListener
6. The ___________ interface is used to handle checkbox events:
Answer: b
a. ContainerListener b. ItemListener c. ActionListener d. WindowListener
7. The ___________ interface is used to handle button events:
Answer: c
a. ContainerListener b. ItemListener c. ActionListener d. WindowListener
8. A push button is an active control that has a _____________ appearance
Answer: c
a. One dimensional b. Two dimensional c. Three dimensional d. None of these
9. ItemListener is defined by the _____________ method:
Answer: b
a. itemChangedState() b. itemStateChanged() c. itemChanged() d. itemState()
10. _____________ is a superclass of TextField and TextArea classes that is used to create single-line or multiline textfields
Answer: c
respectively:
a. TextBox b. CheckBox c. TextComponent d. Choice
11. A label is a simple control which is used to display_____________ on the window:
Answer: a
a. Text(non-editable) b. Text(editable) c. Both a & b s d. None of these
12. The Delegation Event Model defines a ______________ approach to handle events:
Answer: a
a. Logical b. Physical c. Both a & b d. None of these
[Link] of the following event is called when the user presses the mouse button?
Answer: c
a)onMouseMove b)onMouseOut c)onMouseDown d)onMouseOver
14. Which of these interfaces define four methods?
Answer: a
a)ComponentListener b)ContainerListener c)ActionListener d)InputListener
[Link] of these methods will be invoked if a character is entered?
Answer: c
a)keyPressed() b)keyReleased() c)keyTyped() d)keyEntered()
[Link] of these interfaces define a method itemStateChanged()?
Answer: d
a)ComponentListener b)ContainerListener c)ActionListener d)ItemListener
[Link] of these methods is used to get x coordinate of the mouse?
Answer: a
a)getX() b)getXCoordinate() c)getCoordinateX() d)getPointX()
[Link] of these methods is used to obtain the object that generated a WindowEvent?
Answer: b
a)getMethod() b)getWindow() c)getWindowEvent() d)getWindowObject()
19. Which of these are integer constants of TextEvent class?
Answer: a
a)TEXT_CHANGED b)TEXT_FORMAT_CHANGED c)TEXT_VALUE_CHANGED d)TEXT_SIZE_CHANGED
[Link] of these methods can be used to change location of an event?
Answer: b
a)ChangePoint() b)TranslatePoint() c)ChangeCordinates() d)TranslateCordinates()
[Link] of these methods can be used to know the type of focus change?
Answer: c
a)typeFocus() b)typeEventFocus() c)isTemporary() d)isPermanent()
[Link] of these methods can be used to get reference to a component that was removed from a container?
Answer: a
a)getComponent() b)getchild() c)getContainerComponent() d)getComponentChild()
[Link] of these methods can be used to change location of an event?
Answer: b
[Link]() [Link]() [Link]() [Link]()
[Link] of these are integer constants of TextEvent class?
Answer: a
a.TEXT_CHANGED b.TEXT_FORMAT_CHANGED c.TEXT_VALUE_CHANGED d.TEXT_sIZE_CHANGED
[Link] of these methods is used to obtain the object that generated a WindowEvent?
Answer: b
[Link]() [Link]() [Link]() [Link]()
[Link] is subclass of which of these classes?
Answer: d
[Link] [Link] [Link] [Link]
[Link] of these is a superclass of all Adapter classes?
Answer: d
[Link] [Link] [Link] [Link] Event
[Link] of these are integer constants defined in ActionEvent class?
Answer: d
a.ALT_MASK b.CTRL_MASK c.SHIFT_MASK [Link] of the mentioned
[Link] of these methods can be used to obtain the coordinates of a mouse?
Answer: a
[Link]() [Link]() [Link]() [Link]()
[Link] of these methods can be used to know the type of focus change?
Answer: d
[Link]() [Link]() [Link]() [Link]()
[Link] of these methods can be used to obtain the reference to the container that generated a ContainerEvent?
Answer: a
[Link]() [Link]() [Link]() [Link]()
[Link] is subclass of which of these classes?
Answer: a
[Link] [Link] [Link] [Link]
[Link] interface should a class implement to respond to button clicks in Java Swing?
Answer: a
a) ActionListener b) MouseListener c) KeyListener d) WindowListener
[Link] method is invoked when an ActionListener detects a button click?
Answer: a
a) actionPerformed() b) mouseClicked() c) keyTyped() d) windowClosing()
35. What is the purpose of the MouseListener interface in Java Swing?
Answer: b
a) Handling keyboard events b) Handling mouse events c) Handling window event d) Handling file I/O events
[Link] of the following methods is part of the MouseListener interface in Java?
Answer: b
a) keyPressed() b) mouseClicked() c) actionPerformed() d) windowOpened()
37. How many mouse buttons are typically supported by the MouseListener interface?
Answer: c
a) 1 b) 2 c) 3 d) 4
38. What is the primary purpose of the MouseAdapter class in Java Swing?
Answer: c
a) To handle keyboard events
b) To handle window events
c) To provide default implementations of the MouseListener interface
d) To provide default implementations of the ActionListener interface
39. Which event is typically generated when the mouse pointer enters a component?
Answer: b
a) mouseClicked b) mouseEntered c) mousePressed d) mouseExited
40. Which listener interface should you use to respond to mouse drag events in Java Swing?
Answer: b
a) MouseAdapter b) MouseMotionListener c) ActionListener d) KeyListener
41. In Java Swing, what is the primary purpose of the actionPerformed() method?
Answer: c
a) Handling keyboard input
b) Handling mouse clicks
c) Handling button clicks and other action even
d) Handling window resizing
42. Which method is used to register anActionListener with a JButton in Java Swing?
Answer: c
a) addButtonListener() b) addActionEvent() c) addActionListener() d) addListenerToButton()
43. Which method returns the item where the event occurred ?
Answer: b
a. getItemSelectable() b. getItem() c. getStateChange() d. none of these
44. Which method returns the state change type which generated the event ?
Answer: c
a. getItemSelectable() b. getItem() c. getStateChange() d. none of these
45. In item event class which constant marks the last integer id for the range of item ?
Answer: c
a. LAST_Item b. Last_Item c. ITEM_LAST d. Item_last
46. Which method returns the item selectable object where this event originated ?
Answer: a
a. getItemSelectable() b. getItem() c. getStateChange() d. none of these
47. An event is generated when the internal state of the event source is ___________.
Answer: c
a. detected b. origin c. changed d. none of these
48. EventObject contains two important methods:________ and___________
Answer: c
a. getSource() b. toString() c. both a & b d. none of these
49. Focus events are fired whenever a component _____________the focus
Answer: c
a. gains b. loses c. both a & b d. none of these
50. Which class is used for this Processing Method processActionEvent( )?
Answer: d
a. Button b. List c. MenuItem d. All of these
51. Which Method Is used to register a mouse Motion Listner
Answer: a
a. addMouseMotionListener() b. addMouseListener c. both a & b d. none of these
52. Which of these not a constants defined in ComponentEvent class?
Answer: d
a. COMPONENT_HIDDEN b. COMPONENT_VISIBLE c. COMPONENT_SIZED d. All of these
53. Which of these methods is defined in MouseMotionAdapter class.
Answer: a
(a) mouseDragged() (b) mousePressed() (c) mouseReleased() (d)mouseClicked()
54. Which method from the following methods will respond when you click any button by mouse?
Answer: a
(a)mouseClicked() (b)mouseEntered() (c)mousePressed() (d)All of the mentioned
55. In Java, events are all the activities that occur between:
Answer: c
(a)The user (b) The application (c) Both (a) and (b) (d) None of the above
56. The constructor that is defined by the Text Event class is:
Answer: a
a. TextEvenet(Object source, int id ) b. textevent (Object source, int event_type )
c. textevent (object Source, float event_type) d. textevent (Object source, string event_type)
57. An event is generated when the internal state of the event source is
Answer: b
(a) Not changed (b) Changed (c) Either changed or not (d) None of these
58. When two or more objects are added as listeners for the same event, which listener is first
Answer: c
invoked to 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.
59. Which interfaces define a method itemStateChanged().
Answer: d
(a)ComponentListner (b)ContainerListener (c)ActionListener (d)ItemListener
60._______ generates action events when an item is double-clicked, generate action events when an item is selected or deselected.
Answer: a
[Link] b. Check box c. Menu item d. Text box Label
61. ItemListener event defines this method...
Answer: d
a)itemEventChanged( ) b)itemEventOcurred( ) c)itemValueChanged( ) d)itemStateChanged( )
62. KeyEvent is generated in following sequence...
Answer: c
a)Key typed, pressed, released b)Key released, typed, pressed c)Key pressed, typed, released d)Key pressed, released, typed
63. The Delegation Event Model is based on the concept of _____________
Answer: c
a. Source b. Listener c. Both a & b d. None of these
64.. A source generates an event and sends it to ___________ listeners that can handle the event:
Answer: c
a. One b. Two c. One or more d. None of these