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
Q43: What features do GUI builders have to
Q59: Given four JRadioButton objects in a ButtonGroup,
Q62: What is known for certain from this
Q63: Suppose a JPanel with a BorderLayout manager
Q66: Which elements of creating a graphical user
Q68: When method makeMenuItem is called, how many
Q69: The documentation for the JSlider class lists
Q70: Which of the following adds a border
Q72: Which of the following statements is correct?
A)new
Q72: Based on the statement below, which of
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents