Menu
Question Index
...

What will be the output of the following program?

public class PhoneRings {

    public static void main(String[] args) {
        System.out.print(call(53) + " " + call(25));
    }

    public static int call(int number) {
        System.out.print(number + ":");
        if (number % 7 == 0) {
            return 77;
        }
        if (number % 6 == 0) {
            return 66;
        }
        return call(number - 1);
    }
}


53:52:51:50:49:25:24:77 66
53:52:51:50:49:77 25:24:66
Some other output or Compilation Error
Throws StackOverflowError

Doubts

Problems

Topic: Recursive In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App