Java MCQ: Which of the following interfaces is used to handle events in Java?
a) Runnable
b) Serializable
c) EventListener
d) Cloneable
Answer:
c) EventListener
Explanation:
The EventListener
interface in Java is used to handle events. It is a marker interface that all event listener interfaces must extend. Event listeners are objects that are notified when an event occurs, allowing the program to respond to user actions such as mouse clicks, key presses, and other interactions.
Java provides a rich set of event listener interfaces, such as ActionListener
, MouseListener
, and KeyListener
, each designed to handle specific types of events.
Understanding how to use event listeners is crucial for developing interactive Java applications, especially in graphical user interface (GUI) programming.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html