Question
public class RecursionTest3
{
public static void main(String[] args)
{
RecursionTest3 rt3 = new RecursionTest3();
int multiplication = rt3.multiplier(4);
System.out.println(multiplication);
}
int multiplier(int in)
{
System.out.println("IN " + in);
int mul = 0;
if(in ==0)
return 1;
mul= in * multiplier(--in);
return mul;
}
}
a.
24
b.
6
c.
0
d.
Infinite loop
Posted under Java Programming
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of the below Java program with Recursion?
Aubrey : June 26, 2023
What is the output of the below Java program with Recursion?
public class RecursionTest3
{
public static void main(String[] args)
{
RecursionTest3 rt3 = new RecursionTest3();
int multiplication = rt3.multiplier(4);
System.out.println(multiplication);
}
int multiplier(int in)
{
System.out.println("IN " + in);
int mul = 0;
if(in ==0)
return 1;
mul= in * multiplier(--in);
return mul;
}
}
Similar Questions
Discover Related MCQs
Q. A Recursive method does not need to return a value always. State TRUE or FALSE.
View solution
Q. It is difficultto write a program with recursion than using multiple loops. State TRUE or FALSE.
View solution
Q. A Java program with recursion can be completed with few lines of code when compared to using Loops. State TRUE or FALSE.
View solution
Q. Attempting to call a method recursively without a proper RETURN statement leads to ___.
View solution
Q. Recursion usually stops when the Java Runtimeencounters an IF or ELSE statement with a RETURN statement. State TRUE or FALSE.
View solution
Q. Which is the common problem with Recursive methods in Java?
View solution
Q. Which is better in terms of memory utilization Recursion or Loops in Java?
View solution
Q. Uses are Recursion in Java are___.
View solution
Q. Recursion in Java applies to ___.
View solution
Q. Java uses Stack type memory instead of Heap type memory in implementing Recursion because of ___ feature of STACK.
View solution
Q. Java uses ___ type of memory to implement Recursion.
View solution
Q. Recursion in Java is a way of calling the method from within the same method. State TRUE or FALSE.
View solution
Q. Which tab is used to pass command line argument in eclipse?
View solution
Q. ___________ is a very small Java framework that makes it trivial to parse command line parameters.
View solution
Q. args in an array of String.
View solution
Q. Number of arguments can be passed to main() is?
View solution
Q. ____________method can be given parameters via using command line arguments.
View solution
Q. Which of the following statements is true?
View solution
Q. Which of the following statements is true?
View solution
Q. Which statement is true?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!