Ask Question
3 October, 09:09

What is Recursion in Java?

a) Recursion is a class

b) Recursion is a process of defining a method that calls other methods repeatedly

c) Recursion is a process of defining a method that calls itself repeatedly

d) Recursion is a process of defining a method that calls other methods which in turn call again this method

+4
Answers (1)
  1. 3 October, 11:19
    0
    Recursion is a process of defining a method that calls itself repeatedly

    Explanation:

    Recursion is a basic programming technique of defining a method that calls itself repeatedly.

    One practical example is using recursion to find the factorial of a number.

    Consider the following java code below, it uses recursion to solve for the factorial of a number.

    class Main {

    public static void main (String[] args) {

    System. out. println ("Factorial of 3 is " + factorial (3));

    System. out. println ("Factorial of 5 is " + factorial (5));

    System. out. println ("Factorial of 7 is " + factorial (7));

    }

    //the factorial method uses recursion to find the factorial of the

    / / parameter of the integer pass into it

    private static int factorial (int n) {

    int result;

    if (n = =1) return 1;

    result = factorial (n-1) * n;

    return result;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What is Recursion in Java? a) Recursion is a class b) Recursion is a process of defining a method that calls other methods repeatedly c) ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers