Test Bank Docx JavaFX Graphics, Effects, and Media Ch.14 - Java Control Structures 7e Test Bank by Tony Gaddis. DOCX document preview.
Starting Out with Java: From Control Structures through Objects 7e (Gaddis)
Chapter 14 JavaFX: Graphics, Effects, and Media
TRUE/FALSE
1. In a window that is 640px wide by 480px high, the top right X, Y coordinates would be (0, 480).
2. To create a circle, you need to specify only the X and Y coordinates of the center point.
3. A polygon, created by the Polygon class is, by default, filled with the color black.
4. The following statement will draw the string "Welcome!" starting at the top left corner of the screen.
Text welcomeText = new Text(0, 0, "Welcome!");
5. To make a node half its original size, you pass the setScaleX method the value 2 and pass the setScaleY method the value 0.5.
6. JavaFX provides transition classes that allow the creation of animations by causing a node to change, over time, from one state to another.
7. The Rotate class creates a rotating animation.
8. The FillTransition class works only with objects of the Shape class or one of its subclasses.
9. Since the Node class's setEffect method only accepts one effect object as an argument, it is impossible to combine effects.
10. The setInterpolator method allows you to specify how a transition begins and ends.
MULTIPLE CHOICE
1. Given a window that is 640 (width) by 480 (height), which of the following represents the lowest position on the left side?
a. | (639, 0) | b. | (0, 639) | c. | (0, 479) | d. | (479, 0) |
2. Which of the following import statements must be used in order to use the Color class?
a. | import.javafx.scene.Paint.color; |
b. | import.javafx.scene.paint.Color; |
c. | import.javafx.paint.color; |
d. | import.javafx.scene.Color; |
3. Which of the following creates a blue circle centered at X = 50, Y = 50 with a radius of 50?
a. | Circle blueCircle = new Circle(50, 50, 50); blueCircle.setFill(Color.BLUE); |
b. | Circle blueCircle = new Circle(50, 50); blueCircle.setStroke(Color.BLUE); |
c. | Circle blueCircle = new Circle(50, 50, 50, Color.BLUE); |
d. | Circle blueCircle = new blueCircle(50); blueCircle.setColor(BLUE); |
4. The __________ arc type causes a straight line to be drawn from one endpoint of the arc to the other endpoint.
a. | ArcType.ROUND | c. | ArcType.CHORD |
b. | ArcType.CLOSED | d. | ArcType.OPEN |
5. Which class creates an animation in which a node rotates?
a. | Rotate | c. | NodeRotation |
b. | RotateTransition | d. | NodeRotate |
6. To create an animation in which a node fades in or out over a period of time, use the __________ class.
a. | Fade | c. | FadeTransition |
b. | FillTransition | d. | Fill |
7. The __________ class is used to move a node from one position on the screen to another.
a. | AnimationTransition | c. | RotateTransition |
b. | MoveTransition | d. | TranslateTransition |
8. The __________ class specifies the amount of time an animation should last.
a. | Time | b. | Clock | c. | Duration | d. | TimeSpan |
9. To animate a node with the ScaleTransition class, you specify starting and ending __________.
a. | sizes | b. | colors | c. | angles | d. | scale factors |
10. Which effect class do you use to increase an image's brightness?
a. | Glow | c. | ColorAdjust |
b. | Reflection | d. | SepiaTone |
11. To combine several effects, use the Effect class's __________ method.
a. | setInput | c. | addEffect |
b. | combineEffect | d. | Effects cannot be combined. |
12. Which of the following is a subclass of Node?
a. | Media | c. | Both of these |
b. | MediaPlayer | d. | Neither of these |
13. Any time a user presses a key, a __________ event occurs.
a. | KEY_TYPED | c. | KEY_RELEASED |
b. | KEY_PRESSED | d. | KEY_EVENT |
14. Which mouse event occurs when the user presses and releases the mouse button?
a. | MOUSE_PRESSED | c. | MOUSE_CLICKED |
b. | MOUSE_RELEASED | d. | MOUSE_DRAGGED |
15. Which of the following code snippets creates a Line and uses a RotateTransition object to animate it for seven seconds?
a. | Line myLine = new Line(25, 50, 100, 50); RotateTransition rtrans = new RotateTransition(new Duration(7000), myLine); |
b. | Line myLine = new Line(25, 50, 100, 50); RotateTransition rtrans = new RotateTransition(new Duration(7), myLine); |
c. | Line myLine = new Line(25, 50, 100, 50); RotateTransition rtrans = new Duration(7000), myLine; |
d. | Line myLine = new Line(25, 50); RotateTransition rtrans = new RotateTransition(new Duration(7000), Line); |
16. What does the following code snippet do?
Circle myCircle = new Circle(50, 50, 25);
TranslateTransition rtrans =
new TranslateTransition(new Duration(5000), myCircle);
a. | It creates a circle with center point (50, 25), radius = 50, and duration = 5000 seconds. |
b. | It creates a circle with center point (50, 50), radius = 25, and duration = 5 seconds. |
c. | It creates a circle with center point (25, 50), radius = 25, and duration = 5 seconds. |
d. | It creates a circle with center point (50, 25), radius = 50, and duration = 50 seconds. |
17. What does the following code snippet do when the animation is played, given that imageView has been created?
FadeTransition ftrans = new FadeTransition
(new Duration(5000), imageView);
ftrans.setFromValue(1.0);
ftrans.setToValue(0.5);
ftrans.play():
a. | The image will be completely opaque when displayed and will decrease to 50% opacity over the five seconds of the animation. |
b. | The image will be completely invisible when displayed and will increase to 50% opacity over the five seconds of the animation. |
c. | The image will be completely opaque when displayed and will increase to 50% opacity over the five minutes of the animation. |
d. | The image will be 50% opaque when displayed and will increase to 100% over the five seconds of the animation. |
18. Which of the following statements draws the string "Love to animate!" starting at coordinates (200, 50)?
a. | Text myText = new myText(200, 50, "Love to animate!"); |
b. | Text myText = new Text(50.0, 200.0, "Love to animate!"); |
c. | Text myWords = new Text(200.0, 50.0, "Love to animate!"); |
d. | Text Words = new Words(200, 50, "Love to animate!"); |
19. Which transition class causes a node to become larger or smaller?
a. | FillTransition | c. | ScaleTransition |
b. | SizeTransition | d. | TranslateTransition |
20. All the transition classes inherit a method named __________ which allows you to specify how the animation begins and ends.
a. | setFromTo | c. | setInterpreter |
b. | setInterpolator | d. | setStartEnd |
MULTIPLE RESPONSE
1. Select all that apply. Which of the following are constructors of the Rectangle class?
a. | Rectangle(width, height, stroke) |
b. | Rectangle(width, height) |
c. | Rectangle(X, Y, width, height) |
d. | Rectangle(width, height, fill) |
2. Select all that apply. Which of the following are subclasses of the Animation class and the Transition class?
a. | StrokeTransition | c. | ReverseTransition |
b. | TextFillTransition | d. | ScaleTransition |
3. Select all that apply. Which of the following classes are used to play an audio file?
a. | MediaView | c. | MediaPlayer |
b. | Media | d. | AudioPlayer |
4. Select all that apply. Which of the following classes are used to play videos?
a. | MediaView | c. | MediaPlayer |
b. | Media | d. | VideoPlayer |
5. Select all that apply. Which of the following will cause a counterclockwise rotation of a RotateTransition object, rtrans?
a. | rtrans.setFromAngle(60.0); rtrans.setByAngle(15.0); |
b. | rtrans.setFromAngle(-60.0); rtrans.setByAngle(15.0); |
c. | rtrans.setFromAngle(60.0); rtrans.setByAngle(-15.0); |
d. | rtrans.setAngle(60.0, 15.0); |
6. Select all that apply. Which of the following are special effects that can be applied to nodes in a scene graph?
a. | a shadow appears behind a node |
b. | a glow appears |
c. | a shadow appears inside the edges of a node |
d. | an image has a sepia tone appearance |
7. Select all that apply. Which of the following are key events?
a. | when a user rolls a mouse over the monitor |
b. | when a user presses a key |
c. | when a user presses and releases a key that produces a Unicode character |
d. | when a user releases a key |
8. Select all that apply. Which of the following are transition classes?
a. | FadeTransition | c. | RotateTransition |
b. | StrokeTransition | d. | RunTransition |
9. Select all that apply. Which of the following are mouse event types?
a. | MOUSE_CLICKED | c. | MOUSE_LIFTED |
b. | MOUSE_MOVED | d. | MOUSE_PRESSED |
10. Select all that apply. Which of the following are possible states of a MediaPlayer object?
a. | READY | b. | PLAYING | c. | PAUSED | d. | STOPPED |