Java Questions & Answers – Event Listeners Interfaces

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

Answer: c
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

Answer: b
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

Answer: c
Explanation: ActionListener defines the actionPerformed() method that is invoked when an adjustment event occurs.
advertisement
advertisement

4. Which of these interfaces define four methods?
a) ComponentListener
b) ContainerListener
c) ActionListener
d) InputListener
View Answer

Answer: a
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

Answer: d
Explanation: None.
Note: Join free Sanfoundry classes at Telegram or Youtube

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

Answer: d
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

Answer: c
Explanation: None.
advertisement

8. Which of these methods is defined in MouseMotionAdapter class?
a) mouseDragged()
b) mousePressed()
c) mouseReleased()
d) mouseClicked()
View Answer

Answer: a
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

Answer: a
Explanation: All Adapter classes extend Applet class.
advertisement

Sanfoundry Global Education & Learning Series – Java Programming Language.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.