Solved

Consider the Following Code Snippet

Question 9

Multiple Choice

Consider the following code snippet:
Class MyListener implements ActionListener
{
Public void actionPerformed(ActionEvent event)
{
System.out.println(event) ;
}
}
timer t = new Timer(interval, listener) ;
t.start() ;
What is wrong with this code?


A) The Timer object should be declared before the MyListener class.
B) The listener must be declared as new MyListener() .
C) The Timer object must be declared as final.
D) The word listener should be change to MyListener.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions