Ask Question
23 October, 21:42

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.?

+1
Answers (1)
  1. 23 October, 22:57
    0
    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?
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “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. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers