+ Start a Discussion
nikitha kambamnikitha kambam 

Which three statements are accurate about variable scope?

A. Parallel blocks can reuse the same variable name.
B. A sub -block can reuse a parent block variable name if it is static.
C. A variable can be declared at any point In a block.
D.A sub -block can reuse a parent block's variable name if it is not static
is it correct
Phaneendra KPhaneendra K
Sub blocks can not reuse parent block variable name
refer : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_variables.htm
habtamu eshetehabtamu eshete
No, the correct answers are A & C. 
subblocks can not reuse a parent block variable name whether it is static or not.
AJ 711AJ 711
Variable Scope - Variables can be defined at any point in a block, and take on scope from that point forward. Sub-blocks can’t redefine a variable name that has already been used in a parent block, but parallel blocks can reuse a variable name. 
Check this link - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_variables.htm#:~:text=Variable%20Scope&text=Sub%2Dblocks%20can't%20redefine,can%20reuse%20a%20variable%20name.