Given the code below, indicate which statement describes its behavior. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Quiz3A extends JFrame implements ActionListener { public Quiz3A() { JButton okButton = new JButton(“OK”);
Question 13 (5 points)
Given the code below, indicate which statement describes its behavior.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Quiz3A extends JFrame implements ActionListener
{
public Quiz3A()
{
JButton okButton = new JButton(“OK”);
add(okButton);
}
public void actionPerformed(ActionEvent e)
{
System.out.println(“The OK button is clicked”);
}
public static void main(String[] args)
{
JFrame frame = new Quiz3A();
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Question 13 options:
| The actionPerformed method is not executed when you click the OK button, because no instance of Quiz3A is registered with okButton |
| The program has a compilation error because no listeners are registered for okButton |
| The program has a runtime error because no listeners are registered with okButton |
| The message The OK button is clicked is displayed when you click the OK button |