Key Words Flashcards

1
Q

Override

A

When inheriting from a base object, the override explicitly allows the inheritor to create its own implementation of the member.

Without specifying “override”, the child member is said to HIDE the parent member. Both will be accessible, but care will be needed to ensure the correct member is used.

The base class Object has a ToString() method, yet every object in .NET inherits from Object. If you use MyClass.ToString() (with no ToString() method written for MyClass), the base class method is executed. You can create an explicit MyClass.ToString() method, but unless “override” is used, the compiler will generate warnings.

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

Delegate

A

A class / wrapper for a method, which can then be passed to other methods like a parameter.

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

Serializable

A

An object is serializable when it’s able to be converted to a series of bytes and persisted on disk (ie. a file, database record, etc). This is useful when the state of an object needs to be maintained for later use. The process of reading bytes from disk and turning then back into the object is called Deserialization.

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

Abstract

A

Meant only to be used as a base for other classes. Can not be instantiated directly. Can only be invoked by creating a class that inherits from the abstract base.

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

Virtual

A

Anything inheriting from an object containing a virtual member MUST use “override” when overriding that virtual member; hiding is not allowed. The prevents the base class method from being overridden or used.

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

Sealed

A

Prevents other objects from inheriting from the sealed object. An object can not both be sealed and abstract.

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

Yield

A

Used with the Break and Return keywords. Helps maintain a state engine (a loop in which the iterations can be stopped and resumed at a later time. YIELD RETURN X stops the loop and returns the current value. RETURN BREAK stops the loop without returning a value.

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

Protected

A

A protected member is accessible to code inside the class the protected member exists in, and to objects that inherit from it.

If A has a protected int X, and B:A, B.X is accessible from within B, but referencing A.X from within B will generate errors.

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

Lock

A

Limits access to the enclosed code to only one thread at a time.

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

Static

A

Anything declared as static will not have its data or members modified. Also, static objects do not have to be instantiated; they’re created when the application initialized.

For example, Console.WriteLine() can be called without creating a Console object. A consequence of this is that there can only ever be a single instance of that object.

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

Checked

A

Used to encapsulate code in which overflow errors might occur. When a block of code is checked, an exception will be thrown immediately if an overflow occurs.

*int i = int.MaxValue -10;
 checked {      
    i+= 20; // boom: OverflowException
            // "Arithmetic operation resulted in an overflow."
 }*
How well did you know this?
1
Not at all
2
3
4
5
Perfectly