Quiz 11

Wednesday

With a piece of paper, write down your name and answers to the following questions.

  1. What method do you use to place a JMenuBar on a JFrame?

    1. setJMenuBar
    2. placeJMenuBar
    3. addJMenuBar
    4. insertJMenuBar
  2. What is the default selection mode for JList?

    1. single selection
    2. multiple selection
    3. single interval selection
    4. multiple interval selection
  3. Describe what the following program does.

    1. What is displayed in the window?

      The window it titled as “Quiz #11 Question #4”. The window contains a button with text “Button”.

    2. What happens when the button is pressed?

      When the button is clicked, a message window appears, centered on top of the main window. This popup window is titled as “Popup Message” and it contains a message “Hello World”.

    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.WindowConstants;

    public final class Program implements Runnable {
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Program());
      }

      @Override
      public void run() {
        MainWindow window = new MainWindow();
        window.setVisible(true);
      }
    }

    final class MainWindow extends JFrame {

      public MainWindow() {
        super("Quiz #11 Question #4");

        this.setLayout(new FlowLayout());
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        final JButton button = new JButton("Button");
        this.add(button);
        this.pack();

        button.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(
              MainWindow.this,
              "Hello World",
              "Popup Message",
              JOptionPane.PLAIN_MESSAGE);
          }
        });
      }
    }

Student Performance and Statistics

A histogram of student performance on percentage grades for Quiz 11 on Wednesday.

100% 10 90 - 99% 0 80 - 89% 4 70 - 79% 0 60 - 69% 0 50 - 59% 0 40 - 49% 0 30 - 39% 0 20 - 29% 0 10 - 19% 0 0 - 9% 0

A table showing the average performance for each question in Quiz 11 on Wednesday.

Q1 0.9 / 1 Q2 1.0 / 1 Q3 2.8 / 3