• 2022-06-09
    ‎下列程序的输出结果是( )。​‎class Fruit():​‎ def __init__(self):​‎ print('Fruit')​‎ def grow(self):​‎ print('Fruit grow')​‎​‎class Vegetable():​‎ def __init__(self):​‎ print('Vegetable')​‎ def grow(self):​‎ print('Vegetable grow')​‎ ​‎class Tomato(Fruit,Vegetable):​‎ pass​‎​‎t = Tomato()​‎t.grow()​‎​‎知识点:多继承​
    A: FruitFruit grow
    B: FruitVegetable grow
    C: VegetableFruit grow
    D: VegetableVegetable grow
  • A

    内容

    • 0

      下列代码的输出结果是(_____)。 class Account: def __init__(self,id): self.id=id id=888 acc=Account(100) print(acc.id)

    • 1

      下面关于抽象类定义合法的是( ) A: class Animal { abstract void grow(); } B: abstract Animal { abstract void grow(); } C: class abstract Animal { abstract void grow(); } D: abstract class Animal { abstract void grow(); }

    • 2

      Python中类的定义正确的是 A: class Phone: name = "" call(self, name) print(name, "打电话") B: class Phone: name = "" call(self, name) print(name, "打电话") C: class Phone: name = "" def call(self, name): print(name, "打电话") D: class Phone name = "" def call(self, name): print(name, "打电话")

    • 3

      class Person:def __init__(self,n="xxx"):self.name=nclass Student(Person):def __init__(self,s="male"):self.sex=sdef show(self):print(self.name,self.sex)s=Student("female")s.show()结果: A: xxx male B: xxx C: 结果错误 D: xxx female

    • 4

      下面程序运行的结果是( )。class Person:def __init__(self,n="张三"): self.name=nclass Student(Person):def __init__(self,s="male"):self.sex=sdef show(self):print(self.name,self.sex)s=Student("female")s.show() A: 张三 male B: 张三 female C: 出错 D: 张三