Question #194905

* Please select the correct letter choice "A, B, C, D, or E"


8. Given the following code, which can add an "event handler" to "button1"?

JButton button1 = new JButton();


A.

button1.ActionListener( new ActionListener() {

public void actionPerformed(ActionEvent e) { }

} );


B.

button1.addActionListener( new ActionListener() {

public void actionPerformed(ActionEvent e) { }

} );


C.

button1.addActionListener( new ActionListener() {

public void addActionPerformed(ActionEvent e) { }

} );


D.

button1.addActionListener( new ActionListener() {

public void Performed(ActionEvent e) { }

} );


E. All of the options


Expert's answer

B


LATEST TUTORIALS
APPROVED BY CLIENTS