• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 3 fuera de 20 páginas
Examen

Java Chapter 15 Questions with Verified Solutions

Document preview thumbnail
Vista previa 3 fuera de 20 páginas

Java Chapter 15 Questions with Verified Solutions

Vista previa del contenido

Java Chapter 15 Questions with Verified
Solutions
Analyze the following code.


import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;


public class Test extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
Button btOK = new Button("OK");
Button btCancel = new Button("Cancel");


EventHandler<ActionEvent> handler = new EventHandler<ActionEvent>() {
public void handle(ActionEvent e) {
System.out.println("The OK button is clicked");
}
};


btOK.setOnAction(handler);
btCancel.setOnAction(handler);

,HBox pane = new HBox(5);
pane.getChildren().addAll(btOK, btCancel);


Scene scene = new Scene(pane, 200, 250);
primaryStage.setTitle("Test"); // Set the stage title

primaryStage.setScene(scene); // Place the scene in ✔️✔️A. When clicking the OK button, the
program displays The OK button is clicked.
B. When clicking the Cancel button, the program displays The OK button is clicked.


Analyze the following code.


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;


public class Test extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
// Create a button and place it in the scene
Button btOK = new Button("OK");
btOK.setOnAction(e -> System.out.println("OK 1"));
btOK.setOnAction(e -> System.out.println("OK 2"));


Scene scene = new Scene(btOK, 200, 250);
primaryStage.setTitle("MyJavaFX"); // Set the stage title

, primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
}


/**
* The main method is only needed for the IDE with limited JavaFX
* support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}
}

A. When clicking the button, the pr ✔️✔️C. When clicking the button, the program displays OK2.


Which of the following code correctly registers a handler with a button btOK?
A. btOK.setOnAction(e -> System.out.println("Handle the event"));
B. btOK.setOnAction((e) -> System.out.println("Handle the event"););
C. btOK.setOnAction((ActionEvent e) -> System.out.println("Handle the event"));

D. btOK.setOnAction(e -> {System.out.println("Handle the event");}); ✔️✔️A. btOK.setOnAction(e
-> System.out.println("Handle the event"));
B. btOK.setOnAction((e) -> System.out.println("Handle the event"););
C. btOK.setOnAction((ActionEvent e) -> System.out.println("Handle the event"));
D. btOK.setOnAction(e -> {System.out.println("Handle the event");});


Fill in the code below in the underline:


public class Test {

Información del documento

Subido en
21 de marzo de 2025
Número de páginas
20
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$12.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
KateJones
4.8
(12)
Vendido
32
Seguidores
0
Artículos
5716
Última venta
4 semanas hace




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes