Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Sanjivani Rural Education Society’s

SANJIVANI K. B. P. POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST: AHMEDNAGAR / 63
2023-2024
Sub Name : Advanced Java Programming (AJP-22517) Course Code : CM-5-I
Name : Date: / /2023
Roll No : Set: I
Practice Test: [ Unit III -Event Handling ]

1.The Following steps are required to perform Implement the Listener interface and overrides its Methods Register the
component with the Listener
(a) Exception Handling (b) String Handling (c) Event Handling (d) None of the above

2.In which places can put the event handling code


(a) Same class (b) Other class (c) Annonymous class (d) All mentioned above

3.Which package provides many event classes and Listener interfaces for event handling?
(a) java.awt (b) java.awt.Graphics (c) java.awt.event (d) None of the above

4. To use the ActionListener interface it must be implemented by a class there are several ways to do that find in the
following?
(a) Creating a new class (b) using the class the graphical component
(c) an anonymous inner class (d) All mentioned above

5. The ActionListener interface is not used for handling action events?


(a) True (b) False

6. The ActionListener interface is used for handling action events, For example, it's used by a
(a) JButton (b) JCheckbox (c) All of these (d) JMenuItem

7. Which class is used for this Processing Method processActionEvent( )?


(a) Button,List,MenuItem (b) Button,Checkbox,Choice (c) Scrollbar,Component,Button (d) None of the above

8. In Graphics class Which method is used to set the graphics current color to the specified color?
(a) public abstract void setFont(Font font) (b) public abstract void setColor(Color c)
(c) public abstract void drawString(String str, int x, int y) (d) None of the above

9. Which of the following method is used to determine the type of adjustment event?
(a) getType( ) (b) getEventType( ) (c) getAdjustmentType( ) (d) getEventObjectType( )

10. TextField generates ____________ event.


(a) ActionEvent,ItemEvent (b) ActionEvent, TextEvent (c) ScrollEvent,TextEvent (d) ActionEvent, ScrollEvent

11. What is an event in delegation event model used by Java programming language?
a) An event is an object that describes a state change in a source
b) An event is an object that describes a state change in processing
c) An event is an object that describes any change by the user and system
d) An event is a class used for defining object, to create events

12. Which of these methods can be used to know which key is pressed?
a) getKey() b) getModifier() c) getActionKey() d) getActionEvent()
13. What is a listener in context to event handling?
a) A listener is a variable that is notified when an event occurs
b) A listener is a object that is notified when an event occurs
c) A listener is a method that is notified when an event occurs
d) None of the mentioned

14. Which of these methods are used to register a mouse motion listener?
a) addMouse() b) addMouseListener() c) addMouseMotionListner() d) eventMouseMotionListener()

15. Which of these constant value will change when the button at the end of scroll bar was clicked to increase its value?
a) BLOCK_DECREMENT b) BLOCK_INCREMENT c) UNIT_DECREMENT d) UNIT_INCREMENT

16. Which of these events is generated when the component is added or removed?
a) ComponentEvent b) ContainerEvent c) FocusEvent d) InputEvent

17. Which of these methods can be used to obtain the command name for invoking ActionEvent object?
a) getCommand() b) getActionCommand() c) getActionEvent() d) getActionEventCommand()

18. Which of these are integer constants of ComponentEvent class?


a) COMPONENT_HIDDEN b) COMPONENT_MOVED c) COMPONENT_RESIZE d) All of the mentioned

19. Which of these events is generated when computer gains or loses input focus?
a) ComponentEvent b) ContainerEvent c) FocusEvent d) InputEvent

20. Which of these methods can be used to obtain the coordinates of a mouse?
a) getPoint() b) getCoordinates() c) getMouseXY() d) getMouseCordinates()

21. void keyTyped(KeyEvent ke) called when a key on the keyboard is ______.
(a) pressed and then released. (b) pressed (c) released (d) none of the above

22. Which event is generated when the position of scrollbar is changed?


(a) KeyEvent (b) MouseEvent (c) ItemEvent (d) AdjustmentEvent

23. Which class is used for this processing method processActionEvent() method?
(a) Button, List, Menultem (b) Button, Checkbox, Choice (c) ScrollBar, Component, Button (d) None of the above.

24. Which of the following constant is not defined in WindowEvent class?


(a) WINDOW ACTIVATED (b) WINDOW CLOSED (c) WINDOW DEICONIFIED (d) None of these

25. When we need to use Checkbox or Item from the list or use a checkable Menu an____________is generated.
(a) ActionEvent (b) ItemEvent (c) MenuEvent (d) ClickEvent

26. What is the use of String getActionCommand() method of ActionEvent class?


a) to obtain the label (caption) of Button. b) to obtain the reference of Button
c) to obtain object of Button d) to obtain the label (caption) and object of Button.

27. Clicking the closing button on the upper right corner of a frame generates a _____event.
a) ItemEvent b) WindowEvent c) MouseMotionEvent d) ComponentEvent

