C# Interview Questions - 27 | Snaprecruit.com

C# Interview Questions - 27 | Snaprecruit.com

C SHARP interview questions part 27

C SHARP interview questions part 27

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

Total Questions: 20

1. Which of the following is the correct output for the C#.NET program code given below? { struct abc { public int i; } class Program { static void Main(string[] args) { sample a = new sample(); a.i = 10; fun(ref a); Console.WriteLine(a.i); } public static voidn fun(ref sample x) { x.i = 20; Console.WriteLine(x.i); } }}

Correct Answer is : getBytes()

2. Which of the following is the correct result for the given statement in the C#.NET statement given below? p = q struct employee{ private int employee id; private string city;}employee q = new employee();employee p;p = q;

Correct Answer is : TocharArray()

3. Which of the following will be the correct output for the program given below? { struct abc { int i; } class Program { static void Main(string[] args) { abc x = new abc(); abc z; x.i = 10; z = x; z.i = 15; console.Writeline(x.i + " " + y.i) } } }

Correct Answer is : xyz

4. Select the output for the following set of code. static void Main(string[] args) { int movie = 1; switch (movie << 2 + movie) { default: Console.WriteLine("3 Idiots"); break; case 4: Console.WriteLine("Ghazini"); break; case 5: Console.WriteLine("Krishh"); break; case 8: Console.WriteLine("Race"); break; } Console.ReadLine(); }

Correct Answer is : Append()

5. Select the output for the following set of code : static void Main(string[] args) { int i = 2, j = 4; switch (i + j * 2) { case 1 : case 2 : Console.WriteLine("1 and 2"); break; case 3 to 10: Console.WriteLine("3 to 10"); break; } Console.ReadLine(); }

Correct Answer is : 38785

6. Select the output for the following set of code : static void Main(string[] args) { int i = 2, k = 3; switch (i - k) { case -1: ++i; ++k; break; case 2: --i; ++k; break; default: i += 3; k += i; break; } Console.WriteLine(i + "\n" + k); Console.ReadLine(); }

Correct Answer is : Remove()

7. Select output for the following set of code : static void Main(string[] args) { int const p = 0; switch (3 * 5 / 6) { case p: Console.WriteLine("A"); break; case p * 1: Console.WriteLine("B"); break; case p - 2: Console.WriteLine("C"); break; default: Console.WriteLine("D"); } }

Correct Answer is : h

8. Select output for the following set of code : static void Main(string[] args) { int i = 2, j = 3, k = 4; switch (i + j - k) { case 0: case 2: case 4: ++i; k += j; break; case 1: case 3: case 5 : --i; k -= j; break; default: i += j; break; } Console.WriteLine(i + "\n" + j + "\n" + k); Console.ReadLine(); }

Correct Answer is : On a character by character basis

9. Select the output for the following set of code : static void Main(string[] args) { int i = 9 , j = 7; switch (i - j + 3) { case 9: 7: j += 6; break; case 5: i -= 4; break; } Console.WriteLine(i + "\n" + j); Console.ReadLine(); }

Correct Answer is : 800 40

10. Select the output for the following code : static void Main(string[] args) { switch (5) { case 5.0f: Console.WriteLine("harsh"); break; case 5: Console.WriteLine("amish"); break; case 5.0L: Console.WriteLine("ANKIT"); break; default: Console.WriteLine("ashish"); } Console.ReadLine(); }

Correct Answer is : 43961

11. Select output for the following code: static void Main(string[] args) { int i; int j = 1; int []ar = {21, 22, 13, 4}; switch (ar[j]) { case 1: i++; break; case 2: i += 2; j = 3; continue; case 3: i %= 2; j = 4; continue; default: --i; } Console.WriteLine(i); Console.ReadLine(); }

Correct Answer is : 13, 10, 7

12. Select the output for the following set of Code: static void Main(string[] args) { char ch = Convert.ToChar('a' | 'b' | 'c'); switch (ch) { case 'A': case 'a': Console.WriteLine("case A|case a"); break; case 'B': case 'b': Console.WriteLine("case B|case b"); break; case 'C': case 'c': case 'D': case 'd': Console.WriteLine("case D|case d"); break; } Console.ReadLine(); }

Correct Answer is : void

13. Select the output for the following set of Code: static void Main(string[] args) { char ch = 'p'; switch (ch) { case 'p': Console.WriteLine("coco" + "\t" + Convert.ToInt32(ch)); break; default: Console.WriteLine("default"); break; } Console.WriteLine("main"); }

Correct Answer is : whole structure

14. What is the use of try & catch?

Correct Answer is : float(*ptr)[6].

15. Choose the statement which is incorrect?

Correct Answer is : p[10] :0, p[9] :9, p[8] :8…..p[1]:1

16. What will be the output of the program? class Output { public static void main(String args[]) { try { int a = 10; int b = 5; int c = a / b - 5; Console.WriteLine("Hi"); } catch(Exception e) { Console.WriteLine("hello"); } } }

Correct Answer is : tset a si siht

17. Which of the keywords are used for the block to be examined for exceptions?

Correct Answer is : A True

18. What will be the output of the code snippet? class Output { public static void main(String args[]) { try { int a = 10; int b = 5; int c = b - 5 / 5; Console.WriteLine("Hi"); } catch(Exception e) { Console.WriteLine("hello"); } } }

Correct Answer is : p and p2 point to the same address

19. Which of these keywords are used for generating an exception manually?

Correct Answer is : Result has no value

20. What is the need for ‘Conversion of data type’ in C#?

Correct Answer is : 110

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon