🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Recursion and Stack Frames: all 10 questions

Quiz: Recursion and Stack Frames · Question 10 of 10

Each recursive call of fact(n) has its own copy of n because:

Each recursive call of fact(n) has its own copy of n because:

  1. A.n is a global variable
  2. B.n is static
  3. C.each call gets its own stack frame holding its parameters
  4. D.the compiler copies n into the heap
Answer & explanation

Correct answer: each call gets its own stack frame holding its parameters

Separate frames mean separate copies, so the calls do not overwrite each other's n.

Can you get the rest right without peeking?

Take the timed Quiz: Recursion and Stack Frames quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →