Menu
Topics Index
...
`

for loop with continue statement


If you need explanation Read this topic

If you need Answer Take test on this topic

for loop with continue statement
What will be the output of the following program?
public class Condition {
    public static void main(String[] args) {
        int[] numbers = {01111, 02222, 03333, 04444, 05555};
        for (int number : numbers) {
            if (number == 3333) {
                continue;
            }
            System.out.print(number + ",");
        }
    }
}

A. 1111,2222,4444,5555,
B. 1111,2222,3333,4444,5555,
C. 01111,02222,03333,04444,05555,
D. Some other output
E. Compilation Error or Runtime Error
Topic: Unknown

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans is D : because leading 0 in java implies the number is octal..therfore it prints the octal conversion of all those numbers

Posted by Haritha Damarla    2013-11-01 09:09:45


D is the answer.as the octals for the given numbers gives ...585 1170   1755 2340 2925

Posted by Shabaaz Shaikz    2013-11-01 10:12:13


ans D : because leading 0 in java consider as the number octal type of data.so it will give some other output..,which is equivalent values in the octal representation;

Posted by Sapparapu Pradeep Kumar    2013-11-01 11:19:15


and also here the if block wont work

Posted by Sapparapu Pradeep Kumar    2013-11-01 11:19:39


so it wil give 5 numbers in output

Posted by Sapparapu Pradeep Kumar    2013-11-01 11:19:55


Congratulations Shabaaz Shaikz. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2013-11-04 04:16:45


thnks....MC..

Posted by Shabaaz Shaikz    2013-11-04 05:06:20


© meritcampus 2019

All Rights Reserved.

Open In App