python_面向对象小试题

 

 

打印啥?

class Animal(object):
    hobby = "eat"

    def run(self):
        print(self.hobby)
        return self.hobby


class Dog(Animal):
    hobby = "sleep"


dog = Dog()
print(dog.hobby)    
print(dog.run())  

 

答案

sleep
sleep
sleep
View Code

 

 

考点:

  面向对象

  继承

  内置变量

  返回值  

 

转载于:https://www.cnblogs.com/shijieli/p/10160916.html

你可能感兴趣的:(python_面向对象小试题)