StackOverflowError occurs when stack memory is exhausted due to
excessive method calls, typically caused by infinite or very deep
recursion. OutOfMemoryError occurs when the JVM cannot allocate
more memory, usually because heap memory is exhausted by excessive
object creation or memory leaks







