Java Chapter 14

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which of the following statements are correct? A. A Color object is immutable. B. A Font object is immutable. C. You cannot change the contents in a Color object once it is created. D. You cannot change the contents in a Font object once it is created.

A. A Color object is immutable. B. A Font object is immutable. C. You cannot change the contents in a Color object once it is created. D. You cannot change the contents in a Font object once it is created.

Which of the following statements are true? A. A Node can be placed in a Pane. B. A Node can be placed in a Scene. C. A Pane can be placed in a Control. D. A Shape can be placed in a Control.

A. A Node can be placed in a Pane.

Which of the following statements are true? A. A primary stage is automatically created when a JavaFX main class is launched. B. You can have multiple stages displayed in a JavaFX program. C. A stage is displayed by invoking the show() method on the stage. D. A scene is placed in the stage using the addScene method E. A scene is placed in the stage using the setScene method

A. A primary stage is automatically created when a JavaFX main class is launched. B. You can have multiple stages displayed in a JavaFX program. C. A stage is displayed by invoking the show() method on the stage. E. A scene is placed in the stage using the setScene method

Which of the following statements are correct? A. Every subclass of Node has a no-arg constructor. B. Circle is a subclass of Node. C. Button is a subclass of Node. D. Pane is a subclass of Node. E. Scene is a subclass on Node.

A. Every subclass of Node has a no-arg constructor. B. Circle is a subclass of Node. C. Button is a subclass of Node. D. Pane is a subclass of Node.

Why is JavaFX preferred? A. JavaFX is much simpler to learn and use for new Java programmers. B. JavaFX provides a multi-touch support for touch-enabled devices such as tablets and smart phones. C. JavaFX has a built-in 3D, animation support, video and audio playback, and runs as a standalone application or from a browser. D. JavaFX incorporates modern GUI technologies to enable you to develop rich Internet applications.

A. JavaFX is much simpler to learn and use for new Java programmers. B. JavaFX provides a multi-touch support for touch-enabled devices such as tablets and smart phones. C. JavaFX has a built-in 3D, animation support, video and audio playback, and runs as a standalone application or from a browser. D. JavaFX incorporates modern GUI technologies to enable you to develop rich Internet applications.

