Multiple Choice
Why doesn't the following code compile correctly? import java.awt.*;
Import java.awt.event.*;
Import javax.swing.*;
Public class ColorCheckBoxWindow extends JFrame
{
Private JCheckBox greenCheckBox;
Private final int WINDOW_WIDTH = 300,WINDOW_HEIGHT = 100;
Public ColorCheckBoxWindow()
{
SetTitle("Green Check Box") ;
SetSize(WINDOW_WIDTH,WINDOW_HEIGHT) ;
SetDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
GreenCheckBox = new JCheckBox("Green") ;
GreenCheckBox.addItemListener(new CheckBoxListener() ) ;
SetLayout(new FlowLayout() ) ;
Add(greenCheckBox) ;
SetVisible(true) ;
}
Public void itemStateChanged(ItemEvent e)
{
If (e.getSource() == greenCheckBox)
{
System.exit(0) ;
}
}
}
A) ColorCheckBoxWindow is not implementing the correct listener
B) The button cannot be added to the content pane
C) The itemStateChanged method cannot be coded here
D) greenCheckBox should not be a private member
Correct Answer:

Verified
Correct Answer:
Verified
Q2: This layout manager arranges components in regions
Q4: When a splash screen is displayed, the
Q17: What does the following statement do? addButton.addActionListener(new
Q23: Which of the following statements is not
Q26: In Java,the ability to display splash screens
Q37: To include Swing and AWT components in
Q38: _ is a library of classes that
Q41: Event listeners must:<br>A) implement an interface<br>B) be
Q45: Assume that radio references a JRadioButton object.
Q48: When a component is added to a