Exam Questions JavaFX Advanced Controls Gaddis Ch.13 - Java Control Structures 7e Test Bank by Tony Gaddis. DOCX document preview.

Exam Questions JavaFX Advanced Controls Gaddis Ch.13

Starting Out with Java: From Control Structures through Objects 7e (Gaddis)

Chapter 13 JavaFX: Advanced Controls

TRUE/FALSE

1. In JavaFX all CSS properties begin with -fx-.

2. In a JavaFX application, a CSS type selector corresponds to a specific JavaFX node.

3. In a JavaFX application, you must recompile the application each time you make a change to the stylesheet.

4. Styles specified with the .root selector take precedence over styles applied to any other node.

5. CSS uses the RGB color system to define colors and colors can be specified using six hexadecimal numbers preceded by the # symbol.

6. Radio buttons are normally used when you want the user to be able to select one or more options from a group of several possible options.

7. When the user selects an item in a ListView, a change event occurs.

8. A ComboBox differs only from a ListView in that a ComboBox must have a minimum of three items.

9. A TextArea is a multiline TextField that can accept or display several lines of text.

10. To create a mutually exclusive relationship between RadioMenuItem controls, you must group them in a ToggleGroup object.

MULTIPLE CHOICE

1. On a web page, the __________ specifies what information to display and the __________ specifies how that information should be displayed.

a.

HTML, JavaFX

c.

HTML, CSS

b.

code, CSS

d.

CSS, HTML

2. How would a stylesheet named javafxstyles.css be applied to a JavaFX application, assuming that scene is the variable that refers to a Scene object?

a.

scene.getStyles().add("javafxstyles.css");

b.

scene.getStylesheets().add(javafxstyles.css);

c.

scene.getStylesheets().add("javafxstyles.css");

d.

scene.addStylesheets().get("javafxstyles.css");

3. The type of control normally used when you want the user to only be allowed to select one option from several possible options is the __________.

a.

Button

c.

CheckBox

b.

RadioButton

d.

Any of these

4. In a JavaFX CSS style definition, if a selector name starts with a period, that selector corresponds to a __________.

a.

value entered by the user

c.

named color

b.

specific JavaFX node

d.

specific variable in the application

5. To apply specific styles to all of the nodes in a scene, use the __________ selector.

a.

.stage

b.

.top

c.

.root

d.

.all

6. In the hexadecimal color value #CCAA99, the CC refers to the __________ color component?

a.

red

b.

blue

c.

green

d.

yellow

7. Which of the following creates a custom style class that will allow a Button control to appear with a blue background and yellow text?

a.

.button-color {

-fx- background-color: blue;

-fx- text-fill: yellow;

}

b.

.button-color {

-fx- bgcolor: blue;

-fx- textfill: yellow;

}

c.

.blue-button {

background-color: blue;

text-fill: yellow;

}

d.

.blue-button {

-fx- background: blue;

-fx- text: yellow;

}

8. If you have two RadioButtons (dogRadio and catRadio), how should you code them to create a mutually exclusive relationship?

a.

ToggleGroup radioGroup = new ToggleGroup();

dogRadio.setToggleGroup(radioGroup);

catRadio.setToggleGroup(radioGroup):

b.

ToggleGroup radioGroup = new radioGroup();

dogRadio.setToggle(radioGroup);

catRadio.setToggle(radioGroup):

c.

dogRadio.setToggleGroup();

catRadio.setToggleGroup():

d.

ToggleGroup dogRadio = new ToggleGroup();

ToggleGroup catRadio = new ToggleGroup();

9. Which of the following will create a CheckBox that displays pizza and shows up as selected?

a.

CheckBox checkOne.setSelected(true) = "pizza";

b.

CheckBox checkOne = new CheckBox("pizza");

checkOne.setSelected(true);

c.

CheckBox checkOne = new CheckBox("pizza");

CheckBox.setSelected(false);

d.

CheckBox checkOne("pizza") = setSelected(true);

10. The control that displays a list of items and allows the user to select an item from the list is the __________ control.

a.

List

c.

ListView

b.

SelectionList

d.

ArrayList

11. To replace a ListView control's existing items with a new list of items, use the __________ method.

a.

getItems.addAll()

c.

getItems().addAll()

b.

getItems().setAll()

d.

getItems.setAll()

12. Which of the following statements will allow a user to type input into a field of a ComboBox named myComboBox?

a.

ComboBox.setEditable;

b.

myComboBox.setEditable(true);

