+ 1
If I write const int x=5; after many lines I again write const int x =10; What will the final value x at end of execution or it will be an error
5 Answers
+ 4
it will be a syntax error, you cannot declare two variables in a scoop with same name, nor you can assign a "const" with new value
+ 3
it gives you error because after making variable constant you can't modify it in whole program, while using it as local variable you can modify it externally.
+ 2
yes, that is true. variable with the same name is forbidden, so, it will be Error
+ 1
if you are trying to declare two constants with the same name in one class you will get a compile time error.
- 2
but you can call another const variable x only if you call it in another method (subroutine)