04 - Features of OOP Flashcards
What is the definition of encapsulation?
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.
What are the advantages of encapsulation?
The main benefits of encapsulation include:
1) Maintainability
2) Flexibility
3) Extensibility
Encapsulation allows modification of code without breaking other code that uses it.
Define the term inheritance in OOP.
Inheritance is the process by which one object acquires the properties (states and behaviours) of another.
Commonly used keywords are ‘extends’ and ‘implements’.
What are the advantages of inheritance?
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.
What is polymorphism?
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.
What are the advantages of polymorphism?
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.
What is the biggest advantage of using libraries and objects?
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.
What are the disadvantages of OOP?
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.
What are the advantages of modularity in program development?
Advantages of modularity include:
1) Easier debugging and testing
2) Speedier completion of projects
3) Reusable code blocks
Modularity enhances code organization and manageability.
What does it mean for methods to be overridden in OOP?
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.
What is meant by ‘data hiding’ in OOP?
Data hiding refers to the practice of restricting access to certain components of an object to protect its integrity.
It is achieved through encapsulation.