• 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: 9597
36
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!
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!