OOP Flashcards

1
Q

What is a class?

A

A class is a blueprint that provides a definition of the attributes and methods of an object.

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

What is an object?

A

An object is something that we want to represent in our computer system and we model as a class. Examples of objects are students, dogs, invoices and trains.

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

What is encapsulation?

A

It is a form of data hiding. Data and functions are combined into a single unit (a class). The attributes of the class are kept private and public ‘getter’ and ‘setter’ methods are provided to manipulate these attributes.

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

What is polymorphism?

A

Two or methods with the same name but different implementations. Each object in oop owns its own behaviours. If you call a method on an object, it knows how to behave. Thus a triangle object when asked to draw itself, will draw a 3 sided object and a square will draw something with 4 equal length sides.

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

What is instantiation?

A

The process of making a instance of an object and assigning it to a reference variable.

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

What is a constructor?

A

It is a special method that is called implicitly or explicitly when a class is instantiated. It is used to provide initial values for the attributes - either default values or those passed in as parameters.

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

What is a reference variable?

A

A pointer to a memory location where an instance is stored.

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

What is inheritance?

A

This is where a class is derived from a super class (parent class). The derived class (child/sub class), inherits all of the properties (attributes and methods) of the parent class.

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

What is aggregation?

A

A form of association that defines a “has a” relationship. However, the two objects can exist separately so, if one is destroyed, the other can continue to exist. The reference to the owned object exists outside of the container.

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

What is composition?

A

A form of association that defines a “has a” relationship. The two objects cannot exist separately so, if one is destroyed, the other is also destroyed. The reference to the owned object exists only within the container. (it is usually instantiated by the owning objects constructor.

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

In a UML diagram, what are the access specifiers for public, private and protected?

A

+ public - private # protected

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

What is the difference between a private attribute and a protected attribute.

A

A private attribute can be accessed only by class methods. A protected attribute can also be accessed by derived (inherited) methods.

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

What type of relationship is shown in this UML diagram?

A

Inheritance

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

What type of relationship is shown in this UML diagram?

A

Composition

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

What type of relationship is shown in the UML diagram?

A

Aggregation

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