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

Which has a greater energy, long wavelength red light or short wavelength uv light?.
Find xSomebody please help me​
hello people ~One of the following processes does not involve a chemical reaction, that is:(a) Melting of candle wax when heated(b) Burning of candle wax when h
Find the quotient when 99,678 is divided by 111.​
How is a precipitate evidence for a chemical reaction?​
Hello! How to do 10 part (c)?
Because of the pitch of the attic's roof, a bookcase that is 5 feet high must be place as shown. What is the measure of the angle formed by the roof and the flo
en Europa hay una gran variedad de arquitectura antigua y moderna Verdadero or falso?
A triangle has two sides of length 19 and 15. What is the largest possible whole-number length for the third side?
If ∠A > ∠B, then what is the relation between AC and BC?​