Object Oriented Programming Flashcards

1
Q

The structure

A

Can store different types of data.

Cannot define a function within a structure, only reference them.

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

Object

A

Instance of a class ( one knight in particular)

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

Class

A

Template for objects

Only define / initialize variables / functions that are general to all instances of that class.

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

Four main principles of object oriented programming

A

Encapsulation
Abstraction
Inheritance
Polymorphism

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

Encapsulation

A

Bundling data and methods that can operate on that data within a class. Nothing outside the class can interact w/ data within it.

Must interact through its methods

Generally, best to not allow external classes to directly edit an object’s attributes

In complex projects good to not rely on every piece of the project or let pieces become entangled.

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

Getting Methods

A

Retrieving information

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

Setting Methods

A

Changing information

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

Information hiding

A

Keeping data of one class hidden from external classes.

Helps control the program and prevent it Frome becoming too complex.

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

Abstraction

A

Only showing essential details, hiding everything else.

I.e. understanding the outcome, but not the full process ( driving a car vs. building a car).

If one class is changed, do not need to change everything that interacts with it.

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

Interface

A

Way sections of code can communicate with one another

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

Implementation

A

How methods are coded (hidden)

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

Inheritance

A

Principle that allows classes to derive from other classes.

Ex. Weapons class | sword class vs. club class

Superclass to sub classes

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

Access modifiers

A

Changes which classes have access to other classes, methods, or attributes.

Three main access modifiers
Public
Private
Protected

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

Inheritance - Public

A

Can be accessed from anywhere, superclass, subclasses or other parts of the program.

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

Inheritance - Private

A

Only be accessed from the same class that the member is defined.

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

Inheritance - Protected

A

Can be accessed within the class it is defined, as well as any subclasses of that class.

17
Q

Polymorphism

A

Methods that are able to take on many forms.

Two types: dynamic polymorphism, and Static polymorphism

18
Q

dynamic polymorphism

A

Occurs during runtime of program

Methods share name but different implementation.

Changes based on where it is in class hierarchy.

19
Q

Static polymorphism

A

Occurs during compile-time.

Multiple methods with the same name but different arguments are defined in the same class. Has different number and type of parameters.