Menu
Question Index
...

What will be the output of the following program?

class Recursion
{
    public static void main(String[] args)
    {
        int ma = 35;
        int in = 67;
        int sta = recruse(ma, in);
        System.out.println("static = " + sta + "tic");
    }

    public static int recurse(int pub, int lic)
    {
        if (pub % 13 == 0)
        {
            return pub + lic;
        }
        return recurse(pub++, lic / 2);
    }
}


static = 41tic
static = 47tic
static = 43tic
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