Java Questions & Answers – ComponentEvent, ContainerEvent & FocusEvent Class

This section of our 1000+ Java MCQs focuses on ComponentEvent, ContainerEvent & FocusEvent Classes in Java Programming Language.

1. Which of these events is generated when the size of an event is changed?
a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent
View Answer

Answer: a
Explanation: A ComponentEvent is generated when the size, position or visibility of a component is changed.

2. Which of these events is generated when the component is added or removed?
a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent
View Answer

Answer: b
Explanation: A ContainerEvent is generated when a component is added to or removed from a container. It has two integer constants COMPONENT_ADDED & COMPONENT_REMOVED.

3. Which of these methods can be used to obtain the reference to the container that generated a ContainerEvent?
a) getContainer()
b) getContainerCommand()
c) getActionEvent()
d) getContainerEvent()
View Answer

Answer: d
Explanation: None.
advertisement
advertisement

4. Which of these methods can be used to get reference to a component that was removed from a container?
a) getComponent()
b) getchild()
c) getContainerComponent()
d) getComponentChild()
View Answer

Answer: b
Explanation: The getChild() method returns a reference to the component that was added to or removed from the container.

5. Which of these are integer constants of ComponentEvent class?
a) COMPONENT_HIDDEN
b) COMPONENT_MOVED
c) COMPONENT_RESIZE
d) All of the mentioned
View Answer

Answer: d
Explanation: The component event class defines 4 constants COMPONENT_HIDDEN, COMPONENT-MOVED, COMPONENT-RESIZE and COMPONENT-SHOWN.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Which of these events is generated when computer gains or loses input focus?
a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent
View Answer

Answer: c
Explanation: None.

7. FocusEvent is subclass of which of these classes?
a) ComponentEvent
b) ContainerEvent
c) ItemEvent
d) InputEvent
View Answer

Answer: a
Explanation: None.
advertisement

8. Which of these methods can be used to know the type of focus change?
a) typeFocus()
b) typeEventFocus()
c) isTemporary()
d) isPermanent()
View Answer

Answer: c
Explanation: There are two types of focus events – permanent and temporary. The isTemporary() method indicates if this focus change is temporary, it returns a Boolean value.

9. Which of these is superclass of ContainerEvent class?
a) WindowEvent
b) ComponentEvent
c) ItemEvent
d) InputEvent
View Answer

Answer: b
Explanation: ContainerEvent is superclass of ContainerEvent, FocusEvent, KeyEvent, MouseEvent and WindowEvent.
advertisement

Sanfoundry Global Education & Learning Series – Java Programming Language.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.