293). 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

Show Answer

295). Which of these will happen if recursive method does not have a base case?

[A]An infinite loop occurs
[B]System stops the program after some time
[C]After 1000000 calls it will be automatically stopped
[D]None of the mentioned

Show Answer

296). Which of these is not a correct statement?

[A]A recursive method must have a base case
[B] Recursion always uses stack
[C]Recursive methods are faster that programmers written loop to call the function repeatedly using a stack
[D]Recursion is managed by Java Runtime environment

Show Answer

298). What will be the output of the following Java program?
    class recursion 
    {
        int func (int n) 
        {
            int result;
            result = func (n - 1);
            return result;
        }
    } 
    class Output 
    {
        public static void main(String args[]) 
        {
            recursion obj = new recursion() ;
            System.out.print(obj.func(12));
        }
    }

[A]0
[B]1
[C]Compilation Error
[D]Runtime Error

Show Answer

299). What will be the output of the following Java program?
    class recursion 
    {
        int func (int n) 
        {
            int result;
            if (n == 1)
                return 1;
            result = func (n - 1);
            return result;
        }
    } 
    class Output 
    {
        public static void main(String args[]) 
        {
            recursion obj = new recursion() ;
            System.out.print(obj.func(5));
        }
    }

[A]0
[B]1
[C]120
[D]None of the mentioned

Show Answer

300). What will be the output of the following Java program?
    class recursion 
    {
        int fact(int n) 
        {
            int result;
            if (n == 1)
                return 1;
            result = fact(n - 1) * n;
            return result;
        }
    } 
    class Output 
    {
        public static void main(String args[]) 
        {
            recursion obj = new recursion() ;
            System.out.print(obj.fact(5));
        }
    }

[A]24
[B]30
[C]120
[D]720

Show Answer

301). What will be the output of the following Java program?
    class recursion 
    {
        int fact(int n) 
        {
            int result;
            if (n == 1)
                return 1;
            result = fact(n - 1) * n;
            return result;
        }
    } 
    class Output 
    {
        public static void main(String args[]) 
        {
            recursion obj = new recursion() ;
            System.out.print(obj.fact(1));
        }
    }

[A]1
[B]30
[C]120
[D]Runtime Error

Show Answer

302). What will be the output of the following Java program?
    class recursion 
    {
        int fact(int n) 
        {
            int result;
            if (n == 1)
                return 1;
            result = fact(n - 1) * n;
            return result;
        }
    } 
    class Output 
    {
        public static void main(String args[]) 
        {
            recursion obj = new recursion() ;
            System.out.print(obj.fact(6));
        }
    }

[A]1
[B]30
[C]120
[D]720

Show Answer