Font size
WorksheetsLoops, enums,arrays,conditional statements, variables
Total questions: 30
Worksheet time: 16mins
What is a 'static variable' in C#?
A variable that is defined without reference to any object instance
A variable that is declared globally
A variable that can only be accessed within a specific method
A variable that changes its value dynamically
What is the purpose of using methods in C#?
To increase the complexity of the program
To slow down the execution of the program
To confuse the code structure
To reuse code and perform certain actions
What does the C in C# stand for?
Complex
Cool
Coffee
Caffeine
How is a method defined in C#?
With the name of the method followed by square brackets
With the name of the method followed by curly braces
With the name of the method followed by parentheses (round brackets)
With the name of the method followed by angle brackets
What does the 'void' keyword indicate in a method declaration?
The method should return an integer
The method should return a string
The method should return a boolean
The method should not return a value
What is the purpose of method overloading in C#?
To confuse the programmer
To reduce the number of methods in a program
To limit the functionality of methods
To have multiple methods with the same name but different parameters
Why is recursion used in programming?
To increase the memory usage of the program
To solve problems that can be broken down into smaller, similar subproblems
To make the program run faster
To complicate the code structure
Which statement is used to check if a condition is met in a program?
for loop
while loop
if statement
switch statement
In the context of quantum entanglement, which theorem demonstrates the incompatibility between the principles of local realism and the predictions of quantum mechanics?
Noether's Theorem
Bell's Theorem
Heisenberg's Uncertainty Principle
Schrödinger's Equation
What operator is used to check multiple conditions in a single statement?
AND (&&) and OR (||)
NOT (!)
MOD (%)
DIV (/)
In a for loop, what does Statement 1 represent?
It checks the condition for the loop to run.
It executes after the code block in the loop.
It sets a variable before the loop starts.
It breaks out of the loop.
How can you exit a for loop prematurely?
Using the continue statement
Using the return statement
Using the break statement
Using the goto statement
What happens when a C# programmer runs out of coffee?
They switch to tea.
They start coding in Java.
They use caffeine patches.
They begin debugging their life choices.
What is the starting index of an array in C#?
1
0
-1
2
What is a South African’s favorite type of music?
Jazz
Rock
Kwaito
The sound of a sizzling braai
Which statement correctly declares a single-dimensional array of integers with 5 elements in C#?
int[5] arr1;
int arr1[5];
int[] arr1 = new int[5];
int arr1 = new int[5];
What will be the output of the following code?
int[] arr = {1, 2, 3, 4, 5};
Console.WriteLine(arr[2]);
1
2
3
4
How does a while loop function?
It executes the statements within the body of the loop as long as the condition is true.
It executes the statements within the body of the loop until the condition is true.
It executes the statements within the body of the loop exactly once.
It executes the statements within the body of the loop for a fixed number of times.
Which loop is preferred when the number of iterations is known beforehand?
while loop
do-while loop
for loop
foreach loop
Which method can be used to iterate through each element of an array in C#?
foreach loop
for loop
while loop
All of the above
What is an enum in C#?
A collection of methods
A set of named constants
A type of array
A reference type
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);
}
0
1
2
3
Why do C# developers prefer to work in the dark?
To save electricity
Because they are sensitive to light
To keep their code from seeing the light of day
To better see their syntax highlighting
Secretly they are Batman
What is a C# developer's favorite exercise?
For loops
While loops
Do-while loops
Running garbage collection
Why did the C# developer go broke?
They kept throwing exceptions.
They couldn't find a well-paying job.
They spent all their money on new frameworks.
They bought too many cloud storage services.
Why do C# developers love nature walks?
To get inspired by trees (data structures)
To escape the binary world
To find new bugs
To practice branching paths
What’s a C# developer’s favorite musical note?
C#
B flat
F#
G major
Why did the C# developer get stuck in the elevator?
They were caught in a loop.
They forgot to break out.
They were looking for the exit method.
They were debugging the elevator.
What do you call a South African with a braai and no meat?
A vegetarian
An optimist
A desperate chef
A braaibroodjie enthusiast
In quantum field theory, what is the significance of the path integral formulation introduced by Richard Feynman?
It allows the calculation of probabilities by summing over all possible paths a particle can take.
It provides a classical description of particle trajectories in potential fields.
It quantizes the classical fields by imposing commutation relations.
It describes the energy levels of electrons in a hydrogen atom.
