Basic Flashcards

Sample questions for basic c#

1
Q

What a tuple and why are they useful?

A

Tuples are used to store multiple items in a single variable. They are useful for returning multiple results from a function.

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

What is string builder and why is it used?

A

The string builder is a class of .NET to work with strings when repetitive operations are needed. It can improve the performance of code as it is faster than string

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

How can you prevent the silent overflow of integers?

A

It can be achieved via the project settings or by using checked()

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

What is a method body?

A

It contains the instructions that implement the method

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

When does the .NET garbage collector run? What does it do?

A

It is used to free memory space, it runs whenever the heap starts filling up

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

What is method overloading?

A

When multiple methods are created with the same name in same class but they work in different ways (different data types in method returns)

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

What is an Enum and why would you use it?

A

Enum is a special “class” that represents a group of constants. It makes values more readable making it less complex

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

What is casting?

A

When the datatype of a variable is changed.

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

What is an exception?

A

When a error occurs during the runtime.

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

What is meant by a “Strongly Typed Language”?

A

It is in which type of data is predefined as of the programming language and all constants or variables defined for the program must be assigned with one of these datatypes.

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

Why is c# described as memory safe?

A

C# supports static typing meaning that the language enforces type safety at compile time. It prevent a string type being interacted with as though it were an interger type

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

What is .NET?

A

.NET is an open source developer platform, it can build different types of applications and uses multiple languages.

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

What is a conditional breakpoint?

A

They allow you to break inside a code block when a defined expression evaluates to true.

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

In handling exceptions, when is the finally block run?

A

It always executes when try block exits.

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

In a method signature, what does the void keyword mean?

A

The void keyword indicates that this method has no return value

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

What is an out parameter?

A

The out parameter is used to pass arguements to methods by reference

17
Q

What is the difference between an array and a list?

A

Lists are containers for elements having differing data types but arrays are containers for the same data type. New elements can be added to a list

18
Q

What is the difference between a multidimensional array and a jagged array?

A

In a multidimensional array, each element in each dimension has the same size as the other elements in that dimension. In a jagged array, which is an array of arrays, each inner array can be of different size.

19
Q

Which types of operator have the lowest priority?

A

Assignment (=, +=, -=, *=, /=, %=)

20
Q

Which types of operator have the highest priority?

A

Postfix, increment and decrement (++,–)

21
Q

What are method parameters passed by value?

A

Numeric types(integral and floating), char, bool, enum, struct.

22
Q

What are method parameters passed by reference?

A

String, object, dynamic

23
Q

What’s compile time and run time?

A

Compile time is the period when the programming code is converted to machine code. Runtime is the period of time the program is running.

24
Q

Why is representing dates and times complicated?

A

Finding the difference between 2 dates is difficult. Leap year and formatting due different types display dates