All Flashcards

1
Q

What is an object?

A

a collection of data that is associated with certain behaviours

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which statement is used when we have a function wit no content

A

pass statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are arbitrary parameters

A

a function with a not known amount of arguments. * is used before the argument to let the code know.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Whats the difference between a function and a method

A

methods require a parameter named self

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is Inheritance?

A

creates a new class using the data & methods of another class (overerven van parent class)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Encapsulation?

A

restricts the direct access to some data & behaviours (+public, -private)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Polymorphism?

A

execute a single behaviour in various ways

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain the difference between Composition and Aggregation?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

give a example of a list?

A

list1 = [1,2,3]
list2 = [‘abc’, ‘def’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to use the super() method and where is it for?

A

its used to inherit the functionality of the parent class

super(<childClass>, self).\_\_init\_\_()</childClass>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain Method Resolution Order (MRO)?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is multievel - Vs. multiple inheritance?

A

multiple: classC(classA, classB):

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between instance - and class attributes?

A

instance: only available in a certain object, example: self.x = 850
class: defined in the body of a class, example: x = 850

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between equality and identity?

A

equality: ‘==’ used to check values of 2 objects are the same
identity: ‘is’ or ‘is not’ used to check memory adresses are the same

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Give an example of how to handle a attribute Error?

A

try:
X.append(6)
except AttributeError:
print(‘error message)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Where does UML stand for?

A

Unified Modeling Language

17
Q

What are the 4 basic principels of OOP?

A
  1. inheritance
  2. abstraction
  3. encapsulation
  4. polymorphism