c.

ComboBox.setEditable(myComboBox);

d.

myComboBox = ComboBox.setEditable(true);

13. Which of the following statements creates a Slider with a range of 1 to 20 with a starting value of 1?

a.

Slider slider = new Slider(0, 20, 1);

b.

Slider slider = new slider(0.0, 20.0, 1.0);

c.

Slider slider = new Slider(1.0, 20.0, 1.0);

d.

Slider slider = new Slider(1.0, 20);

14. Which of the following statements creates an empty TextArea?

a.

TextArea textArea = new TextArea();

b.

TextArea textArea = new TextArea(" ");

c.

TextArea = new textArea();

d.

TextArea textArea = new TextArea.textArea("");

15. Adding RadioButton controls to a __________ object creates a mutually exclusive relationship between them.

a.

MutualGroup

c.

ToggleGroup

b.

RadioGroup

d.

ExcludeGroup

16. The __________ control uses a drop-down list as its display.

a.

DropList

b.

ItemList

c.

TextList

d.

ListView

17. The __________ class is used to create a menu bar.

a.

MenuBar

b.

Menu

c.

MenuItem

d.

Bar

18. What happens when the following code is executed?

ComboBox<string> myComboBox = new ComboBox<>();

myComboBox.getItems().addAll(5, 10, 15, 20);

a.

A ComboBox displaying the numbers 5, 10, 15, and 20 will be created.

b.

The values 5, 10, 15, and 20 will be added to a ComboBox named myComboBox.

c.

The values 5, 10, 15, and 20 will be converted to strings and added a new ComboBox named myComboBox.

d.

A compiler error will occur.

19. To build a menu system you must __________.

a.

create a MenuBar object

b.

create the Menu objects and register an event handler for each menu item object

c.

Add the MenuBar object to the scene graph

d.

All of these are necessary steps.

20. Which of the following statements will set a ListView control, puppyListView, to be 300 pixels high and 200 pixels wide?

a.

puppyListView.setSize(200, 300);

b.

puppyListView.setSize(300, 200);

c.

puppyListView.setPrefSize(200, 300);

d.

puppyListView.setPrefSize(300, 200);

21. Which of the following is a CSS named color?

a.

maroon

b.

crimson

c.

lavender

d.

All of these

22. In CSS, selector names that begin with a period are called __________ selectors.

a.

class

b.

node

c.

type

d.

object

23. Which CSS type selector corresponds with the TextField JavaFX class?

a.

text-box

c.

text-area

b.

text-field

d.

text

24. What does the following code do, assuming there is a variable that references a Scene object?

myScene.getStylesheets().add("sceneStyles.css");

a.

It adds a stylesheet named sceneStyles to Scene.

b.

It adds a stylesheet named myScene to Scene.

c.

The getStylesheets method returns an object containing the scene's collection of stylesheets and that object's add method adds sceneStyles.css to the collection.

d.

The getStylesheets method gets sceneStyles.css and adds it to the to the myScene object.

25. Given the following styles, what size will the text of the label be?

.root { -fx- font-size: 12pt; }

.label { -fx- font-size: 18pt; }

a.

12 pts

b.

18 pts

c.

15 pts

d.

This will cause an error because there are duplicate font-size styles.

MULTIPLE RESPONSE

1. Select all that apply. The SetStyle method is used to apply style rules directly to a JavaFX node. This method __________.

a.

allows you to pass only one style rule at a time, as a string argument

b.

allows you to pass multiple style rules as string arguments

c.

is considered a better way to add styles than using a stylesheet

d.

removes any styles that were previously applied to that node

2. Select all that apply. Which of the following classes inherit from the Region class?

a.

Label

c.

CheckBox

b.

RadioButton

d.

ListBox

3. Select all that apply. Which of the following are possible selection nodes available to the ListView control?

a.

multiple selection mode

c.

multiple interval selection mode

b.

single selection mode

d.

single interval selection mode

4. Select all that apply. Which of the following methods can be used with both ArrayLists and ObservableLists?

a.

the get method

c.

the remove method

b.

the size method

d.

the set method

5. Select all that apply. Which of the following ComboBox methods require a boolean argument?

a.

getValue

c.

setEditable

b.

setVisibleRowCount

d.

setValue

Document Information

Document Type:
DOCX
Chapter Number:
13
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 13 JavaFX Advanced Controls
Author:
Tony Gaddis

Connected Book

Java Control Structures 7e Test Bank

By Tony Gaddis

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party