Home Tutorial Java Scjp Part7 SCJP Module-7 Question-8

 
 

SCJP Module-7 Question-8
Posted on: July 14, 2010 at 12:00 AM
This program will test your knowledge about the constructor and Integer class in Java. It will also test your understanding about the flow of program in Java.

Given a sample code:

1    public class Test {
2    int a = 1;
3    int b;

4    public Test(Integer x) {
5    b = a + x;
6    System.out.println(b);
    }

7    public static void main(String[] args) {
8    new Test(new Integer(4));
}}

What will be the result of above code ?

(A) 5
(B) An exception is thrown at runtime.
(C) Compilation fails because of an error on line 4.
(D) Compilation fails because of an error on line 8.

Answer:

(A)

Related Tags for SCJP Module-7 Question-8:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.