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 Windows {
    public static void main(String[] args) {
        Room[] r = new House[2];
        r[1] = null;
        System.out.println(r[1]);
        try {
            r[0] = new Room();
        } catch (ArrayStoreException e) {
            System.out.println("array store exception");
        } finally {
            System.out.print("final block execute");
        }
    }
}


null
array store exception
array store exception
final block execute
null
final block execute
null
array store exception
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