04 - Features of OOP Flashcards

1
Q

What is the definition of encapsulation?

A

Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods.

Encapsulation is also referred to as data hiding.

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

What are the advantages of encapsulation?

A

The main benefits of encapsulation include:
1) Maintainability
2) Flexibility
3) Extensibility

Encapsulation allows modification of code without breaking other code that uses it.

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

Define the term inheritance in OOP.

A

Inheritance is the process by which one object acquires the properties (states and behaviours) of another.

Commonly used keywords are ‘extends’ and ‘implements’.

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

What are the advantages of inheritance?

A

The advantages of inheritance include:
1) Minimizing duplicate code
2) Better organization of code
3) Flexibility to change
4) Reusability of code

Inheritance allows subclasses to inherit fields and methods from a superclass.

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

What is polymorphism?

A

Polymorphism is the ability to treat an object of any subclass of a base class as if it were an object of the base class.

It allows subclasses to define their own unique behaviours while sharing functionality with the parent class.

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

What are the advantages of polymorphism?

A

Advantages of polymorphism include:
1) Ability to ignore type-specific details
2) Code can treat different subclasses uniformly
3) Easier code maintenance and readability

Polymorphism enhances extensibility by allowing new subclasses to be added.

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

What is the biggest advantage of using libraries and objects?

A

The biggest advantage is time saving, as algorithms do not have to be re-invented and processes can be reused.

This leads to increased efficiency in development.

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

What are the disadvantages of OOP?

A

Disadvantages include:
1) Slower performance compared to other programming paradigms
2) Higher memory usage
3) More complex planning and design required

Object-oriented programs are often larger and require more resources.

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

What are the advantages of modularity in program development?

A

Advantages of modularity include:
1) Easier debugging and testing
2) Speedier completion of projects
3) Reusable code blocks

Modularity enhances code organization and manageability.

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

What does it mean for methods to be overridden in OOP?

A

In Object-Oriented Programming (OOP), method overriding happens when a subclass (a more specific version of a class) changes how a method (a function) works that was already defined in its superclass (the general version of the class).

This enables dynamic method resolution at runtime.

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

What is meant by ‘data hiding’ in OOP?

A

Data hiding refers to the practice of restricting access to certain components of an object to protect its integrity.

It is achieved through encapsulation.

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