OOP Flashcards

1
Q

What is an interface?

A

An interface contains definitions for a group of related functionalities that a non-abstract class or a struct must implement.

An interface may define static methods, which must have an implementation.

An interface may define a default implementation for members. An interface may not declare instance data such as fields, auto-implemented properties, or property-like events.

MUST IMPLEMENT ALL METHODS IN INTERFACE.

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

What is an abstract class?

A

Like an interface but can have fields, can have methods implemented (non abstract), access modifiers and is used to be built upon such that the extending classes can use universal methods defined but also implement there own.

1+ METHODS TO IMPLEMENT.

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

What is encapsulation?

A

Hiding the internal workings of a field/class but making them only accessible through public methods. (i.e getters and setters)

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

What is inheritance?

A

Using common features from base class. Achieved through extending classes and using interfaces.

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

What is polymorphism?

A

Checking Object type at runtime to choose which version of a method to run.

In C# use the virtual keyword for methods in the base class and then override keyword in the child class.

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

What is a record?

A

Use a record when:
You want to define a data model that depends on value equality.
You want to define a type for which objects are immutable.

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

What is a struct?

A

DO NOT SUPPORT INHERITANCE BUT CAN IMPLEMENT INTERFACES

Use structs for objects only consisting of value types to create less of a load on the GC.

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

What are the 3 OOP principles?

A

1.Inheritance
2.Encapsulation
3.Polymorphism

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