Java Questions & Answers – MouseEvent, TextEvent & WindowEvent Class

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

Answer: d
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

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.

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

Answer: b
Explanation: None.
advertisement
advertisement

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

Answer: c
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

Answer: b
Explanation: None.

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

Answer: d
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

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

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

Answer: d
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

Answer: b
Explanation: ComponentEvent 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.