InfyTQ Recursion Quiz 3

Question 1

Time: 00:00:00
Recursion is similar to which of the following?

Switch Case

Switch Case

Loop

Loop

If-else

If-else

if elif else

if elif else

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
Which of these data types is used by the operating system to manage the Recursion in Java?

Array

Array

Stack

Stack

Queue

Queue

 Tree

 Tree

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What will be the output of the following Java program?

  1.    class recursion

  2.    {

  3.        int fact(int n)

  4.        {

  5.            int result;

  6.            if (n == 1)

  7.                return 1;

  8.            result = fact(n - 1) * n;

  9.            return result;

  10.        }

  11.    }

  12.    class Output

  13.    {

  14.        public static void main(String args[])

  15.        {

  16.            recursion obj = new recursion() ;

  17.            System.out.print(obj.fact(1));

  18.        }

  19.    }

1

1

30

30

120

120

 Runtime Error

 Runtime Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
Look at square numbers again:

square(1) = 1

square(N) = square(N-1) + 2N -1

Which Java method below successfully implements this definition?

int square( int N ) {   if ( N<1 )   {     return 1;   }   else   {     return N*N; }

int square( int N ) {   if ( N<1 )   {     return 1;   }   else   {     return N*N; }

int square( int N ) {   if ( N==1 )   {     return 1;   }   else   {     return square(N-1) + 2*N - 1;     } }

int square( int N ) {   if ( N==1 )   {     return 1;   }   else   {     return square(N-1) + 2*N - 1;     } }

int square( int N ) {   if ( N=1 )   {     return 1;   }   else   {     return square(N-1) + 2*N - 1;     } }

int square( int N ) {   if ( N=1 )   {     return 1;   }   else   {     return square(N-1) + 2*N - 1;     } }

int square( int N ) {   if ( N==1 )   {     return 1;   }   else   {     return square(N);     } }

int square( int N ) {   if ( N==1 )   {     return 1;   }   else   {     return square(N);     } }

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00

  1. class recursion

  2.    {

  3.        int fact(int n)

  4.        {

  5.            int result;

  6.            if (n == 1)

  7.                return 1;

  8.            result = fact(n - 1) * n;

  9.            return result;

  10.        }

  11.    }

  12.    class Output

  13.    {

  14.        public static void main(String args[])

  15.        {

  16.            recursion obj = new recursion() ;

  17.            System.out.print(obj.fact(6));

  18.        }

  19.    }

1

1

30

30

120

120

720

720

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Which of these methods calls update() method?

 notify()

 notify()

observeObject()

observeObject()

updateObserver()

updateObserver()

notifyObserver()

notifyObserver()

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
Which of these methods return a largest whole number less than or equal to variable X?

double ciel(double X)

double ciel(double X)

double floor(double X)

double floor(double X)

double max(double X)

double max(double X)

double min(double X)

double min(double X)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
Which of these functions return the absolute value of a variable?

abs()

abs()

absolute()

absolute()

absolutevariable()

absolutevariable()

 None of the mentioned

 None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/0

Accuracy

0%