Whenever there is a local variable with the same name as that of a global variable, the compiler gives precedence to the local variable.
int globalVar = 2;
int globalVar = 5;
The output of the above code is 5. This is because, although both the variables have the same name, the compiler has given preference to the local scope.