250+ TOP MCQs on MouseEvent, TextEvent & WindowEvent Class and Answers

This set of Java Questions and Answers for Aptitude test on “MouseEvent, TextEvent & WindowEvent Class”.

1. Which of these events is generated when the window is closed?
a) TextEvent
b) MouseEvent
c) FocusEvent
d) WindowEvent

Answer: d
Clarification: A WindowEvent is generated when a window is opened, close, activated or deactivated.

2. Which of these methods can be used to obtain the coordinates of a mouse?
a) getPoint()
b) getCoordinates()
c) getMouseXY()
d) getMouseCordinates()

Answer: a
Clarification: 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.

3. Which of these methods can be used to change location of an event?
a) ChangePoint()
b) TranslatePoint()
c) ChangeCordinates()
d) TranslateCordinates()

Answer: b
Clarification: None.

4. 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
Clarification: TextEvent defines a single integer constant TEXT_VALUE_CHANGED.

5. Which of these methods is used to obtain the object that generated a WindowEvent?
a) getMethod()
b) getWindow()
c) getWindowEvent()
d) getWindowObject()

Answer: b
Clarification: None.

6. MouseEvent is subclass of which of these classes?
a) ComponentEvent
b) ContainerEvent
c) ItemEvent
d) InputEvent

Answer: d
Clarification: None.

7. Which of these methods is used to get x coordinate of the mouse?
a) getX()
b) getXCoordinate()
c) getCoordinateX()
d) getPointX()

Answer: a
Clarification: getX() and getY() are used to obtain X AND Y coordinates of the mouse.

8. 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
Clarification: WindowEvent class defines 7 constants – WINDOW_ACTIVATED, WINDOW_CLOSED, WINDOW_OPENED, WINDOW_DECONIFIED, WINDOW_CLOSING, WINDOW_DEACTIVATED, WINDOW_ICONIFIED.

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

Answer: b
Clarification: ComponentEvent is superclass of ContainerEvent, FocusEvent, KeyEvent, MouseEvent and WindowEvent.

Leave a Reply

Your email address will not be published. Required fields are marked *