# Java Recursive Methods: Exercises, Practice, Solution

## Java Recursive Exercises [15 exercises with solution]

[** An editor is available at the bottom of the page to write and execute the scripts.** Go to the editor]

**1.** Write a Java recursive method to calculate the factorial of a given positive integer.

**2.** Write a Java recursive method to calculate the sum of all numbers from 1 to n.

**3.** Write a Java recursive method to calculate the nth Fibonacci number.

**4.** Write a Java recursive method to check if a given string is a palindrome.

**5.** Write a Java recursive method to calculate the exponentiation of a number (base) raised to a power (exponent).

**6.** Write a Java recursive method to reverse a given string.

**7.** Write a Java recursive method to find the greatest common divisor (GCD) of two numbers.

**8.** Write a Java recursive method to count the number of occurrences of a specific element in an array.

**9.** Write a Java recursive method to find the sum of all odd numbers in an array.

**10.** Write a Java recursive method to find the length of a given string.

**11.** Write a Java recursive method to generate all possible permutations of a given string.

**12.** Write a Java recursive method to find the maximum element in an array.

**13.** Write a Java recursive method to calculate the product of all numbers in an array.

**14.** Write a Java recursive method to find the sum of the digits of a given integer.

**15.** Write a Java recursive method to check if a given array is sorted in ascending order.

**More to Come ! **

* To run the code mouse over on Result panel and click on 'RERUN' button.*

**Java Code Editor**

**Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.**

**Weekly Trends**- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join