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[3];
        scores = {215, 234, 218, 189, 221, 290};
        
        for(int score : scores)
        {
            System.out.print(score + "  ");
        }
    }
}


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

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App