Chapter 5: Decisions Flashcards
What does the if statement allow a program to do?
carry out different actions depending on the nature of the data to be processed
What does a relational operator test?
the relationship between two values
What relationship operators do programmers use to compare numbers?
<, <=, >, >=, ==, !=
Why don’t you check for equality when comparing floating-point numbers?
because they’re could be a rounding error. Instead, test whether they are close enough
What threshhold value do we say is “close enough”
10^(-14) OR 1e-14
T/F: use the == operator to compare strings
Fuck NO!
What method do you use to compare strings?
the equal method
What does the compareTo method do?
compares strings in lexographic order
What is ‘A’ in lexographic order?
65
What is ‘a’ in lexographic order
97
string1.compareTo(string2) == 0 returns true. What is true about the two strings?
they are identical
What would happen if you use the == method on objects?
it would test whether two object references are identical
What method should you use to compare the values of an object?
equals
What does the null reference refer to?
no object
What operator do you use to test whether an object is a null reference?
==
How can you evaluate complex decisions?
use multiple if statements
What order should you test conditions when using multiple if statements?
test general conditions after more specific conditions
When are statements nested?
when a descision statement is contained inside the branch of another descision statement
When are nested descisions required?
for problems that have two levels of descision making
What is black-box testing?
a testing method that does not take the structure of the implementation into account
What is white-box testing?
testing that uses information about the structure of a program
What is code coverage?
a measure of how many parts of a program have been tested
What are boundary test cases?
legal values that lie at the boundary of the set of acceptable inpits
What values does boolean have?
true and false
What is a boolean operator?
an operator that combines boolean conditions
What are the two boolean operators?
&& (and) and || (or)
What operator is used to invert a condition?
! (not)
What does the hasNextInt ensure?
that the next input is a number