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));   } }
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));   } }
Answer: Option D
Was this answer helpful ?
4! = 4*3*2*1 & 2! = 2*1 .So, 24*2 = 48.
Output : 48
Was this answer helpful ?
Submit Solution