skills check 1 Flashcards
What are the advantages of OOP Provide examples.
Advantages:
Reusability through inheritance (e.g., creating a Vehicle class and reusing it for Car and Bike).
Modularity via encapsulation (e.g., class members hidden with private access modifiers).
Easier maintenance and debugging since each class can be developed and tested independently.
Improved scalability and flexibility.
What are the disadvantages of object-oriented programming Provide examples?
Disadvantages:
Increased complexity for small programs.
Slower execution compared to procedural programming for some tasks.
Requires careful planning to implement effectively.
In UML, what is the difference between class and object diagrams? Provide examples.
Class Diagram: Represents the blueprint of a system, showing classes, attributes, methods, and relationships (e.g., inheritance, associations).
Object Diagram: Represents a snapshot of the system at a particular moment, showing specific objects and their relationships.
Describe inheritance in the context of object-oriented programming. Provide examples.
Inheritance allows one class (child) to acquire the properties and methods of another class (parent).
Describe virtualization in the context of object-oriented programming. Provide examples.
Virtualization in OOP often refers to virtual functions, enabling dynamic (runtime) polymorphism. (Same function name being used but different implementation)
Describe encapsulation in the context of object-oriented programming. Provide examples.
Encapsulation involves bundling data and methods into a single unit (class) while restricting access to certain components.
Describe association in the context of object-oriented programming. Provide examples.
Association is a relationship between objects where one object uses or interacts with another.
Example: A Doctor treating a Patient.
Describe aggregation in the context of object-oriented programming. Provide examples.
Aggregation represents a “has-a” relationship where one object contains another, but the contained object can exist independently.
Example: A Department has many Employees.
Describe composition in the context of object-oriented programming. Provide examples.
Composition is a stronger “has-a” relationship where the contained object’s lifecycle is tied to the container.
Example: A Car has an Engine.
This UML diagram represents the concept of composition in object-oriented programming.