Consider the following code snippet which 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) This code will display the total order amount.
Correct Answer:
Verified
Q57: Consider the following code snippet:
Import _
Import java.awt.event.ActionListener;
/**
An
Q58: Which of the following is an event
Q59: Which of the following statements about events
Q60: Consider the following code snippet: JFrame frame
Q63: To build a user interface that contains
Q64: Consider the following code snippet: class MyListener
Q65: The _ class in the javax.swing package
Q66: The Timer class is found in the
Q67: Consider the following code snippet: final RectangleComponent
Q81: When you use a timer, you need
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