1. What is wrong in the below code??? A. public class Test extends Application {
ID: 3688284 • Letter: 1
Question
1. What is wrong in the below code???
A.
public class Test extends Application {
public void start(Stage stage) {
Button btOK = new Button("OK");
}
private class Handler implements
EventHandler<ActionEvent> {
public void handle(Action e) {
System.out.println(e.getSource());
}
}
}
B.
public class Test extends Application {
public void start(Stage stage) {
Button btOK = new Button("OK");
btOK.setOnAction(
new EventHandler<ActionEvent> {
public void handle
(ActionEvent e) {
System.out.println
(e.getSource());
}
} // Something missing here
}
}
Explanation / Answer
B.
public class Test extends Application {
public void start(Stage stage) {
Button btOK = new Button("OK");
btOK.setOnAction(new EventHandler<ActionEvent>(){ //modified
public void handle(ActionEvent e) {
System.out.println
(e.getSource());
}
}); // modified
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.