wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Loops, enums,arrays,conditional statements, variables

Total questions: 30

Worksheet time: 16mins

Name
Class
Date
1.

What is a 'static variable' in C#?

a)

A variable that is defined without reference to any object instance

b)

A variable that is declared globally

c)

A variable that can only be accessed within a specific method

d)

A variable that changes its value dynamically

2.

What is the purpose of using methods in C#?

a)

To increase the complexity of the program

b)

To slow down the execution of the program

c)

To confuse the code structure

d)

To reuse code and perform certain actions

3.

What does the C in C# stand for?

a)

Complex

b)

Cool

c)

Coffee

d)

Caffeine

4.

How is a method defined in C#?

a)

With the name of the method followed by square brackets

b)

With the name of the method followed by curly braces

c)

With the name of the method followed by parentheses (round brackets)

d)

With the name of the method followed by angle brackets

5.

What does the 'void' keyword indicate in a method declaration?

a)

The method should return an integer

b)

The method should return a string

c)

The method should return a boolean

d)

The method should not return a value

6.

What is the purpose of method overloading in C#?

a)

To confuse the programmer

b)

To reduce the number of methods in a program

c)

To limit the functionality of methods

d)

To have multiple methods with the same name but different parameters

7.

Why is recursion used in programming?

a)

To increase the memory usage of the program

b)

To solve problems that can be broken down into smaller, similar subproblems

c)

To make the program run faster

d)

To complicate the code structure

8.

Which statement is used to check if a condition is met in a program?

a)

for loop

b)

while loop

c)

if statement

d)

switch statement

9.

In the context of quantum entanglement, which theorem demonstrates the incompatibility between the principles of local realism and the predictions of quantum mechanics?

a)

Noether's Theorem

b)

Bell's Theorem

c)

Heisenberg's Uncertainty Principle

d)

Schrödinger's Equation

10.

What operator is used to check multiple conditions in a single statement?

a)

AND (&&) and OR (||)

b)

NOT (!)

c)

MOD (%)

d)

DIV (/)

11.

In a for loop, what does Statement 1 represent?

a)

It checks the condition for the loop to run.

b)

It executes after the code block in the loop.

c)

It sets a variable before the loop starts.

d)

It breaks out of the loop.

12.

How can you exit a for loop prematurely?

a)

Using the continue statement

b)

Using the return statement

c)

Using the break statement

d)

Using the goto statement

13.

What happens when a C# programmer runs out of coffee?

a)

They switch to tea.

b)

They start coding in Java.

c)

They use caffeine patches.

d)

They begin debugging their life choices.

14.

What is the starting index of an array in C#?

a)

1

b)

0

c)

-1

d)

2

15.

What is a South African’s favorite type of music?

a)
  • Jazz

b)

Rock

c)

Kwaito

d)

The sound of a sizzling braai

16.

Which statement correctly declares a single-dimensional array of integers with 5 elements in C#?

a)

int[5] arr1;

b)

int arr1[5];

c)

int[] arr1 = new int[5];

d)

int arr1 = new int[5];

17.

What will be the output of the following code?
int[] arr = {1, 2, 3, 4, 5};
Console.WriteLine(arr[2]);

a)

1

b)

2

c)

3

d)

4

18.

How does a while loop function?

a)

It executes the statements within the body of the loop as long as the condition is true.

b)

It executes the statements within the body of the loop until the condition is true.

c)

It executes the statements within the body of the loop exactly once.

d)

It executes the statements within the body of the loop for a fixed number of times.

19.

Which loop is preferred when the number of iterations is known beforehand?

a)

while loop

b)

do-while loop

c)

for loop

d)

foreach loop

20.

Which method can be used to iterate through each element of an array in C#?

a)

foreach loop

b)

for loop

c)

while loop

d)

All of the above

21.

What is an enum in C#?

a)

A collection of methods

b)

A set of named constants

c)

A type of array

d)

A reference type

22.

What is the output of the following code if the day chosen is Wednesday?

enum WeekDays

{

Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday

}

static void Main(string[] args)

{

int a = (int)WeekDays.Wednesday;

Console.WriteLine(a);

}

a)

0

b)

1

c)

2

d)

3

23.

Why do C# developers prefer to work in the dark?

a)

To save electricity

b)

Because they are sensitive to light

c)

To keep their code from seeing the light of day

d)

To better see their syntax highlighting

e)

Secretly they are Batman

24.

What is a C# developer's favorite exercise?

a)

For loops

b)

While loops

c)

Do-while loops

d)

Running garbage collection

25.

Why did the C# developer go broke?

a)

They kept throwing exceptions.

b)

They couldn't find a well-paying job.

c)

They spent all their money on new frameworks.

d)

They bought too many cloud storage services.

26.

Why do C# developers love nature walks?

a)

To get inspired by trees (data structures)

b)

To escape the binary world

c)

To find new bugs

d)

To practice branching paths

27.

What’s a C# developer’s favorite musical note?

a)

C#

b)

B flat

c)

F#

d)

G major

28.

Why did the C# developer get stuck in the elevator?

a)

They were caught in a loop.

b)

They forgot to break out.

c)

They were looking for the exit method.

d)

They were debugging the elevator.

29.

What do you call a South African with a braai and no meat?

a)

A vegetarian

b)

An optimist

c)

A desperate chef

d)

A braaibroodjie enthusiast

30.

In quantum field theory, what is the significance of the path integral formulation introduced by Richard Feynman?

a)

It allows the calculation of probabilities by summing over all possible paths a particle can take.

b)

It provides a classical description of particle trajectories in potential fields.

c)

It quantizes the classical fields by imposing commutation relations.

d)

It describes the energy levels of electrons in a hydrogen atom.