-
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 NullPointerException occurs at runtime
- The value “8” is printed at the command line
- An IllegalStateException occurs at runtime
- Compilation fails because of an error in line
- None of these
Correct Option: C
Because we are performing operation on reference variable which is null.