0% found this document useful (0 votes)
66 views

C# Screening Questions

This document contains a C# coding assessment with 15 multiple choice questions testing various C# concepts like methods, variables, operators, conditionals, loops, arrays, objects, and exceptions. The questions provide code snippets with missing parts for the test taker to fill in to demonstrate their C# language proficiency.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

C# Screening Questions

This document contains a C# coding assessment with 15 multiple choice questions testing various C# concepts like methods, variables, operators, conditionals, loops, arrays, objects, and exceptions. The questions provide code snippets with missing parts for the test taker to fill in to demonstrate their C# language proficiency.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

C# Screening Questions

Instructions: Fill in the answers in the spaces provided.


Questions: 15
Time: 10 minutes

1. Insert the missing part of the code below to output "Hello World!".

static void Answer Here(string[] args)


{
Answer Here.Answer Here ("Hello World!");
}

2. Comments in C# are written with special characters. Insert the missing


parts:

Answer HereThis is a single-line comment


Answer HereThis is a multi-line comment Answer Here

3. Create a variable named myNum and assign the value 50 to it.

Answer Here Answer Here= Answer Here;

4. Add the correct data type for the following variables:

Answer Here myNum = 9;


Answer Here myDoubleNum = 8.99;
Answer Here myLetter = 'A';
Answer Here myBoolean = false;
Answer Here myText = "Hello World";

5. Use the correct operator to increase the value of the variable x by 1.


int x = 10;
xAnswer Here;

6. Use the addition assignment operator to add the value 5 to the variable
x.

int x = 10;
x Answer Here 5;

7. Use the correct operator to concatenate two strings:

string firstName = "John ";


string lastName = "Doe";
string name = firstName Answer Here lastName;

8. Use substitution to join the firstName and lastName strings into fullName

string firstName = "John";


string lastName = "Doe";
string fullName = Answer Here"My full name is:Answer Here Answer

Here";

9. Complete the syntax to execute if x is equal to y.

int x = 50;
int y = 50;
Answer Here(x Answer Here y)
{
code to execute…;
}
10. Insert the missing parts to complete the following switch statement.

int day = 2;
switch (Answer Here)

{
Answer Here 1:
code to execute…;
break;
Answer Here 2:
code to execute…;
Answer Here;

11. Complete the syntax to execute as long as i is less than 6.

int i = 1;
Answer Here(i Answer Here 6)
{
code to execute…;
Answer Here;

}
12. Complete the syntax to execute as long as i is less than 10.

int i = 1;
Answer Here
{
Console.WriteLine(i);
Answer Here;

}
Answer Here(i Answer Here 10);

13. Create an array of type string called cars.

Answer Here Answer Here = {"Volvo", "BMW", "Ford"};

14. Create an object of MyClass called myObj.

Answer Here Answer Here= Answer Here Answer Here();

15. Fill in the missing parts to output an error message if an error occurs.

Answer Here
{
int[] myNumbers = {1, 2, 3};
code to execute…(myNumbers[10]);
}
Answer Here(Exception e)
{
code to output error…(e.Message);
}

You might also like