• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Whizlabs question doubt.

 
Alex Serna
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...

Thanks!
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This statement won't create a variable in the generated servlet file. It will be something like this
 
Alex Serna
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ankit!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic