Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Study the following code: import java.awt.*; import java.awt.event.*; import jav

ID: 3932246 • Letter: S

Question

Study the following code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Test extends A {
   public static void main(String[] args) {
      A frame = new Test();
      frame.setSize(200, 100);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);
   }
}
class A extends JFrame implements ActionListener {
   JButton jbtCancel = new JButton("Cancel");
   JButton jbtok = new JButton("OK");

   public A() {
      getContentPane().setLayout(new FlowLayout());
      getContentPane().add(jbtCancel);
      jbtCancel.addActionListener(this);
      getContentPane().add(jbtok);
      jbtok.addActionListener(this);
   }

   public void actionPerformed(ActionEvent e) {
      if (e.getSource() == jbtCancel) {
         System.out.println("Cancel button is clicked");
      }
      if (e.getSource() == jbtok) {
         System.out.println("OK button is clicked");
      }
   }
}

Select one:

a. The program displays Cancel button on the left of the OK button.

b. When you click the OK button the message "OK button is clicked" is displayed.

c. When you click the Cancel button the message "Cancel button is clicked" is displayed.

d. All of the above

Explanation / Answer

it performs

The program displays Cancel button on the left of the OK button, When you click the OK button the message "OK button is clicked" is displayed and When you click the Cancel button the message "Cancel button is clicked" is displayed.

ANS:

d.all of the above