O'Reilly logo

Java 2™ Programmer Exam Cram™ 2 (Exam CX-310-035) by Marcus Green, Bill Brogden

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exam Prep Practice Questions

Question 1 You need to write code in an applet that will call the submitData method when button1 is clicked. To do this, use addActionListener to connect button1 with an object that implements the ActionListener interface. The only method in this interface has this signature:
void actionPerformed( ActionEvent e );

Which of the following anonymous class declarations is the correct way to do this?

  • A.

    button1.addActionListener(
           new ActionListener()
           { public void
               actionPerformed( ActionEvent evt )
             {  submitData() ;
             }
           }
         );
    
  • B.

    button1.addActionListener(
           new Object implements ActionListener()
           { public void
               actionPerformed( ActionEvent evt )
             {  submitData() ;
             }
           }
         );
    
  • C.

     button1.addActionListener( new ActionListener() { submitData() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required