Chapter 3 Flashcards

1
Q

what does the if-else do?

A

First checks the expression in parentheses after the keyword if. This expression must be something that is either true or false. If it is true, the statement before the else is executed. If the expression is false, the statement after the else is executed.

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

If you write if (x = y) instead of if (x == y) to test whether x and y are equal, you will get a ____ message.

A

syntax error

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

What are these called? &&; , || ?

A

logical operators

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

True or False, The parentheses in (pressure > min) and in (pressure < max) are not required

A

True

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

True or False , You often can avoid using !, and you should do so when possible.

A

True

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

if boolean expression A is true, and boolean expression B is false, A && B evaluates to

A

False

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

To see whether two strings have equal values, you must use the method

A

s1.equals(s2) rather than = =

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

lexicographic order means

A

the letters and other characters are ordered according to their Unicode sequence

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

If we haven’t used else at the end of the loop and If none of the boolean expressions is true, what would happen?

A

nothing happenes

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

What is this called System.exit(0); ?

A

The exit Method

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

The Operator Precedence for booleans are:

A
the boolean operators ==, != 
the boolean operator &amp; 
the boolean operator |
the boolean operator &amp;&amp;
the boolean operator ||
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

True or False: you may spell true and false using either uppercase or lowercase letters or a combination of both. in nextBoolean is more forgiving.

A

True

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

What comes after Switch statement?

A

switch (Controlling_expression)

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

What is case label?

A

is the case that comes after the switch statement

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

In switch statement, could you or could you not have a duplicate case labels?

A

you cant

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

If you test a program that contains a switch statement and it executes two cases when you expect it to execute only one case, you probably have forgotten to include a

A

break statement

17
Q

If the cases of a switch statement assign values to a variable, omitting a default case can cause a

A

syntax error

18
Q

isCar ? true: false: what is this called?

A

ternary operator