What is the result?

Given:
1. public class Boxer1{
2. Integer i;
3. int x;
4. public Boxer1(int y) {
5. x = i+y;
6. System.out.println(x);
7. }
8. public static void main(String[] args) {
9. new Boxer1(new Integer(4));
10. }
11. }
What is the result?

Given:
1. public class Boxer1{
2. Integer i;
3. int x;
4. public Boxer1(int y) {
5. x = i+y;
6. System.out.println(x);
7. }
8. public static void main(String[] args) {
9. new Boxer1(new Integer(4));
10. }
11. }
What is the result?

A.
Compilation fails because of an error in line 5.

B.
The value “4” is printed at the command line.

C.
Compilation fails because of an error in line 9.

D.
An IllegalStateException occurs at runtime.

E.
A NullPointerException occurs at runtime.

F.
A NumberFormatException occurs at runtime.

Explanation:



Leave a Reply 0

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