Question
analyze the following code : import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Test extends JFrame implements ActionListener { public void Test() { JButton jbtOK
analyze the following code :
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Test extends JFrame implements ActionListener { public void Test() { JButton jbtOK = new JButton("OK"); getContentPane().add(jbtOK); } public void actionPerformed(ActionEvent e) { System.out.println("The OK button is clicked"); } public static void main(String[] args) { JFrame frame = new Test(); frame.setSize(300, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
what is the answer
A) The message "The OK button is clicked" is displayed when you click the OK button.
B) The program has a syntax error because no listeners are registered with jbtOK.
C) The program has a runtime error because no listeners are registered with jbtOK.
D) The actionPerformed method is not executed when you click the OK button, because no instance of Test is registered with jbtOK.
E) None of the above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started