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


Share on Google+Share on Google+
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.




Related Tags for SCJP Module-7 Question-8:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 14, 2010

Recommend the tutorial

Advertisements Advertisements