MCQ Flashcards
Which method of the List class is used to add an element to the end of the list?
The Add() method
How do you create a list in C#?
List<datatype> listname = new List<datatype> () ;</datatype></datatype>
What is the default value of a boolean in C#?
false
Which keyword is used to define a method that must be overridden?
abstract
What access modifier must abstract methods have?
public
A method can only be abstract if?
Its class is abstract too
When overriding a method what keyword must you use?
override
What access modify must overridden functions have?
public
How do you write nullable datatypes in C#?
datatype? varname;
Which LINQ method is used to sort a collection in ascending order?
Order by
What is the purpose of the finally block in exception handling?
To execute code regardless of whether an exception is thrown or not
What is the return type of a constructor in C#?
Constructors have no return types
How do you declare a multi-dimensional array in C#?
dataype [,] arrName = new datatype[rows, columns]
What does the yield keyword do in C#?
Pauses code execution to return a value.
What is the purpose of the using statement in C#?
Define a block with a scope for resource cleanup
How do you declare a read-only property in a C# class?
By creating only a getter for that property without a setter.
How do you define a data dictionary in c?
Dictionary<int, string> employees = new Dictionary<int, string>();