Java MCQs on ComponentEvent, ContainerEvent & FocusEvent Classes in Java Programming Language.
1. Which of these events is generated when the size of an event is changed? Answer: a 2. Which of these events is generated when the component is added or removed? Answer: b 3. Which of these methods can be used to obtain the reference to the container that generated a ContainerEvent? Answer: d 4. Which of these methods can be used to get reference to a component that was removed from a container? Answer: b 5. Which of these are integer constants of ComponentEvent class? Answer: d 6. Which of these events is generated when computer gains or loses input focus? Answer: c 7. FocusEvent is subclass of which of these classes? Answer: a 8. Which of these methods can be used to know the type of focus change? Answer: c 9. Which of these is superclass of ContainerEvent class? Answer: b
a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent
Clarification: A ComponentEvent is generated when the size, position or visibility of a component is changed.
a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent
Clarification: A ContainerEvent is generated when a component is added to or removed from a container. It has two integer constants COMPONENT_ADDED & COMPONENT_REMOVED.
a) getContainer()
b) getContainerCommand()
c) getActionEvent()
d) getContainerEvent()
Clarification: None.
a) getComponent()
b) getchild()
c) getContainerComponent()
d) getComponentChild()
Clarification: The getChild() method returns a reference to the component that was added to or removed from the container.
a) COMPONENT_HIDDEN
b) COMPONENT_MOVED
c) COMPONENT_RESIZE
d) All of the mentioned
Clarification: The component event class defines 4 constants COMPONENT_HIDDEN, COMPONENT-MOVED, COMPONENT-RESIZE and COMPONENT-SHOWN.
a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent
Clarification: None.
a) ComponentEvent
b) ContainerEvent
c) ItemEvent
d) InputEvent
Clarification: None.
a) typeFocus()
b) typeEventFocus()
c) isTemporary()
d) isPermanent()
Clarification: 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.
a) WindowEvent
b) ComponentEvent
c) ItemEvent
d) InputEvent
Clarification: ContainerEvent is superclass of ContainerEvent, FocusEvent, KeyEvent, MouseEvent and WindowEvent.