QuestionQ30Verified/Object-Oriented ProgrammingCopy linkReport a problemAsk AstroTutorSave questionAssuming the following code has executed successfully, which expressions evaluate to True? Choose twoAhasattr(B, 'get')Bisinstance(obj_b,C)Cobj_c.get() == 2DC._C__VarA == 2Show AnswerAnswerExplanationB inherits the get method from A, so hasattr(B, 'get') is True. C inherits B.get; the double-underscore reference inside that method is mangled to _B__VarA, which resolves to the value 2 defined on B. Therefore, obj_c.get() == 2 is also True.Show comments1Show commentsCommunity DiscussionNo comments yet. Be the first to start the discussion!
Community Discussion