Object Oriented Programming

in coding •  19 days 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

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

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!