Java MCQs on event listener interfaces in Java Programming Language.
1. Which of these packages contains all the event handling interfaces? Answer: c 2. Which of these interfaces handles the event when a component is added to a container? Answer: b 3. Which of these interfaces define a method actionPerformed()? Answer: c 4. Which of these interfaces define four methods? Answer: a 5. Which of these interfaces define a method itemStateChanged()? Answer: d 6. Which of these methods will respond when you click any button by mouse? Answer: d 7. Which of these methods will be invoked if a character is entered? Answer: c 8. Which of these methods is defined in MouseMotionAdapter class? Answer: a 9. Which of these is a superclass of all Adapter classes? Answer: a
a) java.lang
b) java.awt
c) java.awt.event
d) java.event
Clarification: None.
a) ComponentListener
b) ContainerListener
c) FocusListener
d) InputListener
Clarification: The ContainerListener defines methods to recognize when a component is added to or removed from a container.
a) ComponentListener
b) ContainerListener
c) ActionListener
d) InputListener
Clarification: ActionListener defines the actionPerformed() method that is invoked when an adjustment event occurs.
a) ComponentListener
b) ContainerListener
c) ActionListener
d) InputListener
Clarification: ComponentListener defines four methods componentResized(), componentMoved(), componentShown() and componentHidden().
a) ComponentListener
b) ContainerListener
c) ActionListener
d) ItemListener
Clarification: None.
a) mouseClicked()
b) mouseEntered()
c) mousePressed()
d) all of the mentioned
Clarification: when we click a button, first we enter the region of button hence mouseEntered() method responds then we press the button which leads to respond from mouseClicked() and mousePressed().
a) keyPressed()
b) keyReleased()
c) keyTyped()
d) keyEntered()
Clarification: None.
a) mouseDragged()
b) mousePressed()
c) mouseReleased()
d) mouseClicked()
Clarification: The MouseMotionAdapter class defines 2 methods – mouseDragged() and mouseMoved.
a) Applet
b) ComponentEvent
c) Event
d) InputEvent
Clarification: All Adapter classes extend Applet class.
