Menu
Question Index
...

What will be the output of the following program?

class ForEachloop
{
    public static void main(String args[])
    {
        int[] scores = new int[10];
        scores = new int[] {215, 234, 218, 189, 221, 290};
        
        for(int score : scores)
        {
            System.out.print(score + "  ");
        }
    }
}


215 234 218 189 221 290
215 234 218 189 221 290 0 0 0 0
Compilation Error
Throws ArrayIndexOutOfBoundsException

Doubts

Problems

Topic: For-each Loop In Core Java Programming

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App