Consider the following code: public class Exception {    pub…

Consider the following code: public class Exception {    public void x() {        throw new IndexOutOfBoundsException();    }    public void y(int n) {        try {            if (n > 20)                x();            else                z();        } catch (IndexOutOfBoundsException e) {            System.out.println(“Index out of bounds caught in y”);        } catch (Exception e) {            System.out.println(“Exception caught in y”);        }    }    public void z() {        throw new NullPointerException();    }}What will be the output when the following method call is made? Exceptional ex = new Exceptional();ex.z();  

Suppose the class Undergraduate extends the class Student wh…

Suppose the class Undergraduate extends the class Student which extends the class Person. Given the following variable declaration:Person p = new Person();Student s = new Student();Undergraduate ug = new Undergraduate(); Which of the following assignments are correct? 1) p = ug;2) p = new Undergraduate();3) ug = new Student();4) ug = p;