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

C# Questions & Answers on Fundamentals of Exception Handling for Freshers

1. Which among the following is NOT an exception? a) Stack Overflowb) Arithmetic Overflow or underflowc) Incorrect Arithmetic Expressiond) All of the mentioned Answer: c 2. Which among the follow...

Linux Questions & Answers on File Management for Freshers

1. By default if any regular file is created, the number of link is displayed as 1 ? a) Trueb) False Answer: a 2. How many links are created when we creat a directory file? a) 1b) 2c) 3d) 4 Ans...

C# Questions & Answers on Interfaces Introduction for Freshers

1. Which statement correctly defines Interfaces in C#.NET? a) Interfaces cannot be inheritedb) Interfaces consists of data static in nature and static methodsc) Interfaces consists of only method d...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item