Friday, September 4, 2009

SCJP Questions

1 public class test {
2 public static void add3 (Integer i) }
3 int val = i.intValue ( );
4 val += 3;
5 i = new Integer (val);
6 }
7
8 public static void main (String args [ ] ) {
9 Integer i = new Integer (0);
10 add3 (i);
11 system.out.printIn (i.intValue ( ) );
12 }
13 )
What is the result?
A. Compilation will fail.
B. The program prints "0".
C. The program prints "3".
D. Compilation will succeed but an exception will be thrown at line 3.
Answer: B

0 comments:

Post a Comment

 

About

Site Info

Information Source

Academy of JAVA by Rajesh Rolen Copyright © 2009 Community is Developed by Rajesh Kumar Rolen WebSite

/* tracking code by yahoo login */