Menu
Question Index
...

What will be the output of the following program?

public class Facts {
    public static void main(String[] args) {
        System.out.println(Fact.fact(5));
    }
}
class Fact {
    int fact(int n) {
        return n > 1 ? (fact(n - 1) * n) : 1;
    }
}


120
1
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Static and Non Static Variables - Static and Non Static Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App