Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Whizlabs question doubt. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Whizlabs question doubt." Watch "Whizlabs question doubt." New topic

Whizlabs question doubt.

Alex Serna
Ranch Hand

Joined: Sep 18, 2009
Posts: 58
Hi everyone,

I found this question on a mock exam from Whizlabs and I don't really understand why it is this way:

I thought this would give a compile error since "d" is a Double and we are assigning it a Boolean. The explanation says that "d" gets redeclared. I thought that you couldn't redeclare a variable in java, that you could only shadow an existing variable...

Ankit Garg

Joined: Aug 03, 2008
Posts: 9463

This statement won't create a variable in the generated servlet file. It will be something like this

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Alex Serna
Ranch Hand

Joined: Sep 18, 2009
Posts: 58
Thank you Ankit!
I agree. Here's the link:
subject: Whizlabs question doubt.
It's not a secret anymore!