+ 1
Not able to catch StackoverflowException
The below code attempts to dividebyzero causing DivideByZeroException and it is caught in the catch block static void main() { try { console.write(5/0); } catch (Exception ex) { console.write("abc"); } Nw the code below calls the main() method recursively causing StackOverflowException,but it is not caught in the catch block static void main() { try { main(); } catch (Exception ex) { console.write("abc"); } } output is supposed to be "abc",but it throws the exception. Cn someone plz explain abt dis behavior
2 Respostas
+ 4
In order to be able to catch a exception main must be running. If the exception kills main you won't be able to catch the exception.
+ 2
Cus you do the recursive without bool or throwed exception handle at all 😑