Java Multiple Choice Questions & Answers on Event Listeners Interfaces for Freshers

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

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

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

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()
Answer: c
8. Which of these methods is defined in MouseMotionAdapter class?

a) mouseDragged()
b) mousePressed()
c) mouseReleased()
d) mouseClicked()
Answer: a

Explanation: The MouseMotionAdapter class defines 2 methods – mouseDragged() and mouseMoved.
9. Which of these are constants defined in WindowEvent class?

a) WINDOW_ACTIVATED
b) WINDOW_CLOSED
c) WINDOW_DEICONIFIED
d) All of the mentioned
Answer: d

Explanation: WindowEvent class defines 7 constants – WINDOW_ACTIVATED, WINDOW_CLOSED, WINDOW_OPENED, WINDOW_DECONIFIED, WINDOW_CLOSING, WINDOW_DEACTIVATED, WINDOW_ICONIFIED.
10. Which of these is superclass of all Adapter classes?

a) Applet
b) ComponentEvent
c) Event
d) InputEvent
Answer: a

Explanation: All Adapter classes extend Applet class.

Related

Multiple Choice Questions 5557189857752593270

Post a Comment

emo-but-icon

item