Which of the following class declaration(s) is(are) true?
A.import java.awt.Button;
import java.lang.Runnable;
public class MyClass extends Button implements Runnable{
public void run(){
//Some valid Code
}
}
B.import java.awt.event.*;
import java.applet.Applet;
public class MyApplet extends
Applet,WindowAdapter{
public void windowClosed(WindowEvent we){
//Some Valid Code
}
}
C.import java.lang.Runnable;
public class MyClass implements Runnable{
public void run(){
int i = 10
System.out.println("i = "+i);
}
}
D.import java.awt.event.*;
public class MyClass extends WindowAdapter
implements WindowListener{
public void windowClosed(WindowEvent we){
//Some Valid Code
}
}
I have answered A and C, but the site says answer is A and D.
The Choice D, i think is wrong because when we are implementing an Interface then all its methods are to be overridden other wise the class is to be declared abstract
Can anyone say why choice C is wrong, i dont see anything wrong in it.
Please clear
Thanks in advance
kareem
:roll: