Home / MCQ Bank / Computer
Computer Classes And Objects In C Sharp

What will be the output of the following C# code snippet? class maths { public int fact(int n) { int result; result = fact(n - 1) * n; return result; } } class Program { static void Main(string[] args) { maths obj = new maths(); Console.WriteLine(obj.fact(4)); Console.ReadLine(); } }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option D • Runtime Error

Related Computer Questions

In a weighted graph, what does a negative weight cycle indicate for shortest path algorithms? What is the output for the below code? public class A{ int add(int i, int j){ return i+j; } } public class B extends A{ public static void main(String argv[]){ short s = 9; System.out.println(add(s,6)); } } When does Exceptions in Java arises in code sequence? Ctrl + Q Shortcut is used in Microsoft Word to_____________? What will be the output of the following C# code? static void Main(string[] args) { int [] a = {1, 2, 3, 4, 5}; fun(a); Console.ReadLine(); } static void fun(params int[] b ) { int[] k = { 3, 4, 7, 8,'\0' }; for (int i = 0; i < b.Length; i++) { b[i] = b[i] + k[i] ; Console.WriteLine( b[i] + " "); } }