WorksheetsC# M1 - M2
Total questions: 22
Worksheet time: 9mins
What is the Console.WriteLine() Function do?
Reads Input
Clears the console
Writes to the console with a newline
writes to a file
Which of the following is the correct way to comment out multiple lines in C#?
//--
/* */
__..__
<!-- -->
What is the extension of a C# language file?
.c
.cpp
.cs
.csp
CLR stands for ___.
Common Type System
Java Virtual Machine
Common Language Specification
Common Language Runtime
Which symbols are used to mark the beginning and end of a code block?
Square brackets []
Curly braces {}
Round brackets ()
Double-quotes ""
Every C# statement is terminated by ___.
Colon (:)
Semicolon (;)
Comma (,)
Dot (.)
C# is a programming language, developed by ___.
Oracle
Microsoft
GNU project
What will be the output of the following C# code snippet? ```csharp int a = 5; if (a == 5) { Console.WriteLine("Equal"); } ```
No output
Equal
Error
Not Equal
In C#, which of the following operators is used to check if two values are not equal?
==
!=
>
<
What will be the output of the following C# code snippet? ```csharp int c = 15; if (c > 10) { Console.WriteLine("Greater"); } else { Console.WriteLine("Not Greater"); } ```
Greater
Not Greater
Error
No output
Which of the following C# statements correctly checks if a variable `d` is less than or equal to 20?
if (d < 20)
if (d <= 20)
if (d == 20)
if (d >= 20)
What will be the output of the following C# code snippet? ```csharp int e = 25; if (e < 20) { Console.WriteLine("Less"); } else if (e == 25) { Console.WriteLine("Equal"); } else { Console.WriteLine("Greater"); } ```
Less
Equal
Greater
Error
In a C# switch statement, which keyword is used to exit a case block?
exit
break
continue
stop
What will be the output of the following C# code snippet? ```csharp int f = 3; switch (f) { case 1: Console.WriteLine("One"); break; case 2: Console.WriteLine("Two"); break; case 3: Console.WriteLine("Three"); break; default: Console.WriteLine("Other"); break; } ```
One
Two
Three
Other
Which of the following C# statements correctly checks if a variable `g` is greater than or equal to 50?
if (g > 50)
if (g >= 50)
if (g == 50)
if (g <= 50)
What will be the output of the following C# code snippet? ```csharp int h = 7; if (h > 10) { Console.WriteLine("Greater"); } else if (h < 5) { Console.WriteLine("Less"); } else { Console.WriteLine("Between"); } ```
Greater
Less
Between
Error
In C#, which of the following is the correct syntax for an if-else statement?
if (condition) { } else { }
if (condition) else { }
if (condition) { } else
if (condition) { } else if { }
What will be the output of the following C# code snippet? ```csharp int k = 5; if (k == 5) { Console.WriteLine("Five"); } else { Console.WriteLine("Not Five"); } ```
Five
Not Five
Error
No output
In a C# switch statement, what will happen if there is no `break` statement in a case block?
The program will stop
The next case block will execute
The default case will execute
An error will occur
What will be the output of the following C# code snippet? ```csharp int l = 20; if (l != 20) { Console.WriteLine("Not Equal"); } else { Console.WriteLine("Equal"); } ```
Not Equal
Equal
Error
No output
What is the correct way to declare an integer variable in C#?
`int number = "100";`
`integer number = 100;`
`int number = 100;`
`Int32 number = 100;`
Which of the following is the correct way to output "Hello, World!" to the console in C#?
`Console.WriteLine("Hello, World!");`
`Console.ReadLine("Hello, World!");`
`Console.Print("Hello, World!");`
`Console.WriteText("Hello, World!");`
