Solved

How Do the Lifetimes of the Three Objects MenuLabel, Mi

Question 86

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents