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

C# Test 2

The document summarizes the results of a C# test taken by the user. They answered 11 out of 20 questions correctly in 13 minutes and 41 seconds. It indicates they still need more practice to become an expert. It then lists 13 multiple choice questions from the test, showing the correct answer to each one.
Copyright
© © All Rights Reserved
0% found this document useful (0 votes)
564 views

C# Test 2

The document summarizes the results of a C# test taken by the user. They answered 11 out of 20 questions correctly in 13 minutes and 41 seconds. It indicates they still need more practice to become an expert. It then lists 13 multiple choice questions from the test, showing the correct answer to each one.
Copyright
© © All Rights Reserved
You are on page 1/ 7

7/16/2021 C# Test 2

C# Test 2

Good try! You gave 11 correct answers out of 20 questions in 13:41 minutes.

You still need to work hard to become an expert.

Check Your Answers


 Try Again
More C# Tests

Question 1: What will be the output of the following program?

public static void Main()

int i;

Console.WriteLine(i);

A Random value

B 0

C Runtime error 

D Compile-time error 

Question 2: What will be the output of the following code?

int i = 5, j;

Console.WriteLine(j=i*2);

A 0

B 10 

C Runtime error

D Compile-time error

Question 3: What will be the output of the following program?

public static void Main()

int k;

display(k);

static void display(int val = 0)

Console.Write(val);

A null

B 0 

C Compile-time error 

https://www.tutorialsteacher.com/online-test/csharp-test2 1/7
7/16/2021 C# Test 2

D Runtime error

Question 4: Which of the following keyword is used to declare a variable whose type will be
automatically determined by the compiler?

A dynamic

B var 

C this

D null

Question 5: Which of the following data types can include maximum positive or negative,
integer or float value?

A double 

B long

C decimal

D BigInteger 

Question 6: What will be the output of the following program?

public static void Main(string[] args)

int a = 1, b = 2, c = 3;

Console.Write ((a*b)+(b*c));

Console.Write ((a*b)+(b*c)-c);

A 8, 5 

B 9, 5

C 7,5

D 9,6

Question 7: Which of the following is the default access modifier in a namespace?

A Public

B Private 

C Internal 

D Protected

https://www.tutorialsteacher.com/online-test/csharp-test2 2/7
7/16/2021 C# Test 2

Question 8: A constructor in a class can have a return type.

A True

B False 

Question 9: What will be the output of the following program?

public static void Main(string[] args)

string str1, str2;

str1 = "C#";

str2 = "C#";

Console.Write(Object.ReferenceEquals(str1, str2));

A True 

B False 

C Compile-time error

D Runtime error

Question 10: What will be the output of the following code?

var greet = "Hello ";

var name = "Steve";

Console.WriteLine($"{greet} {name}");

A Hello {name}

B Hello Steve 

C {Hello} {Steve}

D Compile-time error

Question 11: What will be the output of the following program?

int i = 0;

for(;;)

if (i < 5)

Console.Write(i);

else

break;

i++;

https://www.tutorialsteacher.com/online-test/csharp-test2 3/7
7/16/2021 C# Test 2

A 01234 

B 12345

C Infinite loop

D Compile-time error

Question 12: The members of the enum are always public, and no access modifiers can be
applied.

A True 

B False

Question 13: Which of the following is a correct way to initialize an array?

A int[] arr = new int[5]; 

B int[] arr = new int[]{1, 2, 3, 4, 5}; 

C var arr = new int[5]{1, 2, 3, 4, 5}; 

D int[] arr = int[]{1, 2, 3, 4, 5}; 

E int[] arr = {1, 2, 3, 4, 5}; 

F var arr = {1, 2, 3, 4, 5};

Question 14: Which of the following statement(s) are TRUE?

A Array is a value type.

B Array is a reference type. 

C Array is a primitive type.

D None of the above.

Question 15: What will be the output of the following code?

SortedList sortedList = new SortedList()

{2, true},

{1,"one"},

};
foreach(DictionaryEntry kvp in sortedList )

Console.Write(kvp.Value);

https://www.tutorialsteacher.com/online-test/csharp-test2 4/7
7/16/2021 C# Test 2

A Compile-time error

B Runtime error

C 12 

D OneTrue 

Question 16: What will be the output of the following program?

public static void Main()

int val = GetVal();

public static int GetVal(){

int[] arr = {1, 2, 3, 4, 5};

try

return arr[10];

catch(Exception ex){

Console.WriteLine("Error occurred!");

finally{

return 0;

A Error occurred! 

B Compile-time error 

C No output

D Program terminates unexpectedly

Question 17: What will be the output of the following program?

public static void Main()

int[] arr = {1, 2, 3, 4, 5};

try{

Console.Write(arr[10]);

finally{

Console.WriteLine("Error occurred!");

A Compile-timer error

B Error occurred!

C Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds 


of
the array.

D No output and program terminates

https://www.tutorialsteacher.com/online-test/csharp-test2 5/7
7/16/2021 C# Test 2

Question 18: Which of the following statements are TRUE?

A Delegate is a reference type. 

B Delegate is a value type.

C Delegate defines the method signature. 

D Delegate is pointer type.

Question 19: Which of the following is the built-in delegate function for handling events in
.NET?

A public delegate void Action();

B public delegate void Predicate(object sender);

C public delegate void EventHandler(object sender, EventArgs e); 

D None of the above.

Question 20: Events can also be declared static, virtual, sealed, and abstract.

A True 

B False 

TUTORIALSTEACHER.COM TUTORIALS

TutorialsTeacher.com is optimized for learning  ASP.NET Core  AngularJS 1

web technologies step by step.


Examples might
 ASP.NET MVC  Node.js
be simplified to improve reading and basic
understanding.
While using this site, you agree  IoC  D3.js

to have read and accepted our terms


of use
 Web API  JavaScript
and privacy policy.
 C#  jQuery

 LINQ  Sass
[email protected]

 Entity Framework  Https

E-MAIL LIST

Subscribe to TutorialsTeacher email list and get latest updates, tips &
tricks on C#, .Net, JavaScript, jQuery, AngularJS,

Node.js to your inbox.

Email address
https://www.tutorialsteacher.com/online-test/csharp-test2 6/7
7/16/2021 C# Test 2

GO

We respect your privacy.

HOME
PRIVACY POLICY
TERMS OF USE
ADVERTISE WITH US  2020 TutorialsTeacher.com. All Rights Reserved.

https://www.tutorialsteacher.com/online-test/csharp-test2 7/7

You might also like