Analyze the following code: import javafx.application.Application; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.layout.HBox; import javafx.scene.shape.Circle; public class Test extends Application { @Override // Override the start method in the Application class public void start(Stage primaryStage) { HBox pane = new HBox(5); Circle circle = new Circle(50, 200, 200); pane.getChildren().addAll(circle); circle.setCenterX(100); circle.setCenterY(100); circle.setRadius(50); pane.getChildren().addAll(circle); // Create a scene and place it in the stage Scene scene = new Scene(pane); primaryStage.setTitle("Test"); // 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. The program has a compile error since the circle is added to a pane twice. B. The program has a runtime error since the circle is added to a pane twice. C. The program runs fine and displays one circle. D. The program runs fine and displays two circles.

A. The program has a compile error since the circle is added to a pane twice.

The _________ properties are defined in the javafx.scene.shape.Ellipse class. A. centerX B. centerY C. radiusX D. radiusY

A. centerX B. centerY C. radiusX D. radiusY

Which of the following statements correctly sets the fill color of circle to black? A. circle.setFill(Color.BLACK); B. circle.setFill(Color.black); C. circle.setStyle("-fx-fill: black"); D. circle.setStyle("fill: black"); E. circle.setStyle("-fx-fill-color: black");

A. circle.setFill(Color.BLACK); C. circle.setStyle("-fx-fill: black");

What is the output of the following code? import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; public class Test { public static void main(String[] args) { IntegerProperty d1 = new SimpleIntegerProperty(1); IntegerProperty d2 = new SimpleIntegerProperty(2); d1.bind(d2); System.out.print("d1 is " + d1.getValue() + " and d2 is " + d2.getValue()); d2.setValue(3); System.out.println(", d1 is " + d1.getValue() + " and d2 is " + d2.getValue()); } } A. d1 is 2 and d2 is 2, d1 is 3 and d2 is 3 B. d1 is 2 and d2 is 2, d1 is 2 and d2 is 3 C. d1 is 1 and d2 is 2, d1 is 1 and d2 is 3 D. d1 is 1 and d2 is 2, d1 is 3 and d2 is 3

A. d1 is 2 and d2 is 2, d1 is 3 and d2 is 3

What is the output of the following code? import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; public class Test { public static void main(String[] args) { IntegerProperty d1 = new SimpleIntegerProperty(1); IntegerProperty d2 = new SimpleIntegerProperty(2); d1.bindBidirectional(d2); System.out.print("d1 is " + d1.getValue() + " and d2 is " + d2.getValue()); d1.setValue(3); System.out.println(", d1 is " + d1.getValue() + " and d2 is " + d2.getValue()); } } A. d1 is 2 and d2 is 2, d1 is 3 and d2 is 3 B. d1 is 2 and d2 is 2, d1 is 2 and d2 is 3 C. d1 is 1 and d2 is 2, d1 is 1 and d2 is 3 D. d1 is 1 and d2 is 2, d1 is 3 and d2 is 3

A. d1 is 2 and d2 is 2, d1 is 3 and d2 is 3

Which of the following statements are correct to create a FlowPane? A. new FlowPane() B. new FlowPane(4, 5) C. new FlowPane(Orientation.VERTICAL); D. new FlowPane(4, 5, Orientation.VERTICAL);

A. new FlowPane() B. new FlowPane(4, 5) C. new FlowPane(Orientation.VERTICAL); D. new FlowPane(4, 5, Orientation.VERTICAL);

Which of the following statements correctly creates a Font object? A. new Font(34); B. new Font("Times", 34); C. Font.font("Times", 34); D. Font.font("Times", FontWeight.NORMAL, 34); E. Font.font("Times", FontWeight.NORMAL, FontPosture.ITALIC, 34);

A. new Font(34); B. new Font("Times", 34); C. Font.font("Times", 34); D. Font.font("Times", FontWeight.NORMAL, 34); E. Font.font("Times", FontWeight.NORMAL, FontPosture.ITALIC, 34);

Which of the following statements correctly creates an ImageView object? A. new ImageView("http://www.cs.armstrong.edu/liang/image/us.gif"); B. new ImageView(new Image("http://www.cs.armstrong.edu/liang/image/us.gif")); C. new ImageView("image/us.gif"); D. new ImageView(new Image("image/us.gif"));

A. new ImageView("http://www.cs.armstrong.edu/liang/image/us.gif"); B. new ImageView(new Image("http://www.cs.armstrong.edu/liang/image/us.gif")); C. new ImageView("image/us.gif"); D. new ImageView(new Image("image/us.gif"));

To construct a Polygon with three points x1, y1, x2, y2, x3, and y3, use _________. A. new Polygon(x1, y1, x2, y2, x3, y3) B. new Polygon(x1, y2, x3, y1, y2, y3) C. Polygon polygon = new Polygon(); polygon.getPoints().addAll(x1, y1, x2, y2, x3, y3) D. Polygon polygon = new Polygon(); polygon.getPoints().addAll(x1, y2, x3, y1, y2, y3)

A. new Polygon(x1, y1, x2, y2, x3, y3) C. Polygon polygon = new Polygon(); polygon.getPoints().addAll(x1, y1, x2, y2, x3, y3)

To construct a Polyline with three points x1, y1, x2, y2, x3, and y3, use _________. A. new Polyline(x1, y1, x2, y2, x3, y3) B. new Polyline(x1, y2, x3, y1, y2, y3) C. Polyline polyline = new Polygon(); polyline.getPoints().addAll(x1, y1, x2, y2, x3, y3) D. Polyline polyline = new Polygon(); polyline.getPoints().addAll(x1, y2, x3, y1, y2, y3)

A. new Polyline(x1, y1, x2, y2, x3, y3) C. Polyline polyline = new Polygon(); polyline.getPoints().addAll(x1, y1, x2, y2, x3, y3)

Which of the following statements are correct? A. new Scene(new Button("OK")); B. new Scene(new Circle()); C. new Scene(new ImageView()); D. new Scene(new Pane());

A. new Scene(new Button("OK")); D. new Scene(new Pane());

To add two nodes node1 and node2 to the the first row in a GridPane pane, use ________. A. pane.add(node1, 0, 0); pane.add(node2, 1, 0); B. pane.add(node1, node2, 0); C. pane.addRow(0, node1, node2); D. pane.addRow(1, node1, node2); E. pane.add(node1, 0, 1); pane.add(node2, 1, 1);

A. pane.add(node1, 0, 0); pane.add(node2, 1, 0); C. pane.addRow(0, node1, node2);

Suppose a JavaFX class has a binding property named weight of the type DoubleProperty. By convention, which of the following methods are defined in the class? A. public double getWeight() B. public void setWeight(double v) C. public DoubleProperty weightProperty() D. public double weightProperty() E. public DoubleProperty WeightProperty()

A. public double getWeight() B. public void setWeight(double v) C. public DoubleProperty weightProperty()

The _________ properties are defined in the javafx.scene.shape.Shape class. A. stroke B. strokeWidth C. fill D. centerX

A. stroke B. strokeWidth C. fill

The _________ properties are defined in the javafx.scene.text.Text class. A. text B. x C. y D. underline E. strikethrough

A. text B. x C. y D. underline E. strikethrough

The _________ properties are defined in the javafx.scene.shape.Rectangle class. A. width B. x C. y D. height E. arcWidth

A. width B. x C. y D. height E. arcWidth

The _________ properties are defined in the javafx.scene.shape.Line class. A. x1 B. x2 C. y1 D. y2 E. strikethrough

A. x1 B. x2 C. y1 D. y2

Which of the following statements are true? A. A Scene is a Node. B. A Shape is a Node. C. A Stage is a Node. D. A Control is a Node. E. A Pane is a Node.

B. A Shape is a Node. D. A Control is a Node. E. A Pane is a Node.

Every JavaFX main class __________. A. implements javafx.application.Application B. extends javafx.application.Application C. overrides start(Stage s) method D. overrides start() method

B. extends javafx.application.Application C. overrides start(Stage s) method

Which of the following statements correctly creates a Color object? A. new Color(3, 5, 5, 1); B. new Color(0.3, 0.5, 0.5, 0.1); C. new Color(0.3, 0.5, 0.5); D. Color.color(0.3, 0.5, 0.5); E. Color.color(0.3, 0.5, 0.5, 0.1);

B. new Color(0.3, 0.5, 0.5, 0.1); D. Color.color(0.3, 0.5, 0.5); E. Color.color(0.3, 0.5, 0.5, 0.1);

Analyze the following code: import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.geometry.Insets; import javafx.stage.Stage; import javafx.scene.image.Image; import javafx.scene.image.ImageView; public class Test extends Application { @Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane to hold the image views Pane pane = new HBox(10); pane.setPadding(new Insets(5, 5, 5, 5)); Image image = new Image("www.cs.armstrong.edu/liang/image/us.gif"); pane.getChildren().addAll(new ImageView(image), new ImageView(image)); // Create a scene and place it in the stage Scene scene = new Scene(pane); primaryStage.setTitle("ShowImage"); // 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. The program runs fine and displays two images. B. new Image("www.cs.armstrong.edu/liang/image/us.gif") must be replaced by new Image("http://www.cs.armstrong.edu/liang/image/us.gif"). C. The image object cannot be shared by two ImageViews. D. The addAll method needs to be replaced by the add method.

B. new Image("www.cs.armstrong.edu/liang/image/us.gif") must be replaced by new Image("http://www.cs.armstrong.edu/liang/image/us.gif").

Assume p is a Polygon, to add a point (4, 5) into p, use _______. A. p.getPoints().add(4); p.getPoints().add(5); B. p.getPoints().add(4.0); p.getPoints().add(5.0); C. p.getPoints().addAll(4, 5); D. p.getPoints().addAll(4.0, 5.0);

B. p.getPoints().add(4.0); p.getPoints().add(5.0); D. p.getPoints().addAll(4.0, 5.0);

Which of the following are binding properties? A. Integer B. Double C. IntegerProperty D. DoubleProperty E. String

C. IntegerProperty D. DoubleProperty

Which of the following can be used as a source for a binding properties? A. Integer B. Double C. IntegerProperty D. DoubleProperty E. String

C. IntegerProperty D. DoubleProperty

Which of the following statements correctly rotates the button 45 degrees counterclockwise? A. button.setRotate(45); B. button.setRotate(Math.toRadians(45)); C. button.setRotate(360 - 45); D. button.setRotate(-45)

C. button.setRotate(360 - 45); D. button.setRotate(-45);

To place a node in the left of a BorderPane p, use ___________. A. p.setEast(node); B. p.placeLeft(node); C. p.setLeft(node); D. p.left(node);

C. p.setLeft(node);

To add a circle object into a pane, use _________. A. pane.add(circle); B. pane.addAll(circle); C. pane.getChildren().add(circle); D. pane.getChildren().addAll(circle);

C. pane.getChildren().add(circle); D. pane.getChildren().addAll(circle);

To add a node into a pane, use ______. A. pane.add(node); B. pane.addAll(node); C. pane.getChildren().add(node); D. pane.getChildren().addAll(node);

C. pane.getChildren().add(node); D. pane.getChildren().addAll(node);

To remove a node from the pane, use ______. A. pane.remove(node); B. pane.removeAll(node); C. pane.getChildren().remove(node); D. pane.getChildren().removeAll(node)

C. pane.getChildren().remove(node); D. pane.getChildren().removeAll(node);

To place two nodes node1 and node2 in a HBox p, use ___________. A. p.add(node1, node2); B. p.addAll(node1, node2); C. p.getChildren().add(node1, node2); D. p.getChildren().addAll(node1, node2);

D. p.getChildren().addAll(node1, node2);

To add two nodes node1 and node2 into a pane, use ______. A. pane.add(node1, node2); B. pane.addAll(node1, node2); C. pane.getChildren().add(node1, node2); D. pane.getChildren().addAll(node1, node2);

D. pane.getChildren().addAll(node1, node2);

To remove two nodes node1 and node2 from a pane, use ______. A. pane.remove(node1, node2); B. pane.removeAll(node1, node2); C. pane.getChildren().remove(node1, node2); D. pane.getChildren().removeAll(node1, node2);

D. pane.getChildren().removeAll(node1, node2);

What is the output of the following JavaFX program? import javafx.application.Application; import javafx.stage.Stage; public class Test extends Application { public Test() { System.out.println("Test constructor is invoked."); } @Override // Override the start method in the Application class public void start(Stage primaryStage) { System.out.println("start method is invoked."); } public static void main(String[] args) { System.out.println("launch application."); Application.launch(args); } } A. launch application. start method is invoked. B. start method is invoked. Test constructor is invoked. C. Test constructor is invoked. start method is invoked. D. launch application. start method is invoked. Test constructor is invoked. E. launch application. Test constructor is invoked. start method is invoked.

E. launch application. Test constructor is invoked. start method is invoked.

To add a node to the the first row and second column in a GridPane pane, use ________. A. pane.getChildren().add(node, 1, 2); B. pane.add(node, 1, 2); C. pane.getChildren().add(node, 0, 1); D. pane.add(node, 0, 1); E. pane.add(node, 1, 0);

E. pane.add(node, 1, 0);


संबंधित स्टडी सेट्स

PrepU Chapter 6: Values, Ethics and Advocacy

View Set

Chapter 5: Purchasing, Receiving, and Storage

View Set

Chapter 16. Financial Management & Securities Markets

View Set

SPA 201: Estructura 3.1 - Completar

View Set

7. Service Breakdowns and Recovery

View Set

patho quiz 5 check for understanding

View Set