Multiple Choice
The code below will not compile successfully unless the argument to the makeMenuItem method is final.Why not?
public JMenuItem makeMenuItem(final String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel) ;
class MyMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
doSomethingElse() ;
System.out.println(menuLabel) ;
}
}
mi.addActionListener(new MyMenuListener() ) ;
return mi;
}
A) JMenuItem labels must be final
B) This prevents the menuLabel argument from being modified
C) Because a local variable is being accessed from an inner classes
D) Because the String class is final
Correct Answer:

Verified
Correct Answer:
Verified
Q54: What is wrong with the following code?<br>class
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
Q60: Which of the following is false about
Q61: a(n. _ is used when you have
Q62: Examine the code below.What type of class
Q63: What is known for certain from this
Q64: If the method makeMenuItem is called four