What does the JVM throw when a thread needs a larger stack than is permitted, for example through unbounded recursion?
Correct answer B. StackOverflowError
Explanation
The JVM specification states that StackOverflowError is thrown when a computation in a thread requires a larger stack than allowed, and runaway recursion is the usual cause. OutOfMemoryError relates to failing to obtain memory, typically on the heap, or to expand a stack. Being an Error, a stack overflow is normally not caught by applications.
Answer checked How we write and check questions
Discussion