250+ TOP MCQs on Event Listeners Interfaces and Answers

Java MCQs 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

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

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

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

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

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

Answer: d
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().

7. Which of these methods will be invoked if a character is entered?
a) keyPressed()
b) keyReleased()
c) keyTyped()
d) keyEntered()

Answer: c
Clarification: None.

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

  Advanced 250+ TOP MCQs on Web application and Answers

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

Answer: a
Clarification: All Adapter classes extend Applet class.

contest

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top