aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Qn on Wrapper classes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Qn on Wrapper classes." Watch "Qn on Wrapper classes." New topic
Author

Qn on Wrapper classes.

Girish Nagaraj
Ranch Hand

Joined: Apr 19, 2006
Posts: 153
Look at the following snippet of code from Marcus green mock exam

Integer ten = new Integer(10);
Long nine = new Long (9);
System.out.println(ten + nine);

int i=1;
System.out.println(i + ten);

Output is 19 followed by 11.
But what anwer says is :

Compile time error

The wrapper classes cannot be used like primitives.

Why the diff. I am using java sdk 1.5.
Will the output be diff. if I use sdk 1.4.
Shaliey Gowtham
Ranch Hand

Joined: Mar 20, 2006
Posts: 104
Only from 1.5 you having unboxing
This code is valid only from 1.5 so in 1.4 its a compiler error
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

You can use the -source 1.4 option to see what would happen with java 1.4


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Qn on Wrapper classes.
 
Similar Threads
Wrappers
wrapper classes
operations on wrapper classes
Marcus Mock #25
Wrapper class