A
Java Course Outline
Using the Java By Dissection
book
by Ira
Pohl and
Charlie McDowell
Show the output that would be produced by the following program:
public class P1 { public static void main(String[] args) { int a = 5, b = 4; System.out.println( a + "; " + b); b = b + a/3; System.out.println( a + ";" b + ";" ++b); } }
Check the Correct Box |
keyword |
identifier |
constant |
operator |
other |
---|---|---|---|---|---|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
public class P3{ int N = 5; public static void main(String[] args) { int i, sum = 1; for (i = 0; i <= N; i +=2) { sum = sum + i; System.out.println(" sum =" + sum); }; System.out.println(" i = " + i + " sum =" + sum); } }
int i = 3, j = 4, k = 0; i + j +k _____ i < j _____ k || j _____ i % j _____ k = ++j _____
int i = 1, j = 2, k = 4; i + j * k _____ i %% k _____ k / j/(i + 1) _____ 2 * ( k - 3) _____ (i = j) + k _____
public class P5{ public static void main(String[] args) { int count; for( count = 8; count > 0; count-- ) if (count == 6) System.out.println(" count is " + count); else if (count < 3) count = count -1; else System.out.println("so far "+ 8 - count); System.out.println("Final value: " + count); }
The method readInt()
is imported from
a) iostream.h
b) tio
c) java.util
d) stdio
e)other
The println()
method does not
a) print to the screen
b) act on a String
argument
c) add a newline to any output
d) output a String
e) all of these
The if
statement
a) performs flow of control
b) requires an assignment in its true part
c) must be used with a compound statement
d) all of the above
e)none of the above
A compound statement
a) always includes more than one statement in it
b) can only be used with a for
c) is used anywhere a single statement can be used
d) must be used with as the true part of an if
statement
e) none of these