Java Recursion Interview MCQ Questions and Answers

Study and learn Interview MCQ Questions and Answers on Java Recursion. Attend job interviews easily with these Multiple Choice Questions. You can print these Questions in default mode to conduct exams directly. You can download these MCQs in PDF format by Choosing Print Option first and Save as PDF option next using any Web Browser.

Go through Java Theory Notes on Recursion before reading these objective questions.



1) Recursion in Java is a way of calling the method from within the same method. State TRUE or FALSE.
A) TRUE
B) FALSE
C) -
D) -
Answer [=]
Answer[=]
2) Check the below code and state whether it is called Recursion in Java?
void methodA()
{
  methodB();
}
void methodB()
{
  methodA();
}
A) TRUE
B) FALSE
C) -
D) -
Answer [=]
Answer[=]
3) Java uses ___ type of memory to implement Recursion.
A) Heap
B) Stack
C) Register
D) None
Answer [=]
Answer[=]
4) Java uses Stack type memory instead of Heap type memory in implementing Recursion because of ___ feature of STACK.
A) FIFO (First In First Out)
B) LIFO (Last In First Out)
C) Round Robin
D) None
Answer [=]
Answer[=]
5) Recursion in Java applies to ___.
A) Constructors
B) Variables
C) Methods
D) Blocks
Answer [=]
Answer[=]
6) Uses are Recursion in Java are___.
A) Traversing folders and files on a disk
B) Traversing the nodes of a Binary Tree
C) Evaluating Nth order equations and Factorials
D) All the above
Answer [=]
Answer[=]
7) Which is better in terms of memory utilization Recursion or Loops in Java?
A) Recursion
B) Loops
C) -
D) -
Answer [=]
Answer[=]


 

8) Which is the common problem with Recursive methods in Java?
A) StackOverflowError
B) IndexOutOfBoundsException
C) OutOfMemoryError
D) None
Answer [=]
Answer[=]
9) Recursion usually stops when the Java Runtime encounters an IF or ELSE statement with a RETURN statement. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
10) Attempting to call a method recursively without a proper RETURN statement leads to ___.
A) Stack Overflow errors
B) Buffer Overflow errors
C) Compile-time errors
D) ALL
Answer [=]
Answer[=]
11) A Java program with recursion can be completed with few lines of code when compared to using Loops. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
12) It is difficult to write a program with recursion than using multiple loops. State TRUE or FALSE.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
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();
  }
}
A) 4 3 2 1
B) 3 2 1
C) 3 2 1 0
D) Compiler error
Answer [=]
Answer[=]
14) A Recursive method does not need to return a value always. State TRUE or FALSE.
A) TRUE
B) FALSE
C) -
D) -
Answer [=]
Answer[=]


 

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;
  }
}
A) 10
B) 6
C) 0
D) Infinite loop
Answer [=]
Answer[=]
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;
  }
}
A) 24
B) 6
C) 0
D) Infinite loop
Answer [=]
Answer[=]
17) To end a recursive method a RETURN statement is usually kept inside ___.
A) IF block
B) ELSE block
C) IF or ELSE block
D) None
Answer [=]
Answer[=]
18) In most of the scenarios, a recursive method returns ____.
A) void
B) Some value or object
C) -
D) -
Answer [=]
Answer[=]
19) What is the maximum number of levels in a Recursion?
A) 8
B) 16
C) 32
D) No limit
Answer [=]
Answer[=]
20) Which is bigger in size Stack Memory or Heap Memory?
A) Stack Memory
B) Heap Memory
C) -
D) -
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Try Some Java Books

Book Price
1. Java - The Complete Reference  Check Price
2. Core Java: An Integrated Approach, Black Book Check Price
3. Java All-in-One for Dummies Check Price
4. OCP Java SE 8: Programmer II Check Price
5. Programming with Java Check Price
6. Head First Java Check Price

We may get some affiliate commission for the above purchases.