Menu
Question Index
...

What will be the output of the following program?

class Room {
    int r1, r2;
}
class House extends Room {
    int paints;
}
public class Test {
    public static void main(String[] args) {
        Room[] r = new House[5];
        r[1] = null;
        System.out.println(r[1]);
        try {
            r[0] = new House();
        } catch (ArrayStoreException e) {
            System.out.println("array store exception");
        } finally {
            System.out.println("final block execute");
        }
    }
}


null
array store exception
array store exception
final block execute
null
final block execute
final block execute
Compilation Error or Runtime Error

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