Menu
Question Index
...

What will be the output of the following program?

public class Factorial
{
    public static void main(String args[])
    {
        for (int fact = 5; fact < 10; fact++)
        {
                 System.out.printf("%d! = %d, ", fact, findFactorial(fact));
        }
    }
    public static long findFactorial(long number)
    {
        if (number <= 1)
            return 1;
        else
            return number * findFactorial(number - 1);
    }
}


%d! = %d,
%d! = %d,
%d! = %d,
%d! = %d,
%d! = %d,
5! = 120, 6! = 720, 7! = 5040, 8! = 40320, 9! = 362880,
5! = 120,
6! = 720,
7! = 5040,
8! = 40320,
9! = 362880,
Compilation Error at LINE K because there is printf statement and also using %d.
Compilation Error for some other reason

Doubts

Problems

Topic: Java Formatter

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App