Chapter 6 Flashcards

1
Q

What is the syntax of the switch statement?

A
switch ( expression)
{
case value1:
    statement-list1;
case value2:
    statement-list2;
...
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What happens if you don’t put break at the end of a switch statement-list?

A

Without break; every statement-list after it inside the switch will be executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the default statement in a switch?

A

Default indicates a statement-list to be executed in the circumstance in which no other cases was true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What primitive value cannot be used as a condition in a switch statement?

A

A floating point value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the syntax of a conditional operator? How does it work?

A

condition ? expression1 : expression2;

If the condition is fulfilled, the first expression is executed, otherwise the second one is.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between a conditional operator and a conditional statement?

A

A conditional operator is a ternary operator that evaluates a condition and returns one of two possible values (true or false).

A conditional statement is a category of statements that allow conditions to be evaluated and the appropriate statements executed as a result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the syntax of a do statement? What’s the difference with using a while?

A
do
{
    statement-list;
]
while (condition);

Compared to a while, the do statement executes the statement-list at least one and will then execute it for each time the condition is true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the syntax of a for statement?

A

for (initialization; condition; increment)
statement;

The initialization is executed only once before the start of the loop, the condition is evaluated every time, and increment happens at the end of the loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Although having the same functionality, in what circumstance would for be preferred to a while and vice versa?

A

A for is used when the number of loops is known, on the other a while loop is built in cases in which the length of a loop, aka the number of loops that it will do is unknown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Can the header of a for statement be shortened?

A

Yes, every formal parameter of for can be left blank.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the common methods used for graphic transformations in JavaFX?

A

Translation:
setTranslateX(100);
setTranslateY(…);

Scaling:
setScaleX(0.7);
setScaleY(0.5);

Rotation:
setRotate(40); will be clockwise
setRotate(-40); will be anticlockwise.

Shearing:
is done by creating a Shear object. Ex:
imgView.getTransforms() .add(new Shear(0.4, 0.2));
How well did you know this?
1
Not at all
2
3
4
5
Perfectly