Java
TOPIC 19 – WHILE STATEMENTS – PART 1
AP EXTRA
AP LESSON WORK
QUESTION
1
What will the
following programs output? Note that
we are not looking at too many examples here because this will not come up
often – if ever.
a)
|
int x = 0;
while(x < 5)
System.out.println("hi");
x++;
|
b)
|
int a = 0;
int b = 0;
while(b < 5)
while(a < 4)
{
a+=2;
b++;
System.out.println(a
+ b);
}
|
|