28. Which of these interfaces define a method actionPerformed().


a) ComponentListener b)ContainerListener c) ActionListener d) InputListener
29. The MouseListener interface is used to make mouse handling.
a) True b) False

30. Component Event is super class of_______.


a) FocusEvent b) WindowEvent c) MouseEvent (d) All of the above

31. Which of these packages contains all the classes and methods required for even handling in Java?
a) java.applet b) java.awt c) java.event d) java.awt.event

32. Event class is defined in which of these libraries?


a) java.io b) java.lang c) java.net d) java.util

33. Which of these methods can be used to determine the type of event?
a) getID() b) getSource() c) getEvent() d) getEventObject()

34. Which of these class is super class of all the events?


a) EventObject b) EventClass c) ActionEvent d) ItemEvent

35. Which of these events will be notified if scroll bar is manipulated?


a) ActionEvent b) ComponentEvent c) AdjustmentEvent d) WindowEvent

36. Which of these events will be generated if we close an applet’s window?


a) ActionEvent b) ComponentEvent c) AdjustmentEvent d) WindowEvent

37. Which of the following component generates ActionEvent?


(a) Window (b) RadioButton (c) ScrollBar (d) None of these

38. The MouseListener interface is used to make mouse handling.


(a) True (b) False

39. ComponentEvent is the super class of __________.


a) FocusEvent b)MouseEvent c)Window Event d)All of the above

40. If we close an applet window _________ events will be generated.


(a) ActionEvent (b)ComponentEvent (c)AdjustmentEvent (d) WindowEvent

41. Name the method defined in EventObject class that returns the object generated from the event.
(a) getEvent() (b) getObject( ) (c) getId( ) (d) getSource( )

42. MouseEvent is subclass of which of the following class?


a) ComponentEvent b) ContainerEvent c)ItemEvent d)InputEvent

43. What is the use of String getActionCommand( ) method of ActionEvent class


(a)to obtain the label (caption) of Button (b)to obtain the reference of Button
(c)to obtain object of Button (d)to obtain the label (caption) and object of Button

44. Button Control implements following listener interface.


(a) ItemListener (b)ActionListener (c) FlowListener (d) Adapter

45. If we close an applet windowevents will be generated.


(a) ActionEvent (b) ComponentEvent (c)AdjustmentEvent (d) WindowEvent

46.Name the method defined in EvenObject class that returns the object generated from the event.
(a) getEvent( ) (b) getObject( ) (c) getId( ) (d) getSource( )
47.How to obtain the command name for invoking ActionEvent?
(a) getCommandName( ) (b) getActionEventCommand( ) (c) getActionCmd( ) (d) getActionCommand( )

48. Which of the following method must be overridden in the order to handle KeyEvent.
(a) keyPressed(KeyEvent obj) (b) KeyReleased(KeyEvent obj)
(b) KeyTyped(KeyEvent obj) (d) All of these

49.Which of these methods can be used to know the degree of adjustment made by the user?
(a) getValue( ) (b) getAdjustmentType( ) (c) getAdjustmentValue( ) (d) getAdjustmentAmount()

50.The _________ is an object that is notified when an event occurs.


(a) Listener (b) Sources (c) Event (d) None of the above

51. Which of the following control generates ActionEvent?


a) MenuItem b)Scrollbar c)Button d)Both a) and c)

52. Which of the following methods are the methods of component window?
a) windowClosed() b)windowClosing() c)windowDeiconified() d)All of the above

53. Which of the following control generates ActionEvent and ItemEvent?


a) Button b)List c)Scrollbar d)Choice

54. Event,Listeners are_____


a) Packages b)Classes c)Interfaces d)All of the above

55.Scrollbar control generates ______ event?


a)ActionEvent b)KeyEvent c)MouseEvent d)AdjustmentEvent

55. ______ interface is used to handle button events.


a) ItemListener b)ActionListener c)ButtonListener d)MouseListener

56.The MouseMotionInterface has ______ methods.


a)1 b)0 c)2 d)3

57.Which of the following is not event class in java?


a)ClickEvent b)ItemEvent c)MouseEvent d)None

58. A MenuItem object can generate ______ event.


a) KeyEvent b)MouseEvent c)ActionListener d)ActionEvent

59. Following events require direct interaction of user.


a) ForegroundEvents b)BackgroundEvents c)ActionEvent d)ItemEvent

60. Which of this packages contains all the methods and classes for event handling.
a) java.applet.*; b) java.awt.*; c) java.event.*; d) java.awt.event.*;

61. Which of these methods are used to register a keyboard event listener?
a) KeyListener() b) addKistener() c) addKeyListener() d) eventKeyboardListener()

62. An___ is a change in the state of an item?


a) Source b)Event c) Object d) Listener

63.A____ is an object that is notified when an event occurs?


a) Listener b)Source c) Object d)Event

You might also like