Ask Question
7 July, 22:45

If class C inherits class B. And B has inherited class A. Then while creating the object of class C, what will be the sequence of constructors getting called?

+4
Answers (1)
  1. 8 July, 00:48
    0
    Constructor of A then B, finally C

    Explanation:

    A constructor in Java is a method of initializing objects. The constructor is called when an object of a class is created. It can be used to set initial values for object characteristics.

    In creating the object of class C, its constructor would be called by default. But, if the class is inheriting some other class, firstly the parent class constructor will be called so that all the data is initialized that is being inherited.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “If class C inherits class B. And B has inherited class A. Then while creating the object of class C, what will be the sequence of ...” 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