C# Interview Questions - 22 | Snaprecruit.com

C# Interview Questions - 22 | Snaprecruit.com

C SHARP interview questions part 22

C SHARP interview questions part 22

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. Which of these data types is used by operating system to manage the Recursion in Csharp?

Correct Answer is : code runs successfully prints even number between 1 to 20

2. What will be the output of the given 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(); } }

Correct Answer is : Iterate the first 7 letters:

3. What will be the correct output for the given code snippet? class maths { public int fact(int n) { int result; if (n == 2) return 1; 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(); } }

Correct Answer is : 65 66 67 68 69 70

4. Which reference modifier is used to define reference variable?

Correct Answer is : Both They allow to pass arguments to the iterator that control what elements are obtained & This form of iterators can be overloaded

5. Select the output for following set of code : static void Main(string[] args) { int a = 5; fun1 (ref a); Console.WriteLine(a); Console.ReadLine(); } static void fun1(ref int a) { a = a * a; }

Correct Answer is : Math

6. Select the output for the following set of code : static void Main(string[] args) { int[] arr = new int[] {1 ,2 ,3 ,4 ,5 }; fun1(ref arr); Console.ReadLine(); } static void fun1(ref int[] array) { for (int i = 0; i < array.Length; i++) { array[i] = array[i] + 5; Console.WriteLine(array[i] + " "); } }

Correct Answer is : 8

7. Select the output for the following set of code : static void Main(string[] args) { int a = 10 , b = 20; Console.WriteLine("Result before swap is: "+ a +" "+b); swap(ref a, ref b); Console.ReadLine(); } static void swap(ref int i, ref int j) { int t; t = i; i = j; j = t; Console.WriteLine("Result after swap is:"+ i +" "+j); }

Correct Answer is : 4.772

8. Select output for the set of code : static void Main(string[] args) { int []a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; func(ref a); Console.ReadLine(); } static void func(ref int[] x) { Console.WriteLine(" numbers are:"); for (int i = 0; i < x.Length; i++) { if (x[i] % 2 == 0) { x[i] = x[i] + 1; Console.WriteLine(x[i]); } } }

Correct Answer is : approximately 2.72

9. Select the wrong statement about ‘ref’ keyword in C#?

Correct Answer is : 1 2 1 2

10. Select correct differences between ‘=’ and ‘==’ in C#.

Correct Answer is : 64

11. Select the correct output for following set of code. static void Main(string[] args) { int X = 0; if (Convert.ToBoolean(X = 0)) Console.WriteLine("It is zero"); else Console.WriteLine("It is not zero"); Console.ReadLine(); }

Correct Answer is : 3

12. Select the output for the following set of code : static void Main(string[] args) { int x = 4 ,b = 2; x -= b/= x * b; Console.WriteLine(x + " " + b); Console.ReadLine(); }

Correct Answer is : 625

13. What is output for the following set of expression? int a+= (float) b/= (long)c.

Correct Answer is : 3

14. Select the output for the following set of code : static void Main(string[] args) { int x = 8; int b = 16; int C = 64; x /= b /= C; Console.WriteLine(x + " " + b+ " " +C); Console.ReadLine(); }

Correct Answer is : 16

15. Select the relevant output for the following set of code: static void Main(string[] args) { int a = 4; int b = 5; int c = 6; int d = 8; if (((a * b / c) + d) >= ((b * c + d ) / a)) { Console.WriteLine("Line 1 - a is greater to b"); Console.WriteLine((a * b / c) + d); } else { Console.WriteLine("Line 1 - a is not greater to b"); Console.WriteLine((b * c + d )/ a); } }

Correct Answer is : Method overloading

16. Check for given code whether the given relation operator works according to the if condition or not. static void Main(string[] args) { int a = 10; int b = 5; int c = 12; int e = 8; int d; d = Convert.ToInt32((a * (c - b) / e + (b + c)) <= (e * (c + a) / (b + c) + a)); Console.WriteLine(d); if (d == 1) { Console.WriteLine("C# is great language!"); Console.WriteLine((a * (c - b) / e + (b + c))); } else { Console.WriteLine("harsh is not great language!"); Console.WriteLine((e * (c + a) / (b + c) + a)); } }

Correct Answer is : Both Constructors & Methods

17. Which of the following is/are not Relational operators in C#.NET ?

Correct Answer is : 1000

18. The relevant output for the following set of code is : int n = 2; int p = 4; int q = 5; int w = 3; if ( !((p * q) /n <= (q * w) + n/p )) { Console.WriteLine( ++p + w++ + " " + ++n); Console.WriteLine("b"); } else { Console.WriteLine(--p + q-- + " " + --n); Console.WriteLine("a"); }

Correct Answer is : 7

19. Select the relevant output for the set of code : m = 5; int y; 1. y = m++; 2. y = ++m;

Correct Answer is : 216

20. Predict the output for the following set of code : static void Main(string[] args) { int a = 3, b = 5, c = 1; int z = ++b; int y = ++c; b = Convert.ToInt32((Convert.ToBoolean(z)) && (Convert.ToBoolean(y)) || Convert.ToBoolean(Convert.ToInt32(!(++a == b)))); a = Convert.ToInt32(Convert.ToBoolean(c) || Convert.ToBoolean(a--)); Console.WriteLine(++a); Console.WriteLine(++b); Console.WriteLine(c); }

Correct Answer is : 45511

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon