Multiple Choice
Consider the following code snippet that is supposed to show the total order amount when the button is clicked:
Public static void main(String[] args)
{
Final Order myOrder = new Order() ;
JButton button = new JButton("Calculate") ;
Final JLabel label = new JLabel("Total amount due") ;
) . .
Class MyListener implements ActionListener
{
Public void actionPerformed(ActionEvent event)
{
Label.setText("Total amount due " + myOrder.getAmountDue() ) ;
}
}
ActionListener listener = new MyListener() ;
}
What is wrong with this code?
A) button should be declared as final
B) The listener has not been attached to the button.
C) The listener cannot access the methods of the myOrder object.
D) The listener cannot access the methods of the label object.
Correct Answer:

Verified
Correct Answer:
Verified
Q9: Which of the following statements creates a
Q10: Which statements will create an editable text
Q11: When an event occurs, the event source
Q12: Which of the following statements about listener
Q13: Insert the missing statement(s) in the following
Q15: An inner class can access local variables
Q17: Which statement will add a dollar sign
Q18: A/an _ object contains methods that describe
Q19: An event listener for a button must
Q82: How do you specify what the program