Solved

Consider the Following Code Snippet That Is Supposed to Show

Question 26

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:

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