Sail E0 Webinar
Question
What will be the correct output for the given code snippet?
class maths  {     int fact(int n)      {         int result;         if (n == 1)         return 1;         result = fact(n - 1) * n;         return result;     } }  class Output  {     static void main(String args[])      {         maths obj = new maths() ;         Console.WriteLine(obj.fact(4)*obj.fact(2));     } }
Options:
A .  64
B .  60
C .  120
D .  48
Answer: Option D


4! = 4*3*2*1 & 2! = 2*1 .So, 24*2 = 48.
Output : 48



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

More Questions on This Topic :


Latest Videos

Latest Test Papers