wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C# Programming Quiz

Total questions: 25

Worksheet time: 25mins

Name
Class
Date
1.

The command to compile a C# program is (a)   .

2.

The starting point of every C# program is the (a)   method.

3.

A C# source code file ends with the extension (a)   .

4.

To read input from the user, we use Console. (a)   ().

5.

To print text with a new line, we use Console. (a)   ().

6.

Every variable in C# must have a data type.

a)

True

b)

False

7.

The operator ! means NOT in C#.

a)

True

b)

False

8.

int is used for decimal numbers.

a)

True

b)

False

9.

The for loop repeats a block of code a set number of times.

a)

True

b)

False

10.

The try-catch statement is used to handle exceptions.

a)

True

b)

False

11.

Which is NOT included in the .NET SDK?

a)

C# Compiler

b)

.NET CLI

c)

Visual Studio

12.

Which of the following is NOT a C# data type?

a)

int

b)

bool

c)

text

13.

Which operator checks if two values are equal?

a)

=

b)

==

c)

!=

14.

Which loop guarantees at least one execution of its body?

a)

for

b)

while

c)

do-while

15.

Which statement is best for multiple-choice branching?

a)

if

b)

switch

c)

try

16.

Which keyword is used to declare a constant?

a)

var

b)

const

c)

static

17.

Which jump statement ends the current loop immediately?

a)

continue

b)

break

c)

return

18.

Which jump statement skips the current loop cycle?

a)

break

b)

continue

c)

exit

19.

Which part of exception handling always runs, even if there is no error?

a)

throw

b)

catch

c)

finally

20.

Which keyword lets the compiler decide the type automatically?

a)

auto

b)

var

c)

let

21.

What will this print? int number = 5; Console.WriteLine(number);

a)

5

b)

number

c)

Error

22.

What is the result? Console.WriteLine(10 / 2);

a)

2

b)

5

c)

10/2

23.

What is the output? int a = 5, b = 10; Console.WriteLine(a > b ? "Yes" : "No");

a)

Yes

b)

No

24.

Which converts a string to an integer?

a)

int.Parse()

b)

Convert.ToInt32()

c)

Both

25.

What will this program print? string[] fruits = { "Apple", "Banana" }; foreach (string f in fruits) { Console.WriteLine(f); }

a)

Apple

b)

Banana

c)

Apple Banana