Menu
Question Index
...

What will be the output of the following program?

public class PrintStatment12
{
    int sum = 0;
    public int getNumberSum(int number)
    {
        if (number == 0)
        {
            return sum;
        }
        else
            sum += (number % 10);
        getNumberSum(number / 10);
        return sum;
    }
    public static void main(String a[])
    {
        PrintStatment12 stmnt = new PrintStatment12();
        System.out.println(stmnt.getNumberSum(223));
    }
}


10
14
1
7
Compilation Error or Runtime Error

Doubts

Problems

Topic: Unknown

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App