Amazon Interview Question
Software Engineer / DevelopersThe stack frame is allocated at function call and all variables are stored in the same. So new frame is not created for {} block, in fact a new variable is created only thing is that the memory location of variable has same name as that of the previous one, so within that scope we refer to the newly created variable (i.e. i = 100).
+1 for the first two questions.
3.
No, it wont create a new activation record. An activation record or a stack frame is created during a function call which holds the return address, the parameters and variables declared in the function.
Answer is 100.
- JAG March 01, 2011No a stack frame would not be created as there is no function call.