Ask Question
2 December, 18:57

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. 2 December, 19:30
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers