Java Multiple Choice Questions & Answers on MouseEvent, TextEvent & WindowEvent Class for Freshers

1. Which of these events is generated when the a window is closed?

a) TextEvent
b) MouseEvent
c) FocusEvent
d) WindowEvent
Answer: d

Explanation: A WindowEvent is generated when a window is opened, close, activated or deactivated.
2. Which of these events is generated when the component is added or removed?

a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent
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 coordinates of a mouse?

a) getPoint()
b) getCoordinates()
c) getMouseXY()
d) getMouseCordinates()
Answer: a

Explanation: getPoint() method can be used to obtain coordinates of a mouse, alternatively we can use getX() and getY() methods for x and y coordinates of mouse respectively.
4. Which of these methods can be used to change location of an event?

a) ChangePoint()
b) TranslatePoint()
c) ChangeCordinates()
d) TranslateCordinates()
Answer: b
5. Which of these are integer constants of TextEvent class?

a) TEXT_CHANGED
b) TEXT_FORMAT_CHANGED
c) TEXT_VALUE_CHANGED
d) TEXT_sIZE_CHANGED
Answer: c

Explanation: TextEvent defines a single integer constant TEXT_VALUE_CHANGED.
6. Which of these methods is used to obtain the object that generated a WindowEvent?

a) getMethod()
b) getWindow()
c) getWindowEvent()
d) getWindowObject()
Answer: b
7. MouseEvent is subclass of which of these classes?

a) ComponentEvent
b) ContainerEvent
c) ItemEvent
d) InputEvent
Answer: d
8. Which of these methods is used to get x coordinate of the mouse?

a) getX()
b) getXCoordinate()
c) getCoordinateX()
d) getPointX()
Answer: a

Explanation: getX() and getY() are used to obtain X AND Y coordinates of the mouse.
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 WindowEvent class?

a) WindowEvent
b) ComponentEvent
c) ItemEvent
d) InputEvent
Answer: b

Explanation: ComponentEvent is superclass of ContainerEvent, FocusEvent, KeyEvent, MouseEvent and WindowEvent.

Related

Multiple Choice Questions 2256379733503921138

Post a Comment

emo-but-icon

item