C# Programming Interview Questions for Freshers

Check out 15 C# programming questions every beginner should prepare before appearing in an interview for the C# developer position. It could help you clear the first round which is a written test held to assess your programming ability.

So if you are going for such interviews with top IT MNCs like Amazon, Flipkart, Oracle, Siemens, and Ericsson, then you should aim for solving these kinds of questions.

In this post, we’ve targetted a specific set of quick coding problems that can make you brush up your C# skills.

We hope to see you getting success in your forthcoming interviews.

In case you have any query, then please use the comment box to let us know.

Solve Quick C# Coding Problems.

Apart from the C# programming questions, you can also read the below post to get through the second round of the interview. In this level, interviewer puts up theoretical questions and expects a decisive answer from you.

Q-6. Which of the following code snippets correctly differentiate between Odd and Even number?A.

Java

1

2

3

4

5

6

intnum;

Stringout;

if(num%2==0)

out="Even";

else

out="Odd";

B.

Java

1

2

3

4

5

6

intnum;

Stringout;

if(num Mod2==0)

out="Even";

else

out="Odd";

C.

Java

1

2

intnum;

Console.WriteLine(num Mod2==0?"Even":"Odd");

D.

Java

1

2

3

4

intnum;

Stringout;

num%2==0?out="Even":out="Odd";

Console.WriteLine(out);

Output:A. 1, 3B. 1 OnlyC. 2, 3D. 4 OnlyE. All are correct

Check correct option.

Answer. B

Q-7. Which of the following statements can be used to terminate a while loop and transfer control outside the loop?

1. exit while2. continue3. exit statement4. break5. goto

Output:A. 1, 3B. 2, 4C. 3, 5D. 4, 5E. All of the above

Check correct option.

Answer. D

Q-8. Which of the following statements are correct for the below code snippet?

Java

1

2

if(age>18&&no<11)

a=25;

1. The condition no < 11 will be evaluated only if age > 18 evaluates to True.2. The statement a = 25 will get executed if any one condition is True.3. The condition no < 11 will be evaluated only if age > 18 evaluates to False.4. The statement a = 25 will get executed if both the conditions are True.5. && is known as a short-circuiting logical operator.

Output:A. 1, 3B. 2, 5C. 1, 4, 5D. 3, 4, 5E. All options are correct

Check correct option.

Answer. C

Q-9. What will be the output of the following code snippet?

Java

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

using System;

namespaceProgrammingExercise

{

classFindOutput

{

staticvoidMain(string[]args)

{

inta=2,b=a;

if(Convert.ToBoolean((a|b&5)&(b-25*1)))

Console.WriteLine(1);

else

Console.WriteLine(0);

}

}

}

Output:A. 0B. 1C. Compile ErrorD. Runtime Error

Check correct option.

Answer. A

Q-10. Which of the following statements are correct for the given code snippet?

Java

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

using System;

namespaceProgrammingExercise

{

classFindOutput

{

staticvoidMain(string[]args)

{

intid;

Stringval;

switch(id)

{

case5:

val="First";

break;

case6:

val="Second";

break;

case1:

val="Third";

break;

casels<4:

val="Fourth";

break;

caseElse:

val="Fifth";

break;

}

}

}

}

Output:A. The compiler will report an error in case “ls<4” as well as in case “Else”.B. There is no error in the code.C. The compiler will report an error in case “Else”.D. The compiler will report an error as there is no default case.E. The order of the first three cases should be case 1, 5, and 6 (ascending order).

Check correct option.

Answer. A

Q-11. What will be the output of the following code snippet?

Java

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

using System;

namespaceProgrammingExercise

{

classFindOutput

{

staticvoidMain(string[]args)

{

int[]a=newint[3];

a[1]=10;

Objecto=a;

int[]b=(int[])o;

b[1]=100;

Console.WriteLine(a[1]);

((int[])o)[1]=1000;

Console.WriteLine(a[1]);

}

}

}

Output:A. 1000B. 100C. 100
1000D. Error

Check correct option.

Answer. C

Q-12. What will be the output of the following code snippet?

Java

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

using System;

namespaceProgrammingExercise

{

classFindOutput

{

staticvoidMain(string[]args)

{

Stringa="TechBeamers";

Stringb="TECHBEAMERS";

intval;

val=b.CompareTo(a);

Console.WriteLine(val);

}

}

}

Output:A. -1B. 1C. 0D. Error

Check correct option.

Answer. B

Q-13. What will be the output of the following code snippet?

Java

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

using System;

namespaceProgrammingExercise

{

classFindOutput

{

staticvoidMain(string[]args)

{

charObj='L';

charNum=Convert.ToChar(76);

Obj--;

Num++;

Console.WriteLine(Obj+" "+Num);

Console.ReadLine();

}

}

}

Output:A. K MB. L MC. K LD. L L

Check correct option.

Answer. A

Q-14. Which of the following statements are correct?

1. The switch statement is a control statement that handles multiple selections and enumerations by passing control to one of the case statements within its body.2. The goto statement passes control to the next iteration of the enclosing loop statements in which it appears.3. We induce Branching using jump statements which cause an immediate transfer of the program control.4. We use the continue statement to transfer the program control, either to the specified switch-case label or to its default case.5. The do statement executes a statement or a block of statements enclosed in “{}” repeatedly until the defined expression evaluates to false.

A. 1, 2, 4B. 1, 3, 5C. 2, 3, 4D. 3, 4, 5E. None of these

Check correct option.

Answer. B

Q-15. Which of the following statements are correct about the given code snippet?

Java

1

2

if(obj>18||num<11)

res=25;

1. The condition num < 11 will get evaluated only if obj > 18 evaluates to False.2. The condition num < 11 will get evaluated if obj > 18 evaluates to True.3. The statement res = 25 will get evaluated if anyone one of the two conditions is True.4. || is known as a short-circuiting logical operator.5. The statement res = 25 will get evaluated only if both the conditions are True.

A. 1, 4, 5B. 2, 4C. 1, 3, 4D. 2, 3, 5E. None of these

Check correct option.

Answer. C

Summary – C# Programming Questions for Beginners.

Hopefully, you would have now got a good exposure to the kinds of C# programming questions asked in interviews.

In our next post, we’ll come up with a new topic that will help you learn more about the C# programming.

If you liked the above questions, then do share this post on your social media accounts.