Menu
Topics Index
...
`

Store Exception


If you need explanation Read this topic

If you need Answer Take test on this topic

Store Exception
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");
        }
    }
}

A. Mother Father 0
executed
B. store exception
executed
C. executed
D. Compilation Error or Runtime Error
Topic: Object As A Super Class In Java

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.

D. Because we cannot assign integer object in place of  string object.

Posted by Ravi Theja Tallam    2014-01-21 03:53:12


compilation error exception will arise

Posted by Akash Kolariya    2014-01-21 05:34:32


D. Because we cannot assign integer object in place of string object.

Posted by Rakesh Arveti    2014-01-21 06:23:08


Congratulations Ravi Theja Tallam. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-01-22 04:01:38


© meritcampus 2019

All Rights Reserved.

Open In App