Multiple Choice
Consider the scope of the three objects menuLabel, mi, and the anonymous object new MyMenuListener() within the JmenuItem class.How do thier lifetimes compare?
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) all have the same lifetimes
B) menuLabel and new MyMenuListener() are the same and both longer than mi
C) mi and new MyMenuListener() are the same and both longer than menuLabel
D) from shortest to longest:menuLabel, new MyMenuListener() , mi
Correct Answer:

Verified
Correct Answer:
Verified
Q65: You can add a(n) _ to a
Q66: When a menu item is selected, what
Q67: Which method can a program use to
Q68: The JFrame has a content pane with
Q69: The statement that would add smallButton to
Q70: When using a combo box, the _
Q71: Which GUI element allows text entry from
Q73: Given four JRadioButton objects in a ButtonGroup,
Q74: Which of the following classes have a
Q75: What type does the method getSelectedItem in