This set of Java Questions and Answers for Aptitude test focuses 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
View Answer
Explanation: 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()
View Answer
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.
3. Which of these methods can be used to change location of an event?
a) ChangePoint()
b) TranslatePoint()
c) ChangeCordinates()
d) TranslateCordinates()
View Answer
Explanation: 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
View Answer
Explanation: 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()
View Answer
Explanation: None.
6. MouseEvent is subclass of which of these classes?
a) ComponentEvent
b) ContainerEvent
c) ItemEvent
d) InputEvent
View Answer
Explanation: None.
7. Which of these methods is used to get x coordinate of the mouse?
a) getX()
b) getXCoordinate()
c) getCoordinateX()
d) getPointX()
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: ComponentEvent is superclass of ContainerEvent, FocusEvent, KeyEvent, MouseEvent and WindowEvent.
Sanfoundry Global Education & Learning Series Java Programming Language.
To practice all areas of Java for Aptitude test, here is complete set on 1000+ Multiple Choice Questions and Answers on Java.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Check Programming Books
- Check Java Books
- Practice BCA MCQs
- Apply for Java Internship
- Practice Programming MCQs