1.

What will be output of the following code?

public class Result
{
Integer K;
int p;
public Result(int q)
{
p = K+q;
System.out.println(p);
}
public static void main(String[] args)
{
new Result (new Integer(8));
}
}

A. A NullPointerException occurs at runtime
B. The value 8 is printed at the command line
C. An IllegalStateException occurs at runtime
D. Compilation fails because of an error in line
E. None of these
Answer» D. Compilation fails because of an error in line


Discussion

No Comment Found

Related MCQs