You are using a Whizlabs 1.4 test, but a Java 1.6 compiler? Hmm...OK then.
Did Java 1.4 have autoboxing?
Once you know the answer to that, you should be able to answer the question yourself.
Also, your code will not compile as you have declared the member "d1" twice.
Rajesh k Jha
Joined: May 10, 2009
I got the answer so i want to clarify one thing (I know this is somewhat silly question but still i think clarifying doubt is important) that
the return type double is Autoboxed to Double in line
and that is the reason i m not getting compile time error in 1.6
and it will not compile if i use 1.4 compiler....
Joined: Jun 09, 2009
"parseDouble()" returns a "double". The 1.6 compiler immediately autoboxes it to a "Double" object on that line of code. The 1.4 compiler on the other hand, has a nervous breakdown.
You can see what happens using "java -source 1.4 -target 1.4 YourClass.java" from the command line (or change options in your IDE).