Multiple Choice
What is wrong with the following code?
class ExitListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
System.exit(0) ;
}
}
ActionListener exitListener = new ExitListener() ;
JMenu exitMenu = new JMenu("Exit") ;
exitMenu.addActionListener(exitListener) ;
JMenuBar menuBar = new JMenuBar() ;
menuBar.add(exitMenu) ;
A) The ExitListener class is not public
B) You cannot attach a listener to a menu, only to a menu item
C) You cannot add a menu to the menu bar, only a menu item
D) You need to use a menu listener, not an action listener
Correct Answer:

Verified
Correct Answer:
Verified
Q49: What is the easiest way to create
Q50: Which of the following is true about
Q51: Which code will create a JSlider with
Q52: Which of the following adds a border
Q53: Which of the following classes has a
Q55: For a new programmer using the Swing
Q56: Which method can a program use to
Q57: What is the general order of a
Q58: What type of object can be added
Q59: The code below will not compile successfully