The exam will contain multiple choice, supply missing code statement questions and one or two questions that ask you to write a small amount of java code.
Covers: Week02_Notes03, Week03_Notes01, Week04_Notes01, Week04_Notes02, Week04_Notes03
Labs 3 and 4.
Questions similar to exam 1.
syntax parentheses enclose the conditional expression
control flow:
- if the conditional expression is true, execute the statements in the body of the loop
- when reach the end of the loop evaluate the conditional expression again
- execute the statement following the loop body only when the conditional expression is false
Loops may be infinite (not terminate) your program hangs.
A done variable is used to allow a loop to terminate when any one of several different conditions is met.
Loops may be nested the inner loop executes until its conditional expression is false each time through the outer loop.
Nested loops are used to print tables.
System.out.print() is used to print something and leave the cursor positioned on the same line ready for the next call to print()
See demos/loops.htm for practice problems.
Used to encapsulate a complicated set of instructions or a set of instructions that needs to be executed many times.
Have a signature and a body.
The signature declares the name of the method, the parameters it accepts, and the type of value it returns.
nameOfMethodBeingCalled(actualParameter1, actualParameter2);
May be used as part of a larger expression, e.g., as a parameter to println()
Think of the value returned by the method you called as syntactically replacing the expression that called the method.
Scope: class-level, parameter, local.
For each scope:
spatial meaning where in the source code are variables declared in each scope visible.
temporal meaning when are variables declared in each scope alive at run time.