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
Q4: If the method makeMenuItem is called four
Q5: Suppose a JPanel with a BorderLayout manager
Q6: Suppose a JPanel with a BorderLayout manager
Q7: If the makeMenuItem method is called four
Q8: What is the best way to start
Q10: Which of the following adds a border
Q11: What can be determined about obj from
Q12: Which layout manager uses a grid, but
Q14: Which layout manager allows you to add
Q44: Which of the following statements is correct?<br>A)new