Menu
Question Index
...

What will be the output of the following program?

public class StoreException {
    public static void main(String args[]) {
        Object x[] = new String[3];
        x[0] = "Mother";
        x[1] = "Father";
        x[2] = new Integer[0];
        String output = "";
        try {
            for (Object element : x) {
                output += element + " ";
            }
            System.out.println(output);
        } catch (ArrayStoreException e) {
            System.out.println("store exception");
        } finally {
            System.out.print("executed");
        }
    }
}


Mother Father 0
executed
store exception
executed
executed
Compilation Error or Runtime Error

Doubts

Problems

Topic: Object As A Super Class In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App