Forums Register Login

AWT

+Pie Number of slices to send: Send
Check my answer
1.Which of the following statements are true about the adapter class:
1)Adapter class may provide the default procesing of an event. -false
2)Every listener interface has a corresponding adapter class.
false
3)All methods in adapter class are empty. -true
4)Adapter class is named according to the events they process.
true
Please explain me the answers.
for this one .I am not sure how to proceed
2.Object
--util.EventObject-awt.AWTEvent
---awt.event.ActionEvent
Suppose we have the following code to count events and save the most recent event
int i =0;
AWTEvent lastE;
public void saveEvent(AWTEvent evt){
lastE = evt;
i++;
}
which of the following calls of saveEvent would run without causing an exception .Select which are correct
call with an AWTEvent obj ref
call with an ActionEvent obj ref
call with an EventObject obj ref
call with null value
Which of the following members is used to find the type of event encapsulated in java.awt.Event class
1. id//true
2. getEventType()//f
3. isMouseEvent()//f
4. getParameters();//f

+Pie Number of slices to send: Send
The answer to the first question is you're correct. The adapter classes are named after but not like the events they process, just in case... They implement all methods which don't do anything but return. So that cannot be considered "default processing" whatever that means.
+Pie Number of slices to send: Send
Sorry Tony...
Please explain me the answers.
for this one .I am not sure how to proceed
2.Object
--util.EventObject-awt.AWTEvent
---awt.event.ActionEvent
Suppose we have the following code to count events and save the most recent event
int i =0;
AWTEvent lastE;
public void saveEvent(AWTEvent evt){
lastE = evt;
i++;
}
which of the following calls of saveEvent would run without causing an exception .Select which are correct
call with an AWTEvent obj ref
call with an ActionEvent obj ref
call with an EventObject obj ref
call with null value
+Pie Number of slices to send: Send
Which of the following members is used to find the type of event encapsulated in java.awt.Event class
1. id//true
2. getEventType()//f
3. isMouseEvent()//f
4. getParameters();//f
+Pie Number of slices to send: Send
I don't want to answer that question just like that because it would not do you (or anyone else reading) any good
However, I will say that this is a OOP question (which are important) so I'll draw a picture from the Sun Java API doc:
<PRE>
java.lang.Object
|
+--java.util.EventObject
|
+--java.awt.AWTEvent
|
+--java.awt.event.ActionEvent
</PRE>
and now it should be apparent what the answer is, right?
If not, ask again. I will give away part of the answer: null wouldn't make it fail.
+Pie Number of slices to send: Send
In your question
"Which of the following members is used to find the type of event encapsulated in java.awt.Event class"
The class name is wrong. It's <CODE>java.awt.AWTEvent</CODE>. The one above is all but replaced by the latter since Java 1.1.
So if you already know the class... why not look into the API doc for java.awt.AWTEvent?
+Pie Number of slices to send: Send

java.lang.Object
| +--java.util.EventObject
| +--java.awt.AWTEvent
| +--java.awt.event.ActionEvent

int i =0;
AWTEvent lastE;
public void saveEvent(AWTEvent evt){
lastE = evt;
i++;
}


saveEvent(ActionEvent);//ok becoz it is subclasss of AWTEvent
saveEvent(AWTEvent) //is ok; as per method call
saveEvent(null) is also ok
so 1,2,4 are correct
am I right in my conclusions???
can i pass "null" to any method that is taking an instance
i think i must checkout this!!!.
+Pie Number of slices to send: Send
Yes your analysis was correct. And it is also legal to pass a null where an object reference variable is expected.
[This message has been edited by Tony Alicea (edited February 21, 2000).]
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 847 times.
Similar Threads
Calling a method
from hardest questions
Question, reference, package
Question from Exam Cram CD!
Calling a method
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:19:17.