Study the following programme // precondition : x >= 0 public void demo(int x)…

ISRO Scientist/Engineer SC · 2007 · Computer ScienceBEL · Computer Science · 2007

Study the following programme
// precondition : x >= 0 public void demo(int x) { System.out.print(x % 10); if( (x / 10) != 0 ) { demo(x / 10); } System.out.print(x % 10); }
Which of the following is printed as a result of the call demo (1234)?

  1. A.

    1441

  2. B.

    3443

  3. C.

    12344321

  4. D.

    43211234

Attempted by 436 students.

Show answer

Correct answer: D

The worked solution is available to enrolled students.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…