C# program to demonstrate the stack overflow exception
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Program:
The source code to demonstrate the stack overflow exception is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created a class ExceptionDemo that contains two methods increaseVal() and Main(). The increaseVal() is a recursive method, here we increase the value of the parameter, due to recursion, method calls indefinitely then StackOverflowException exception get generated by the program that will be caught by "catch" block and print exception message on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer