第41669题 单选题
执行如下代码,将输出钢琴:叮咚叮咚和吉他:咚咚当当而不是两行乐器在演奏声音,这体现了面向对象编程的( )特性。
class Instrument:
    """基类:乐器"""
    def play(self):
        print("乐器在演奏声音")

    def __del__(self):
        pass

class Piano(Instrument):
    """子类:钢琴"""
    def play(self):
        print("钢琴:叮咚叮咚")

class Guitar(Instrument):
    def play(self):
        print("吉他:咚咚当当")

if __name__ == "__main__":
    instruments = [Piano(), Guitar()]

    for inst in instruments:
        inst.play()
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析