Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

AWT  RSS feed

 
josephine chen
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
josephine chen
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
josephine chen
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
josephine chen
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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!!!.
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!