Title: JavaChapter5

Q: This is the general form of what type of statement?
(int counter = 1; counter <= 10; counter++)
A: For

Q: "%-20s" is an example of
A: A left justified field width

Q: What does a comma formatting flag indicate
A: That a floating-point value should be output with a grouping separator

Q: Which multiple-selection statement responds to the types of byte, short, int or char?
A: Switch

Q: What does <Ctrl> d or <Ctrl> z indicate?
A: The end-of-file indicator. It means there is no more data to input.

Q: What is a character constant?
A: A specific character or characters in single quotes

Q: A variable that contains a value which does not change for the entire program
A: constant variable

Q: Use logical operators
A: How to combine simple conditions

Rules for forming structured programs:
1. Begin with the simplest activity diagram
2. Any action state can be replaced by 2  action states in sequence (stacking rule)
3. Any action state can be replaced by any control statement (nesting rule)
4. Rules 2 and 3 can be applied as often as you like in any order.

Q: What do the graphics methods drawRect and drawOval draw?
A: rectangles and ovals respectively

Q: What is a bounding rectangle
A: An imaginary rectangle  inside an oval that touches the midpoints of all four sides.

Q: determines if looping should continue
A: loop-continuation condition

Q: controlling loops with [...] may result in [...] and [...].
A: floating-point variables; imprecise counter values; inaccurate termination tests

Q: What is the main difference between while loops and for loops?
A: For loops specify the counter-controlled repetition details in the first line of the loop.

Q: Another name for the first line of a for loop
A: for statement header

Q: General format of a for statement
A: for (initialization; loopContinuationCondition; increment){
statements . . .
}

If the initialization expression in the for header declares the control variable, it can only be used in that for statement.

Q: [...] expression(s) in the [...] are [...].
A: All three; for header; optional

Q: The command to increase a counter by n
A: counter += n

Q: code used to call a static method
A: ClassName.methodName(arguements)

Q: Each case in a switch statement must contain this.
A: A constant integral expression

Q: Contitional and operator
A: &&

Q: logical and operator
A: &

Q: logical inclusive or operator
A: |

Q: logical not operator and it's function
A: ! and it "reverses" the value of the condition

Q: You need these conditions for the logical exclusive or operator to be true
A: one opperand is true and the other is false

If the initialization expression in the for header declares the control variable, the control variable can only be used in that for statement. This is known as the variable's scope.

The integer between a % and a conversion character indicates that the value should be displayed with a field width equal to the integer. In other words, printf displays the value with at least a number of character positions equal to the integer.

In a while reptition statement, the program tests the loop-continuation condition at the beginning of the loop, before executing the loop's body. If the condition is false, the body never executes.

A switch multiple-selection statement performs different actions based on the possible values of a constant integral expression of type byte, short, int, or char.

Q: hasNext
A: A Scanner method that determines whether or not there is more data to input.

Case labels and an optional default case are used to determine which counter to increment based on a value.

Q: [...] is the [...] and is true [...].
A: ^; boolean logical exclusive OR operator; if and only if one of its operands is true and the other is false

Q: [...] is the [...] and is true [...].
A: ||; conditional OR operator; if either or both of the simple conditions are true

Q: off-by-one error
A: Common error made because java starts counting at 0, not 1.

Q: "for" statements in counter controlled repetition do the following:
A: initializes (the variable); loop continuation condition; increment of control variable
Ex: "for( int i = 0; i >= 12; i++)"

Q: "do...while" statements
A: executes the body's loop before checking the condition of the body, ensuring that the body executes at least once

Q: "break"
A: exits a loop at this point

Q: "continue" statement
A: skips remaining info in loop but proceeds to the next iteration of the loop

Q: && and || are...
A: logical operators

Q: Math.pow(x,y)
A: Arithmetic argument that raises 'x' to the 'y' power

Q: for repetition statement
A: specifies the counter-controlled-repitition details in a single line of code.

Q: for statement header
A: Another name for the "for"s first line

Q: controlling expression
A: the expression in the parenthesis after the switch statement that is evaluated

Q: utility methods are known as helper methods because...
A: they can only be called by other method of that class

Q: logical operators enable...
A: more complex conditions by combining simple conditions

Q: True or False: you can declare and initialize a variable in the same statement
A: True

Typically for statements are used for counter controlled repetition and while statements are used for sentinel-controlled repetition.

Q: The "." in a format specifier indicates
A: that the integer to its right is the number's precision

Q: True or false: cases can have multiple statements that do not need to be put in braces ({ . . . }).
A: True

Q: What happens when no match occurs between the controlling expression's value and case label
A: the optional default case executes