A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Mock Exam Errata
Marcus Green Exam 1 Question 25
Joined: Sep 03, 2009
Sep 03, 2009 12:38:21
What will happen if you attempt to compile and run the following code?
Integer ten=new Integer(10);
Long nine=new Long (9);
System.out.println(ten + nine);
System.out.println(i + ten);
1) 19 followed by 20
2) 19 followed by 11
3) Compile time error
4) 10 followed by 1
Marcus states the correct answer is: 3) Compile time error - The wrapper classes cannot be used like primitives.
But when I put this code in a class with main(), it compiled and matched answer #2, 19 followed by 11
Joined: Jul 15, 2009
Sep 04, 2009 22:45:14
Yeah your answer is correct. I think Long nine = 9 will give the compile time error. Or may be this mock is for an older version of
like prior to java5.
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor.
- Java 6
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
subject: Marcus Green Exam 1 Question 25
Qn on Wrapper classes.
Marcus Green Q25
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014