Originally posted by Sonali:
Following is the question from Exam cram page 112 chapter #6
Consider the following Code
int evtCt=0;
AWTEvent lastE;
public void saveEvent(AWTEvent evt)
{
lastE = evt;
evtCT++;
}
Which of the follwoing calls of saveEvent would run without causing an exception.
a: an AWTEvent object refrence
b: an ActionEvent object refrence
c: an EventObiect object refrence
d: a null value
Answer is
a, b,d
If someone can explain this..
Sonali
a - AwtEvent is the Object reference in the parameter list
b - is a subclass of AwtEvent so, it has everthing it needs (and more)
d - null is always a valid reference however you have to use caution on any operations which try to use it.
c - is incorrect because it is the super class to AwtEvent, super classes have some of the functionality of the subclass but, may and usually don't have all of them so, can't be used.