Multiple choice technology programming languages

What is the output of the following code for exampleprint(1)? static void exampleprint(int inputitem) { if (inputitem == 0) { System.out.print("*"); } else { System.out.print("["); exampleprint(inputitem - 1); System.out.print(","); exampleprint(inputitem - 1); System.out.println("]"); } }

  1. *

  2. [,]

  3. ,,*

  4. None of the Above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The recursive method exampleprint(1) follows this flow: print '[' then call exampleprint(0) which prints '', then print ',', then call exampleprint(0) again which prints '', then print ']' and newline. Result: [,]