Object Oriented Programming

in #coding4 years ago

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?

a) create
b) del
c) init

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.

class Test:
___egg = 7

t = Test()
print(t._Test____)

Answer - _egg = 7
t = Test()
print(t.Test
egg)

  • 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

  • class Person:
    def init(self, name):
    self._name = name

    @property
    def name(self):
    return self._name


def name(self, value):
self._____= value

@name.setter - first-line answer
_name - second line answer

image source

Sort:  

Congratulations @filler! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published more than 50 posts. Your next target is to reach 60 posts.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 64303.16
ETH 3137.29
USDT 1.00
SBD 3.97