This is more difficult in Python and can really frustrate you.
Patience is the key and do not forget to practice.
Object oriented programming quiz
- The property is created
a) Using the property decorator
b) Using the classmethod decorator
c) Making a class a subclass of property
Answer - a) @property
- What is the difference between a class method and a static method?
a) Class methods are passed the calling class, static methods aren't
b) Class methods are faster
c) Class methods are inherited, static methods aren't
Answer - a) refers to the class instance with cls or self
- What are the usual parameter names for the calling instance and the calling class?
a) slf and cls
b) self and cls
c) self and class
Answer - b) self and cls ( it was also referred to in the previous question)
- What method is called just before an object is instantiated?
answer - c) init
(__ is double underscore)
- Fill in the blanks to make the egg attribute strongly private and access it from outside of the class.
___egg = 7
t = Test()
Answer - _egg = 7
t = Test()
- What is the automatic process by which unnecessary objects are deleted to free memory?
a) Garbage collection
b) Rubbish deletion
c) Bit-trash exfoliation
Answer - a) Garbage collection
def init(self, name):
self._name = name
def name(self, value):
@name.setter - first-line answer
_name - second line answer