Menu
Question Index
...

What will be the output of the following program?

public class Sections {
    public static void main(String args[]) {
        char sections[] = {'A', 'B', 'C', 'D'};
        try {
            for (int i = 0; i <= sections.length; i++)
                System.out.print(sections[i] + " ");
        } catch (Exception e) {
            System.out.print(e);
        }
    }
}


A B C D
A B C D java.lang.ArrayIndexOutOfBoundsException: 4
Compilation Error
Runtime Error for some other reason

Doubts

Problems

Topic: Java Built In Exceptions Checked Exceptions, Unchecked Exceptions

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App