OOP Flashcards

1
Q

what is meant by overriding?

A

When a derived class / subclass has a different implementation for a method / function / subroutine to the class it inherits from / from the base class;

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

what is meant by polymorphism?

A

A method shared (up and down the inheritance hierarchy chain) but with each class / method implementing it differently

//

A single interface is provided to entities/objects of different classes / types

//

Objects of different classes / types respond differently to the use of a common interface / the same usage

//

Allowing different classes to be used with the same interface

//

The ability to process objects differently depending on their class / type;

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

A protected attribute

A

protected attributes can also be accessed by any classes that inherit from the class they belong to;

Protected means it can be accessed / seen in the class it is in and in any subclasses // protected means it can be accessed / seen in the class it is in and in any classes derived / inheriting from it;

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

A private attribute

A

Private attributes can only be accessed by the class

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

What is meant by aggregation?

A

An object that contains other objects;

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

features of an object

A

Contains its own data/fields/variables/properties;

Contains its own Operations/methods/functions/procedures/behaviours/code;

Responds to messages;

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

What is meant by inheritance?

A

A class has properties/fields/attributes/characteristics and methods/procedures/functions of the parent class it is derived from
//
a subclass/derived class inherits all the properties/fields/attributes/characteristics and methods/procedures/functions from a super-class/base-class/parent class;

From an older paper:

Relationship among classes wherein one class shares the data structure and behaviour/methods / procedures / functions / actions of another class

OR when a class has the same characteristics as its parent class

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

State advantages of the object-oriented approach to program design over the structured approach to program design.

A

Produces re-useable code because of inheritance/encapsulation;

Produces re-useable objects;

Data is protected // only accessible in well-defined ways (because of encapsulation);

More efficient to write programs which use pre-defined / inherited objects / classes;

Storage structure of data and method code of a class may be altered without affecting programs that make use of the class;

Code produced contains fewer errors / more reliable;

Solutions are easier to understand (when expressed in terms of objects);

Easier to enforce design consistency; easier to debug;

Less maintenance effort required by developer since objects can be re-used;

New functions can be added to objects easily (because of inheritance);

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

What is meant by class?

A

A class

A grouping of data structures and behaviours / methods / procedures / functions; A set of objects / object type which share a common data structure and common behaviour / methods / procedures / functions;

Need both structure and behaviour

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

virtual method

A

Virtual methods can be overridden by the derived class //

virtual methods do not have to be overridden //

Virtual methods have an implementation/body //

virtual methods contain code (with functionality) (in the base class) //

virtual methods can be declared in abstract and non-abstract classes;

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

abstract method

A

abstract methods must be overridden by the derived class;

abstract methods do not contain an implementation/body //

abstract methods contain no code (with functionality) (in the base class) //

abstract methods only contain a declaration (in the base class);

Abstract methods can only be declared in abstract classes

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

A public attribute

A

Public means it can be accessed / seen outside of the class it is in;

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

Information hiding

A

[textbook] This principle of information hiding, where other classes cannot directly access the attributes of another class when they are declared private.

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