• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marcus Green Exam #3, Question 59

 
Jon Dalberg
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the question:
Which of the following statements are true?
1) The x,y coordinates of an instance of MouseEvent can be obtained using the getX() and getY() methods
2) The x,y coordinates of an instance of MouseEvent can be obtained using the X and Y integer fields
3) The time of a MouseEvent can be extracted using the getTime() method
4) The time of a MouseEvent can be extracted using the when parameter of the MouseEvent constructor
According to the exam, the answers are 1 and 4. However, I disagree. Maybe it's just semantics but if a MouseEvent is passed to a MouseListener or a MouseMotionListener, there is no way to 'extract' the time of the MouseEvent from the constructor.
I think the only correct answer is 1. Anyone else?
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jon,
That one stumped me also. I think, to give Marcus the benefit of the doubt, the logic goes like this:
MouseEvent extends InputEvent
InputEvent has a method: getWhen() that can be used to return the time when the event occurred. The value that is returned from the method is set inside the MouseEvent constructor which accepts a when parameter ...
Confused yet?
Manfred.
 
Jon Dalberg
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manfred Leonhardt:
Hi Jon,
That one stumped me also. I think, to give Marcus the benefit of the doubt, the logic goes like this:
MouseEvent extends InputEvent
InputEvent has a method: getWhen() that can be used to return the time when the event occurred. The value that is returned from the method is set inside the MouseEvent constructor which accepts a when parameter ...
Confused yet?
Manfred.

I agree that you can pass the time when a MouseEvent is 'created', but you can't 'extract' the time from a MouseEvent's ctor; you must use the getWhen() method. Perhaps the wording is ambiguous.
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My logic was based on the following description of the constructor
(just cut and pasted from http://java.sun.com/products/jdk/1.2/docs/api/java/awt/event/MouseEvent.html)
MouseEvent(Component�source,
int�id,
long�when,
int�modifiers,
int�x,
int�y,
int�clickCount, boolean�popupTrigger)

I picked on the when parameter as being available. Does that make sense?. I'm keen to ensure my questions are not ambiguous, let me know what you think.
Marcus
 
Jon Dalberg
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marcus Green:
My logic was based on the following description of the constructor
(just cut and pasted from http://java.sun.com/products/jdk/1.2/docs/api/java/awt/event/MouseEvent.html)
MouseEvent(Component�source,
int�id,
long�when,
int�modifiers,
int�x,
int�y,
int�clickCount, boolean�popupTrigger)

I picked on the when parameter as being available. Does that make sense?. I'm keen to ensure my questions are not ambiguous, let me know what you think.
Marcus

If you had said
4) The time of a MouseEvent can be extracted FROM the when parameter of the MouseEvent constructor
then I would say the 4 is also a valid choice. I think it's a little ambiguous with the word 'using' because it implies that one can use the when parameter from the ctor.
 
Russell Tao
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jon Dalberg:


If you had said

4) The time of a MouseEvent can be extracted FROM the when parameter of the MouseEvent constructor

then I would say the 4 is also a valid choice. I think it's a little ambiguous with the word 'using' because it implies that one can use the when parameter from the ctor.

It is not a little ambiguous. It's totally ambiguous.
Just wonder why they make scjp questions so impratical, nonesense, rubbish, useless....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic