recategorized by
2,809 views
2 votes
2 votes

Assume that we have constructor functions for both base class and derived class. Now consider the declaration in

main()

Base *P=New Derived;

In what sequence will the constructor be called?

  1. Derived class constructor followed by Base class constructor
  2. Base class constructor followed by Derived class constructor
  3. Base class constructor will not be called
  4. Derived class constructor will not be called
recategorized by

1 Answer

2 votes
2 votes

ans is  B
Here A derived class object is created first and then assigned to a base class pointer. Whenever a derived class object is created, the base class constructor gets called first and then the derived class constructor.
 

Answer:

Related questions

4.4k
views
2 answers
2 votes
go_editor asked Jul 7, 2016
4,367 views
The mechanism that binds code and data together and keeps them secure form outside world is known asAbstractionInheritanceEncapsulationPolymorphism
1.3k
views
1 answers
2 votes
go_editor asked Jul 7, 2016
1,329 views
Match the following with respect to java.util.$\ast$ ... d)-(i)}$\text{(a)-(ii), (b)-(i), (c)-(iii), (d)-(iv)}$
1.2k
views
1 answers
1 votes
go_editor asked Jul 13, 2016
1,215 views
Which is the method used to retrieve the current state of a check box?get State ( )put State ( )retrieve State ( )write State ( )
3.4k
views
1 answers
2 votes
go_editor asked Aug 20, 2016
3,379 views
When one object reference variable is assigned to another object reference variable thena copy of the object is createda copy of the reference is ... illegal to assign one object reference variable to another object reference variable