178k views
2 votes
What is the output of the following program when the method is called with 4?

void unknown(int n)

{

if(n>0)

{

System.out.print("?");

unkown(n-1);

}

}

A. None of the other answers

B.???

C.?????

D.????

User Mcbowes
by
5.5k points

1 Answer

7 votes

Answer:

A.

Step-by-step explanation:

void unknown(int n) defines a methodes that doesn't return a value, hence unknow(int n) is a function... it is function that prints the value ? as many times as you tell it, hence for n=4 it would print ????. However, it doesn't return a value an interger, string etc..., so it doesn't give an output .

User Martosfre
by
5.5k points