Program Flow, Java Structure and Variables and Expressions Quiz
10/12:
Chapters 1,2, 3 & 7 and part of 8
Ensure you can read both an Alice and Java program and tell what
it will do from looking at the code. Be able to tell the order in which
each step happens, and the value of every variable at each step.
Know how to start a Java program with the correct syntax. This
means memorizing :
public class MyClassName
{
public static void main( )
{
//
your statements here ending in semi-colon
}
}
Know how to print a line with the correct syntax.
In Java: System.out.println(<whatever you want to print>
+ <whatever you want to print>);
example: System.out.println(<whatever you want to print> + <whatever you want to
print> );
Remember: the semi-colon; capitalize System, use both
parentheses;
Remember quotes around text and not around variable names
In Alice: Drag the say command over.
Variables
Know what data type of variable you want to create in both Alice
and Java.
In Alice the possible choices include Number, String,
Boolean.
In Java, the choices include: (I struck out type you do not
need to know for the quiz.)
byte (-128 to 127)
int (-2147483648 to 2147483647) all whole numbers
long (whole number
bigger than int)
double (handles decimal places)
char (a
single letter)
boolean
(true/false)
String.(holds text) -- note that String is really a class
holding char, and not a primitive type like the ones above
If you were given the following values, what data type would
you create to hold the value: 0.5; 20,000,000,000; 0, 333.5, abc, 10
Know how to create a variable in program
In Java: <type> <variable name> ; example: int sum
;
In Alice: Click the new variable or new parameter button.
Know how to change variable contents:
In Java: <variable name> = <some expression>; example: sum = 5 ;
In Alice: Drag the variable to a blank line to create a set
statement.
Know how to trace the value of a variable at any time.