Multiple Choice Question

Quiz Guidelines

 

QID: 
376
Question: 

Note: This question may be considered too advanced for this exam. Given:

class MySuper{
public MySuper(int i){ }
}
abstract class MySub extends MySuper{
public MySub(int i){ super(i); }
public abstract void m1();
}
class MyTest{
public static void main(String[] args){
MySub ms = new MySub(){
public void m1() { System.out.println("In MySub.m1()"); }
};
ms.m1();
}
}

What will be the output when the above code is compiled and run?

Select 1 option

A. It will not compile.
B. It will throw an exception at run time.
C. It will print In MySub.m1()
D. It will compile and run without any exception but will not print anything.

Q&A Set: