Answers

Question and Answer:

  Home  Java Classes

⟩ What is the output of the following? // A simple example of recursion.class Factorial { // this is a recursive method int fact(int n) { int result; if(n==1) return 1; result = fact(n-1) * n; return result; }} class Recursion { public static void main(String args[]) { Factorial f = new Factorial(); System.out.println("Factorial of 3 is " + f.fact(3)); }}A) Factorial of 3 is 3B) Factorial of 3 is 6C) Factorial of 3 is 9D) None of the above

D) None of the above

Exception in thread "main" java.lang.NoSuchMethodError: main

 144 views

More Questions for you: