C# Flashcards

1
Q

What is a statically typed language?

A

Static typing is where the type is bound to the variable. Types are checked at compile time. C# and Java are statically typed languages.

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

What is a dynamically typed language?

A

Dynamic typing where the type is bound to the value. Types are checked at run time. PHP and JavaScript are dynamically typed languages.

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

What is a strongly typed language?

A

Strongly typed languages will not allow automatic conversion from one type to another. It does not allow for type coercion. Python is a strongle typed language.

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

What is a weakly typed language?

A

Weakly typed languages do allow for automatic conversion from one type to another. It allows for type coercion. JavaScript is a weakly typed language.

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

What does type safe mean?

A

Type safety is the idea that you can only interact with an object in ways that are allowed by that object. For example, C# prevents you from interacting with a string type as if it were an integer type.

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

What does memory safe mean?

A

Memory safety is a property of programming languages where all memory access is well defined. Most programming languages in use today are memory safe because they use some form of garbage collection.

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

What is a value type?

A

A value type is the actual value. If it is declared within the body of a method then it is placed on the stack. If a value type is declared inside a reference type then is will be placed within the reference type on the heap.

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

What is a reference type?

A

A reference type’s value is stored in the Heap. It is accessed by a pointer. The pointer is stored in the Stack which points to an address in the Heap where the real value is stored.

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

In memory what is the Stack?

A

The Stack keeps track of what’s executing in the code. It is self maintaining and takes care of its own memory management.

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

In memory what is the Heap?

A

The Heap’s purpose is to hold data, so anything in the the Heap can be accessed at any time. The heap contains Reference Type values. It is garbage collected.

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

What is a namespace?

A

A namespace is a way to logically arrange classes, interfaces, structs, etc. into their own named space. It’s used to provide context for the compiler for all named information in the program.

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

What is a using statement?

A

It explicitly tells the compiler that you’ll be using a certain namespace in the program. A developer can avoid having to fully qualify classes with the namespace in every instance of typing it.

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

What is an access modifier?

A

They are keywords that define the accessibility of a member, class or datatype in a program. It can restrict unwanted access by external programs or classes.

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

What is the default access modifier for a class?

A

internal

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

What is the default access modifier for a type member?

A

private

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

What is the internal access modifier?

A

The type of member can only be accessed by code in the same assembly.

17
Q

What is the private access modifier?

A

The type or member can only be accessed by code in the same class or struct.

18
Q

What is the protected access modifier?

A

The type or member can only be accessed by code in the same class, or in a class that is derived from that class.

19
Q

What is the public access modifier?

A

The type or member can be access by any other code in the same assembly or another assembly that references it.

20
Q

What is the protected internal access modifier?

A

The type or member can be accessed by any code in the same assembly or from within a derived class in another assembly.

21
Q

What is the private protected access modifier?

A

The type or member can only be accessed with its declaring assembly by code in the same class or in a type that is derived from that class.

22
Q

What is a statement?

A

Statements are written using C# Keywords and Expressions. They end in a semicolon or curly braces.

23
Q

What is an expression?

A

Expressions are constructed using operators and operands. They usually result in a value.

24
Q

What is the Common Language Runtime (CLR)?

A

The execution engine is called the Common Language Runtime. It consists of the Just-In-Time compiler, Runtime Type Safety, and Garbage Collection

25
Q

What is the .NET Base Class Libraries (BCL)?

A

It is part of the .NET Framework that provides library support to the CLR to work properly.

26
Q

What is Common Intermediate Language (CIL)?

A

C# is compiled into CIL using the Roslyn compiler. The dotnet build command uses MSBuild. MDBuild uses the Roslyn compiler. CIL is the Assembly. This could be a DLL or EXE file.

27
Q

What is Just-In-Time compiler (JIT)?

A

The JIT compiles the CIL into machine code, as needed. The machine code is then executed by the CPU.

28
Q

What are the Integer Types in C#?

A

Integer types are value types.
Signed: sbyte, short, int, long
Unsigned: byte, ushort, uint, ulong

29
Q

What are the Decimal Types in C#?

A

Decimal types are value types.
floating decimal point: float, double
fixed decimal point: decimal

30
Q

What are the other Value Types in C#?

A

enum
char
bool
struct

31
Q

What are the Reference Types in C#?

A

String
Arrays
Class
Delegates

32
Q

What is immutable in C#?

A

Strings are immutable. If changes are made to a string object then the old instance will be discarded and a new instance will be created in to hold the new value.

33
Q

What happens when you pass a value type into a method?

A

A new copy of the variable will be created for the method. If the value is changed in the method, it will not affect the variable value.

34
Q

What happens when you pass a reference type into a method?

A

A new copy will not be created, instead a copy of the address in memory will be passed into the method. Changes to the passed in object will change the original object.

35
Q

What is Boxing in C#?

A

It is used to store value types on the garbage collected heap. It is an implicit conversion of a value type or to any interface type implemented by this value type.

36
Q

What is Unboxing in C#?

A

It is an explicit conversion from the type object to a value type.