Multiple Choice
How do the lifetimes of the three objects menuLabel, mi, and the anonymous object new MyMenuListener() compare?
Public JMenuItem makeMenuItem(final String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel) ;
Class MyMenuListener implements ActionListener
{
Public void actionPerformed(ActionEvent
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
E) {
DoSomethingElse() ;
System.out.println(menuLabel) ;
}
}
Mi) addActionListener(new MyMenuListener() ) ;
Return mi;
}
Correct Answer:

Verified
Correct Answer:
Verified
Q4: The ChangeEvent class defines no methods.What makes
Q8: When you use a timer, you need
Q14: What is the most time-effective way to
Q30: What is the container for top-level menu
Q38: You can add a(n) _ to a
Q39: The Timer class is found in the
Q44: Which of the following statements is correct?<br>A)new
Q68: Which layout manager allows you to add
Q72: What is known for certain from this
Q73: Given four JRadioButton objects in a ButtonGroup,