All Flashcards
What is an object?
a collection of data that is associated with certain behaviours
Which statement is used when we have a function wit no content
pass statement
What are arbitrary parameters
a function with a not known amount of arguments. * is used before the argument to let the code know.
Whats the difference between a function and a method
methods require a parameter named self
what is Inheritance?
creates a new class using the data & methods of another class (overerven van parent class)
What is Encapsulation?
restricts the direct access to some data & behaviours (+public, -private)
What is Polymorphism?
execute a single behaviour in various ways
Explain the difference between Composition and Aggregation?
composition: class A acts as the container of class B (delete A -> delete B)
Aggregation: class A refers to class B (delete A does not delete B)
give a example of a list?
list1 = [1,2,3]
list2 = [‘abc’, ‘def’]
How to use the super() method and where is it for?
its used to inherit the functionality of the parent class
super(<childClass>, self).\_\_init\_\_()</childClass>
Explain Method Resolution Order (MRO)?
MRO is a concept used in inheritance. It is the order in which a method is searched for in a classes hierarchy and is especially useful in Python because Python supports multiple inheritance.
What is multievel - Vs. multiple inheritance?
multiple: classC(classA, classB):
What is the difference between instance - and class attributes?
instance: only available in a certain object, example: self.x = 850
class: defined in the body of a class, example: x = 850
What is the difference between equality and identity?
equality: ‘==’ used to check values of 2 objects are the same
identity: ‘is’ or ‘is not’ used to check memory adresses are the same
Give an example of how to handle a attribute Error?
try:
X.append(6)
except AttributeError:
print(‘error message)
Where does UML stand for?
Unified Modeling Language
What are the 4 basic principels of OOP?
- inheritance
- abstraction
- encapsulation
- polymorphism