1.2.4 OOP definitions Flashcards
(e)
what is a class?
a template for making an object
what is an object?
an instance of a class
what is a constructor method?
- __init__
- creates an instance of an object
what is a public attribute?
accessible anywhere in the code
what is a protected attribute?
only accessible inside the class or subclass
what is a private attribute?
only accessible inside the class
what is encapsulation?
data hiding, making attributes private and only accessible via the public methods
what are the advantages of encapsulation?
1) stops accidental overwriting of attributes
2) allows validation before modifying attributes
what is inheritance?
where a subclass takes on the attributes of a superclass and can have additional attributes and methods
what is polymorphism?
redefining a method in a subclass with new behaviour