Question: Consider the following code. int x = 0; while (x < 5) { System.out.print(x + ); x++; } System.out.println(x); Suppose the statement x++; is
Consider the following code.
int x = 0;
while (x < 5) {
System.out.print(x + " ");
x++;
}
System.out.println(x);
Suppose the statement x++; is replaced. What will be printed for each of the following replacements?
1.x--;
2.x += 2;
3.x += 3;
4.x += x + 1;
Answer Choices
A. 0 3 6
B. results in an infinite loop
C. 0 1 3 7
D. 0 2 4 6
Second Part
How do you declare a Random variable and assign a new Random object to the variable?
A. new Random(r);
B. r = new Random( );
C. Random r;
D. Random r = new Random( );
E. Random r = Random.new( );
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
