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
Joined: Jan 09, 2001
Posts: 1492
posted
0
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
Joined: Feb 19, 2001
Posts: 4
posted
0
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.
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
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
Joined: Dec 13, 2004
Posts: 12
posted
0
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....