wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C# Quizz - LC Year 9

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.
What is the difference between Console.Write and Console.WriteLine?
a)
Console.WriteLine moves to the next line.
b)
Console.Write moves to the next line.
c)
Both move to the next line.
d)
Console.WriteLine keeps on the same line.
e)
None
2.
What is the correct format to name a variable in camel case?
a)
MyVariable
b)
myVariable
c)
My_variable
d)
my_variable
e)
None
3.
Which of the following is true when using var to initialize variables?
a)
var requires a specific type like int, string.
b)
var is used when the type is unknown.
c)
var cannot store strings.
d)
var can store multiple types of values.
e)
None
4.
What will be the output of the following code? Console.WriteLine("Hello\tWorld\n!");
a)

Hello World

!

b)
Hello World
c)
Hello World !
d)
Hello World
e)
None
5.
Which of the following methods allows you to concatenate strings in Console.WriteLine?
a)
+ (plus sign)
b)
$ (dollar sign)
c)
& (ampersand)
d)
@ (verbatim symbol)
e)
None
6.
What will be the output of this code: Console.WriteLine(3 + 2 * 5);
a)
13
b)
25
c)
10
d)
15
e)
None
7.
How do you check if a number is positive or negative using if/else in C#?
a)
if(number > 0)
b)
if(number < 0)
c)
if(number = 0)
d)
if(number >= 0)
e)
None
8.
What will happen if this condition is false? if (x > 10)
a)
The code in the if block is executed.
b)
The code in the else block is executed.
c)
The program stops.
d)
The program crashes.
e)
None
9.
What does the following code do? int[] grades = {90, 85, 78, 88}; for(int i = 0; i < grades.Length; i++) { Console.WriteLine(grades[i]); }
a)
Prints all grades stored in the array.
b)
Prints only the first grade.
c)
Crashes the program.
d)
Prints the last grade only.
e)
None
10.
What is the output of this code: int[] numbers = {1, 2, 3}; Console.WriteLine(numbers.Length);
a)
1
b)
2
c)
3
d)
None