oop Flashcards
1
Q
inheritance
A
- subclass inherits public attributes and methods from superclass
- can override & extend these public methods wo the need to re-implement these methods in their own classes
- to promote code reuse
2
Q
encapsulation
A
- bundling of data and methods that act on the data into an object
- prevents inadvertent modification of data by separating the interface of object from its implementation
3
Q
polymorphism
A
- polymorphic classes present the same interface & have a common set of methods which have the same name but exhibit different behaviours at runtime
- to promote code generalisation
so that instances of polymorphic classes can be handled with the same code without needing conditional handling
4
Q
advantage of encapsulation
A
- thru keeping public mtds & attributes private, keeps data structure more consistent
- prevent bugs (caused frm syntax errors)
5
Q
advantage of inheritance
A
less likelihood of bugs when modifying code (bc less code duplication)
6
Q
KW for polymorphism
A
behave differently
7
Q
how encapsulation achieves data&info hiding in the design
A
- encapsulation invl restricting access to private attributes using public methods
- thus separating the interface of an object from its implementation