Study the following code import javaawt import javaawtevent

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

Solution

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

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)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site