What will happen if we don't have termination statement in recursion ?

Search Interview Questions

 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text


Interview Questions and Answers

 Q1. What will happen if we don't have termination statement in recursion ?
Ans. Function call allocates a stackframe in stack. Every stackframe will use some memory to store local variables, parameters and to remember return address. Without terminating condition stackframes will keep consuming memory from stack and eventually program will result in stackoverflow error.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     recursion   break statement  break  stackoverflow exception  stackoverflow  memory management  memory  exceptions

Related Questions

  What are different ways to create String Object? Explain.
  Does garbage collection guarantee that a program will not run out of memory?
  What is a String Pool ?
  Describe, in general, how java's garbage collector works ?
  Describe what happens when an object is created in Java ?
  What are various types of Class loaders used by JVM ?
 Why two types of memory - stack and heap are required by Java ?
  When are static variables loaded in memory ?
  Explain java.lang.OutOfMemoryError ?
  Should we override finalize method ?

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: