Ask Question

What will be the output of the following Python code? class A: def test1 (self) : print (" test of A called ") class B (A) : def test (self) : print (" test of B called ") class C (A) : def test (self) : print (" test of C called ") class D (B, C) : def test2 (self) : print (" test of D called ") obj=D () obj. test ()

+5
Answers (1)
  1. 19 April, 09:59
    0
    "test of B called"

    Explanation:

    The object is created for the D class, but there are two test methods in class B and C. The D class does not hold any test method. So when the object called the test method. Then the B method is called. It is because the B class is declared first in the inheritance of D class like in the statement "class D (B, C) ". If the statement will be "class D (C, B) ", then the C method will be called. if the D class holds the method test, then only the D method will be called. Hence the output is "test of B called".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What will be the output of the following Python code? class A: def test1 (self) : print (" test of A called ") class B (A) : def test ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers