Java Reference
In-Depth Information
IN THEORY
1.11
Let b have the value of 5 and c have the value of 8. What is the value
of a , b , and c after each line of the following program fragment:
a = b++ + c++;
a = b++ + ++c;
a = ++b + c++;
a = ++b + ++c;
What is the result of true && false || true ?
1.12
For the following, give an example in which the for loop on the left is
not equivalent to the while loop on the right:
1.13
init;
for( init; test; update ) while( test )
{ {
statements statements
update;
} }
For the following program, what are the possible outputs?
1.14
public class WhatIsX
{
public static void f( int x )
{ /* body unknown */ }
public static void main( String [ ] args )
{
int x = 0;
f( x );
System.out.println( x );
}
}
IN PRACTICE
1.15
Write a while statement that is equivalent to the following for frag-
ment. Why would this be useful?
for( ; ; )
statement
Write a program to generate the addition and multiplication tables for
single-digit numbers (the table that elementary school students are
accustomed to seeing).
1.16
Write two static methods. The first should return the maximum of three
integers, and the second should return the maximum of four integers.
1.17
Search WWH ::




Custom Search