Chapter 5: Decisions Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does the if statement allow a program to do?

A

carry out different actions depending on the nature of the data to be processed

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

What does a relational operator test?

A

the relationship between two values

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

What relationship operators do programmers use to compare numbers?

A

<, <=, >, >=, ==, !=

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

Why don’t you check for equality when comparing floating-point numbers?

A

because they’re could be a rounding error. Instead, test whether they are close enough

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

What threshhold value do we say is “close enough”

A

10^(-14) OR 1e-14

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

T/F: use the == operator to compare strings

A

Fuck NO!

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

What method do you use to compare strings?

A

the equal method

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

What does the compareTo method do?

A

compares strings in lexographic order

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

What is ‘A’ in lexographic order?

A

65

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

What is ‘a’ in lexographic order

A

97

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

string1.compareTo(string2) == 0 returns true. What is true about the two strings?

A

they are identical

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

What would happen if you use the == method on objects?

A

it would test whether two object references are identical

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

What method should you use to compare the values of an object?

A

equals

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

What does the null reference refer to?

A

no object

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

What operator do you use to test whether an object is a null reference?

A

==

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

How can you evaluate complex decisions?

A

use multiple if statements

17
Q

What order should you test conditions when using multiple if statements?

A

test general conditions after more specific conditions

18
Q

When are statements nested?

A

when a descision statement is contained inside the branch of another descision statement

19
Q

When are nested descisions required?

A

for problems that have two levels of descision making

20
Q

What is black-box testing?

A

a testing method that does not take the structure of the implementation into account

21
Q

What is white-box testing?

A

testing that uses information about the structure of a program

22
Q

What is code coverage?

A

a measure of how many parts of a program have been tested

23
Q

What are boundary test cases?

A

legal values that lie at the boundary of the set of acceptable inpits

24
Q

What values does boolean have?

A

true and false

25
Q

What is a boolean operator?

A

an operator that combines boolean conditions

26
Q

What are the two boolean operators?

A

&& (and) and || (or)

27
Q

What operator is used to invert a condition?

A

! (not)

28
Q

What does the hasNextInt ensure?

A

that the next input is a number