Hi!
The correct answer is A. Why???
Thank you.
26. Which of the following are correct, if you compile the following code?
public class CloseWindow extends Frame implements WindowListener {
public CloseWindow() {
addWindowListener(this); // This is listener registration
setSize(300, 300);
setVisible(true);
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public static void main(
String args[]) {
CloseWindow CW = new CloseWindow();
}
}
A) Compile time error
B) Run time error
C) Code compiles but Frame does not listen to WindowEvents
D) Compile and runs successfully.