Java Event Handling MCQs Questions | Java Program MCQs
1.what is an event in java?
A.An action or occurrence to which a program can respond
B.A Java class that handles exceptions
C.A type of exception
D.A data type
2.In Java event handling, what is an event source?
A.An event listener
B.A keyword used to declare events
C.A method that handles events
D.An object that generates events
3.
Which package in Java contains classes for event handling?
A.`java.util`
B.`java.swing`
C.`java.awt.event`
D.`java.io`
4.
What is an event listener in Java?
A.A Java class that generates events
B.An object that listens for events and responds to them
C.A method that handles events
D.None of These
5.
In Java, which method is used to register an event listener with an event source?
A.`addEventListener()`
B.`addEventSource()`
C.`addActionListener()`
D.`addEventHandler()`
6.
What is the purpose of the `ActionEvent` class in Java event handling?
A.It represents an exception
B.It represents a listener interface
C.It represents an event source
D.It represents an action event generated by a component like a button
7.
In Java event handling, what is the purpose of the `getSource()` method of the `ActionEvent` class?
A.It returns the object that generated the event
B.It returns the event listener object
C.It returns the event source
D.It returns the event type
8.
Which event listener interface is used for handling action events in Java?
A.`ActionHandler`
B.`EventHandler`
C.`EventListener`
D.`ActionListener`
9.
In Java, how do you specify that an event should trigger a particular method for event handling?
A.By using a keyword in the event source declaration
B.By adding a random method to the event source
C.By implementing an event listener interface and overriding its method
D.By using the `performEvent()` method10.
What is the purpose of the `ItemEvent` class in Java event handling?
A.It represents an event source
B.It represents an item event generated by components like checkboxes and radio buttons
C.It represents an event listener
D.None of These
11.
In Java event handling, which method is used to handle item events for a checkbox?
A.`handleCheckbox()`
B.`onItemEvent()`
C.`itemStateChanged()`
D.`checkboxSelected()`
Pause
Unmute
Loaded%0 :
Fullscreen
12.
What is the purpose of the `MouseListener` interface in Java event handling?
A.It represents an exception
B.It represents an event source
C.It represents an event listener
D.It provides methods for handling mouse-related events
13.
In Java event handling, what is the purpose of the `MouseEvent` class?
A.It represents mouse-related events and provides information about them
B.It represents an exception
C.It represents an event listener
D.It represents an event source
14.
Which method is used to handle mouse clicks in Java event handling?
A.`clickEvent()`
B.`onMouseClick()`
C.`handleClick()`
D.`mouseClicked()`
15.
In Java event handling, what is the purpose of the `KeyEvent` class?
A.It represents an exception
B.It represents an event source
C.It represents keyboard-related events
D.It represents an event listener
16.
In Java event handling, which interface is used for handling window events like closing a window?
A.`WindowHandler`
B.`WindowListener`
C.`WindowEvent`
D.None of These
Answer & Solution Discuss in Board Save for Later
17.
What is the purpose of the `WindowEvent` class in Java event handling?
A.It represents an event listener
B.It represents an event source
C.It represents window-related events
D.It represents an exception
18.
In Java event handling, which method is used to handle window closing events?
A.`closeWindow()`
B.`onWindowClose()`
C.`handleClose()`
D.`windowClosing()`
19.
What is the purpose of the `ActionCommand` in Java event handling?
A.It provides a string that describes the action command associated with an event
B.It handles exceptions
C.It represents an event source
D.It represents an event listener
20.
In Java event handling, which event is generated when a button is clicked?
A.KeyEvent
B.WindowEvent
C.MouseEvent
D.ActionEvent
21.
Which method is used to handle mouse drag events in Java event handling?
A.`handleDrag()`
B.`onMouseDrag()`
C.`mouseDragged()`
D.`dragEvent()`
22.
What is the purpose of the `FocusEvent` class in Java event handling?
A.It represents an event source
B.It represents focus-related events
C.It represents an event listener
D.None of These
23.
In Java event handling, which method is used to handle focus gained events?
A.`focusEvent()`
B.`onFocusGained()`
C.`focusGained()`
D.`handleFocus()`
24.
What is the purpose of the `KeyEventDispatcher` interface in Java event handling?
A.It represents an exception
B.It represents an event source
C.It represents an event listener
D.It provides methods for dispatching keyboard-related events
25.
In Java event handling, what is the purpose of the `MouseWheelEvent` class?
A.It represents mouse wheel-related events
B.It represents an exception
C.It represents an event source
D.It represents an event listener
26.
Which method is used to handle mouse wheel events in Java event handling?
A.`wheelEvent()`
B.`onMouseWheelMove()`
C.`handleMouseWheel()`
D.`mouseWheelMoved()`
27.
In Java event handling, what is the purpose of the `WindowAdapter` class?
A.It represents an exception
B.It represents an event source
C.It provides default implementations of the `WindowListener` interface methods
D.It represents an event listener
28.
What is the purpose of the `InputEvent` class in Java event handling?
A.It represents an event source
B.It represents input-related events
C.It represents an event listener
D.None of These
29.
Which method is used to handle input events in Java event handling?
A.`processInput()`
B.`onInputEvent()`
C.`inputEvent()`
D.`handleInput()`
30.
In Java event handling, what is the purpose of the `MouseListenerAdapter` class?
A.It represents an exception
B.It represents an event source
C.It represents an event listener
D.It provides default implementations of the `MouseListener` interface methods
31.
Which of these is superclass of ContainerEvent class?
A.WindowEvent
B.ComponentEvent
C.ItemEvent
D.InputEvent
32.
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
33.
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()
34.
Which of these packages contains all the event handling interfaces?
A.java.lang
B.java.awt
C.java.awt.event
D.java.event
35.
Which of these interfaces define a method itemStateChanged()?
A.ComponentListener
B.ContainerListener
C.ActionListener
D.ItemListener
36.
Which of these is superclass of WindowEvent class?
A.WindowEvent
B.ComponentEvent
C.ItemEvent
D.InputEvent
37.
Which of these are integer constants of TextEvent class?
A.TEXT_CHANGED
B.TEXT_FORMAT_CHANGED
C.TEXT_VALUE_CHANGED
D.TEXT_SIZE_CHANGED
38.
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
39.
Which of these are integer constants of ComponentEvent class?
A.COMPONENT_HIDDEN
B.COMPONENT_MOVED
C.COMPONENT_RESIZE
D.All of the mentioned
40.
Which of these are constants defined in WindowEvent class?
A.WINDOW_ACTIVATED
B.WINDOW_CLOSED
C.WINDOW_DEICONIFIED
D.All of the mentioned
41.
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
42.
Which of these methods are used to register a mouse motion listener?
A.addMouse()
B.addMouseListener()
C.addMouseMotionListner()
D.eventMouseMotionListener()
43.
Which of these events is generated when the window is closed?
A.TextEvent
B.MouseEvent
C.FocusEvent
D.WindowEvent
44.
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
45.
Which of these methods can be used to know which key is pressed?
A.getKey()
B.getModifier()
C.getActionKey()
D.getActionEvent()
46.
Which of these events is generated when a button is pressed?
A.ActionEvent
B.KeyEvent
C.WindowEvent
D.AdjustmentEvent
47.
Which of these methods can be used to know the type of focus change?
A.typeFocus()
B.typeEventFocus()
C.isTemporary()
D.isPermanent()
48.
Which of these methods will be invoked if a character is entered?
A.keyPressed()
B.keyReleased()
C.keyTyped()
D.keyEntered()
49.
Which of these methods can be used to determine the type of adjustment event?
A.getType()
B.getEventType()
C.getAdjustmentType()
D.getEventObjectType()
50.
Which of these methods is defined in MouseMotionAdapter class?
A.mouseDragged()
B.mousePressed()
C.mouseReleased()
D.mouseClicked()
51.
Which of these events will be generated if we close an applet's window?
A.ActionEvent
B.ComponentEvent
C.AdjustmentEvent
D.WindowEvent
52.
MouseEvent is subclass of which of these classes?
A.ComponentEvent
B.ContainerEvent
C.ItemEvent
D.InputEvent
53.
Event class is defined in which of these libraries?
A.java.io
B.java.lang
C.java.net
D.java.util
54.
Which of these events is generated by scroll bar?
A.ActionEvent
B.KeyEvent
C.WindowEvent
D.AdjustmentEvent
55.
Which of these events is generated when the size of an event is changed?
A.ComponentEvent
B.ContainerEvent
C.FocusEvent
D.InputEvent
56.
Which of these methods can be used to determine the type of event?
A.getID()
B.getSource()
C.getEvent()
D.getEventObject()
57.
Which of these methods can be used to change location of an event?
A.ChangePoint()
B.TranslatePoint()
C.ChangeCordinates()
D.TranslateCordinates()
58.
Which of these events is generated when computer gains or loses input focus?
A.ComponentEvent
B.ContainerEvent
C.FocusEvent
D.InputEvent
59.
Which of these methods is used to get x coordinate of the mouse?
A.getX()
B.getXCoordinate()
C.getCoordinateX()
D.getPointX()
60.
Which of these interfaces handles the event when a component is added to a container?
A.ComponentListener
B.ContainerListener
C.FocusListener
D.InputListener
61.
Which of these methods can be used to obtain the command name for invoking ActionEvent
object?
A.getCommand()
B.getActionCommand()
C.getActionEvent()
D.getActionEventCommand()
62.
Which of these methods can be used to get reference to a component that was removed from a
container?
A.getComponent()
B.getchild()
C.getContainerComponent()
D.getComponentChild()
63.
Which of these are integer constants defined in ActionEvent class?
A.ALT_MASK
B.CTRL_MASK
C.SHIFT_MASK
D.All of the mentioned
64.
Which of these interfaces define four methods?
A.ComponentListener
B.ContainerListener
C.ActionListener
D.InputListener
65.
FocusEvent is subclass of which of these classes?
A.ComponentEvent
B.ContainerEvent
C.ItemEvent
D.InputEvent
66.
Which of these methods are used to register a keyboard event listener?
A.KeyListener()
B.addKistener()
C.addKeyListener()
D.eventKeyboardListener()
67.
Which of these is a superclass of all Adapter classes?
A.Applet
B.ComponentEvent
C.Event
D.InputEvent
68.
Which of these events is generated when the component is added or removed?
A.ComponentEvent
B.ContainerEvent
C.FocusEvent
D.InputEvent
69.
Which of these methods is used to obtain the object that generated a WindowEvent?
A.getMethod()
B.getWindow()
C.getWindowEvent()
D.getWindowObject()
70.
Which of these interfaces define a method actionPerformed()?
A.ComponentListener
B.ContainerListener
C.ActionListener
D.InputListener
71.
Which of these methods can be used to obtain the coordinates of a mouse?
A.getPoint()
B.getCoordinates()
C.getMouseXY()
D.getMouseCordinates()
72.
Which of these methods can be used to obtain the reference to the container that generated a
ContainerEvent?
A.getContainer()
B.getContainerCommand()
C.getActionEvent()
D.getContainerEvent()
73.
Which of these events will be notified if scroll bar is manipulated?
A.ActionEvent
B.ComponentEvent
C.AdjustmentEvent
D.WindowEvent
74.
Which of these methods will respond when you click any button by mouse?
A.mouseClicked()
B.mouseEntered()
C.mousePressed()
D.all of the mentioned
75.
Which of these class is super class of all the events?
A.EventObject
B.EventClass
C.ActionEvent
D.ItemEvent