alexbiersack7439 alexbiersack7439
  • 22-08-2019
  • Computers and Technology
contestada

what is the output of the following program when the method is called with 4?

void unknown(int n)

{

if(n>0)

unkown(n-1);

System.out.print("?");

}

A. None of the other answers

B.???

C.?????

D.????

Respuesta :

Branta Branta
  • 29-08-2019

Answer:

C. ?????

Explanation:

Given code:

void unknown(int n)

{

if(n>0)

unkown(n-1);

System.out.print("?");  

}

Calling code: unknown(4)

This is a recursive invocation of unknown function and causes ? to be printed 5 times once each for following values of n.

  • unknown invocation with n=4
  • unknown invocation with n=3
  • unknown invocation with n=2
  • unknown invocation with n=1
  • unknown invocation with n=0

When n becomes 0, termination condition is reached and the function returns.

So the output is ?????

Answer Link

Otras preguntas

solve and check 1/4 (8-6x+12)
How did the Dutch extract raw materials from their colonies in the East Indies?
4 times a number is 64 what is the number
To determine the appropriate landing speed of an airplane, the formula D = .1x 2 − 3x + 22 is used, where x is the initial landing speed in feet per second and
Write an equation of a line that is parallel to the line whose equation is 3y=x+6 and that passes through the point (-3,4).
150% of what number is 600?
How much does pi equal?
what is the difference between the product of 19 and 3.6 , and thw sun of 2.87 and 3.5
Which of these is a biotic factor of an ecosystem? A. the bacteria that live in the intestine of a rabbit B. the rocks that provide cover for a rattlesnake C. t
In the process of genetic engineering, what is the correct order of the steps? A. DNA separation, DNA extraction, and cutting DNA B. DNA extraction, cutting DNA