147k views
4 votes
Declaring a variable in the method’s body with the same name as a parameter variable in the method header is ___________.

a.a syntax error

b.a logic error

c.a logic error

d.not an error

User Bamdan
by
6.2k points

1 Answer

1 vote

Answer:

a. a syntax error

Step-by-step explanation:

When the same variable name is repeated in the parameter set and the method body, it will result in a syntax error. This is because the variable in the parameter has a local scope within the method body. Now if we declare another variable with the same name in the method body, it will result in redefinition of the variable and violate the uniqueness principle of variable names in the method code. This will give rise to syntax error.

User Benz
by
6.5k points