Which, inserted at line 6, produces the following output?

Given:

3. int num = 0, count;
4. while ( num < 3 ) {
5. num++;
6. // insert code here
7. System.out.println(“num = ” + num + ” : count = ” + count);
8. }
9. }
Which, inserted at line 6, produces the following output?
num = 1 : count = 1
num = 1 : count = 2
num = 2 : count = 1
num = 2 : count = 2
num = 3 : count = 1
num = 3 : count = 2

Given:

3. int num = 0, count;
4. while ( num < 3 ) {
5. num++;
6. // insert code here
7. System.out.println(“num = ” + num + ” : count = ” + count);
8. }
9. }
Which, inserted at line 6, produces the following output?
num = 1 : count = 1
num = 1 : count = 2
num = 2 : count = 1
num = 2 : count = 2
num = 3 : count = 1
num = 3 : count = 2

A.
while ( ++count < 3 ) {

B.
for ( count = 1 ; count < 3 ; count++ ) {

C.
for ( count = 0 ; count < 3 ; count++ ) {

D.
while ( ++count < 2 ) {

E.
for ( count = 1 ; count < 2 ; count++ ) {



Leave a Reply 0

Your email address will not be published. Required fields are marked *