MCQ Flashcards

1
Q

Which method of the List class is used to add an element to the end of the list?

A

The Add() method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you create a list in C#?

A

List<datatype> listname = new List<datatype> () ;</datatype></datatype>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the default value of a boolean in C#?

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which keyword is used to define a method that must be overridden?

A

abstract

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What access modifier must abstract methods have?

A

public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A method can only be abstract if?

A

Its class is abstract too

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When overriding a method what keyword must you use?

A

override

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What access modify must overridden functions have?

A

public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you write nullable datatypes in C#?

A

datatype? varname;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which LINQ method is used to sort a collection in ascending order?

A

Order by

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of the finally block in exception handling?

A

To execute code regardless of whether an exception is thrown or not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the return type of a constructor in C#?

A

Constructors have no return types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you declare a multi-dimensional array in C#?

A

dataype [,] arrName = new datatype[rows, columns]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the yield keyword do in C#?

A

Pauses code execution to return a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of the using statement in C#?

A

Define a block with a scope for resource cleanup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you declare a read-only property in a C# class?

A

By creating only a getter for that property without a setter.

16
Q

How do you define a data dictionary in c?

A

Dictionary<int, string> employees = new Dictionary<int, string>();