Past paper (OOP) Flashcards
(14 cards)
What is inheritance in OOP?
Subclasses inherit attributes & methods from parent classes, promoting code reuse and hierarchy.
What is polymorphism in OOP?
Objects of different classes can be treated as instances of a common superclass or interface.
How does polymorphism add flexibility?
Same method call behaves differently depending on object class implementation.
Define encapsulation in OOP.
Bundling data (attributes) & methods inside a class, hiding internal object state from outside.
Why is encapsulation important?
Protects data, prevents direct access, enhances security and maintainability.
What is a mutator method?
Setter method that modifies object attributes; usually void and takes parameters.
What is an accessor method?
Getter method that returns attribute value without changing it; no parameters.
Compare mutator and accessor methods.
Mutator changes attribute; accessor returns attribute value without changing it.
What is method overriding?
Subclass provides a new implementation for a method inherited from superclass with same signature.
What is method overloading?
Multiple methods in the same class with same name but different parameter lists.
Difference between method overriding and overloading?
Overriding: different classes, same method signature. Overloading: same class, same name, different parameters.
What does a minus sign (-) mean in class diagram fields?
Private access modifier.
What does a hash sign (#) mean in class diagram fields?
Protected access modifier (package or subclass access).
How is a constant field represented in a class diagram?
All capital letters, underlined, with assigned value (e.g., MAXHOURS = 8).