TOTAL QS = 20Time [ 00 : 00 : 00 ]
00:00:00

Java Recursion Basics Online Test 1

Instructions

Total Questions: 20

Total Minutes: 20

This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on basics of Java Recursion with Methods. This test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics.

Go through Java Theory Notes on Recursion before attempting this test.

All the Best

Challenge SCORE

0 / 20

Take This Exam
1) Recursion in Java is a way of calling the method from within the same method. State TRUE or FALSE.
2) Check the below code and state whether it is called Recursion in Java?
void methodA()
{
  methodB();
}
void methodB()
{
  methodA();
}
3) Java uses ___ type of memory to implement Recursion.
4) Java uses Stack type memory instead of Heap type memory in implementing Recursion because of ___ feature of STACK.
5) Recursion in Java applies to ___.
6) Uses are Recursion in Java are___.
7) Which is better in terms of memory utilization Recursion or Loops in Java?
8) Which is the common problem with Recursive methods in Java?
9) Recursion usually stops when the Java Runtime encounters an IF or ELSE statement with a RETURN statement. State TRUE or FALSE.
10) Attempting to call a method recursively without a proper RETURN statement leads to ___.
11) A Java program with recursion can be completed with few lines of code when compared to using Loops. State TRUE or FALSE.
12) It is difficult to write a program with recursion than using multiple loops. State TRUE or FALSE.
13) What is the output of the below Java program with recursion?
public class RecursionTesting
{
  static int num=4;
  public static void main(String[] args)
  {
    new RecursionTesting().recursiveMethod();
  }

  void recursiveMethod()
  {
    num--;
    if(num == 0)
      return;
    System.out.print(num + " ");
    recursiveMethod();
  }
}
14) A Recursive method does not need to return a value always. State TRUE or FALSE.
15) What is the output of the below Java program with Recursion?
public class RecursionTest2
{
  public static void main(String[] args)
  {
    RecursionTest2 rt2 = new RecursionTest2();
    int sum = rt2.summer(4);
    System.out.println(sum);
  }

  int summer(int in)
  {
    int sum = 0;

    if(in ==0)
	  return 0;

    sum = in + summer(--in);	
    return sum;
  }
}
16) 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;
  }
}
17) To end a recursive method a RETURN statement is usually kept inside ___.
18) In most of the scenarios, a recursive method returns ____.
19) What is the maximum number of levels in a Recursion?
20) Which is bigger in size Stack Memory or Heap Memory?

 

 

Show some care. Like or Subscribe.
ExamTray App is now Available on Google Play EXAMTRAY android app link