Event Listeners Interfaces(Computer Science > Java Program ) Questions and Answers

Question 1.

Which of these is superclass of all Adapter classes?


  1.    Applet
  2.    ComponentEvent
  3.    Event
  4.    InputEvent
Explanation:-
Answer: Option A. -> Applet

All Adapter classes extend Applet class.



Question 2.

Which of these are constants defined in WindowEvent class?


  1.    WINDOW_ACTIVATED
  2.    WINDOW_CLOSED
  3.    WINDOW_DEICONIFIED
  4.    All of the mentioned
Explanation:-
Answer: Option D. -> All of the mentioned

WindowEvent class defines 7 constants - WINDOW_ACTIVATED, WINDOW_CLOSED, WINDOW_OPENED, WINDOW_DECONIFIED, WINDOW_CLOSING, WINDOW_DEACTIVATED, WINDOW_ICONIFIED.



Question 3.

Which of these methods is defined in MouseMotionAdapter class?


  1.    mouseDragged()
  2.    mousePressed()
  3.    mouseReleased()
  4.    mouseClicked()
Explanation:-
Answer: Option A. -> mouseDragged()

The MouseMotionAdapter class defines 2 methods – mouseDragged() and mouseMoved.



Question 4.

Which of these methods will be invoked if a character is entered?


  1.    keyPressed()
  2.    keyReleased()
  3.    keyTyped()
  4.    keyEntered()
Explanation:-
Answer: Option C. -> keyTyped()

None.



Question 5.

Which of these methods will respond when you click any button by mouse?


  1.    mouseClicked()
  2.    mouseEntered()
  3.    mousePressed()
  4.    All of the mentioned
Explanation:-
Answer: Option D. -> All of the mentioned

when we click a button, first we enter the region of button hence mouseEntered() method 


Question 6.

Which of these interfaces define a method itemStateChanged()?


  1.    ComponentListener
  2.    ContainerListener
  3.    ActionListener
  4.    ItemListener
Explanation:-
Answer: Option D. -> ItemListener

None.



Question 7.

Which of these interfaces define four methods?


  1.    ComponentListener
  2.    ContainerListener
  3.    ActionListener
  4.    InputListener
Explanation:-
Answer: Option A. -> ComponentListener

ComponentListener defines four methods componentResized(), componentMoved(), 

componentShown() and componentHidden().



Question 8.

Which of these packages contains all the event handling interfaces?


  1.    java.lang
  2.    java.awt
  3.    java.awt.event
  4.    java.event
Explanation:-
Answer: Option C. -> java.awt.event

None.



Question 9.

Which of these interfaces define a method actionPerformed()?


  1.    ComponentListener
  2.    ContainerListener
  3.    ActionListener
  4.    InputListener
Explanation:-
Answer: Option C. -> ActionListener

ActionListener defines the actionPerformed() method that is invoked when an 

adjustment event occurs.



Question 10.

Which of these interfaces handles the event when a component is added to 

a container?


  1.    ComponentListener
  2.    ContainerListener
  3.    FocusListener
  4.    InputListener
Explanation:-
Answer: Option B. -> ContainerListener

The ContainerListener defines methods to recognize when a component is added to 

or removed from a container.