This section of our 1000+ Java MCQs focuses on event listener interfaces in Java Programming Language.
1. Which of these packages contains all the event handling interfaces?
a) java.lang
b) java.awt
c) java.awt.event
d) java.event
View Answer
Explanation: None.
2. Which of these interfaces handles the event when a component is added to a container?
a) ComponentListener
b) ContainerListener
c) FocusListener
d) InputListener
View Answer
Explanation: The ContainerListener defines methods to recognize when a component is added to or removed from a container.
3. Which of these interfaces define a method actionPerformed()?
a) ComponentListener
b) ContainerListener
c) ActionListener
d) InputListener
View Answer
Explanation: ActionListener defines the actionPerformed() method that is invoked when an adjustment event occurs.
4. Which of these interfaces define four methods?
a) ComponentListener
b) ContainerListener
c) ActionListener
d) InputListener
View Answer
Explanation: ComponentListener defines four methods componentResized(), componentMoved(), componentShown() and componentHidden().
5. Which of these interfaces define a method itemStateChanged()?
a) ComponentListener
b) ContainerListener
c) ActionListener
d) ItemListener
View Answer
Explanation: None.
6. Which of these methods will respond when you click any button by mouse?
a) mouseClicked()
b) mouseEntered()
c) mousePressed()
d) all of the mentioned
View Answer
Explanation: 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().
7. Which of these methods will be invoked if a character is entered?
a) keyPressed()
b) keyReleased()
c) keyTyped()
d) keyEntered()
View Answer
Explanation: None.
8. Which of these methods is defined in MouseMotionAdapter class?
a) mouseDragged()
b) mousePressed()
c) mouseReleased()
d) mouseClicked()
View Answer
Explanation: The MouseMotionAdapter class defines 2 methods – mouseDragged() and mouseMoved.
9. Which of these is a superclass of all Adapter classes?
a) Applet
b) ComponentEvent
c) Event
d) InputEvent
View Answer
Explanation: All Adapter classes extend Applet class.
Sanfoundry Global Education & Learning Series Java Programming Language.
- Practice Programming MCQs
- Check Java Books
- Practice BCA MCQs
- Apply for Java Internship
- Apply for Computer Science Internship