MCQs
None.
Output:
$ javac Output.javac
$ java Output
720
fact() method recursively calculates factorial of a number, when value of n reaches 1,
base case is excuted and 1 is returned.
Output:
$ javac Output.javac
$ java Output
1
fact() method recursively calculates factorial of a number, when value of n reaches 1,
base case is excuted and 1 is returned.
Output:
$ javac Output.javac
$ java Output
120
None.
Output:
$ javac Output.javac
$ java Output
1
Since the base case of the recursive function func() is not defined hence infinite loop
occurs and results in stackoverflow.
Output:
$ javac Output.javac
$ java Output
Exception in thread "main" java.lang.StackOverflowError
None.
If a recursive method does not have a base case then an infinite loop occurs which
results in stackoverflow.
Recursions are always managed by using stack.
Recursion is the process of defining something in terms of itself. It allows us to
Recursion is always managed by operating system.