File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes AWT Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "AWT" Watch "AWT" New topic
Author

AWT

josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
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

Joined: Jan 30, 2000
Posts: 3215
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.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
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

Joined: Oct 29, 2002
Posts: 216
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

Joined: Jan 30, 2000
Posts: 3215
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

Joined: Jan 30, 2000
Posts: 3215
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

Joined: Oct 29, 2002
Posts: 216

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

Joined: Jan 30, 2000
Posts: 3215
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).]
 
 
subject: AWT
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com