1. A program with infinite recursion will act similarly to a program with an infinite loop. True or False?

2. Unchecked exceptions must be caught or propagated, or a program will not compile. True or False?

3. Once a method is overridden in a subclass, the original version can never be referenced from within the subclass. True or False?

4. An exception will be propagated until it is caught and handled or until it is passed out of the main method.   True or False?

5. An exception will be propagated until it is caught and handled or until it is passed out of the main method. True or False?

6.

Show the output of running the class Test in the following code lines:

interface A {   

void print();

}

class C {}

class B extends C implements A {  

public void print() { }

}

class Test {

public static void main(String[] args) {

    B b = new B();

    if (b instanceof A)

      System.out.println(“b is an instance of A”);

    if (b instanceof C)

      System.out.println(“b is an instance of C”);

}

                            }

a.         Nothing.

b.         b is an instance of A.

c.         b is an instance of C.

d.         b is an instance of A followed by b is an instance of C.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *