recategorized by
2,731 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

2 votes
2 votes
2 answers
1
go_editor asked Jul 7, 2016
4,216 views
The mechanism that binds code and data together and keeps them secure form outside world is known asAbstractionInheritanceEncapsulationPolymorphism
2 votes
2 votes
1 answer
2
go_editor asked Jul 7, 2016
1,261 views
Match the following with respect to java.util.$\ast$ class methods :$\begin{array}{clcl} \text{(a)} & \text{Bit Set} & \text{(i)} & \text{Time zone getTimezone()} \\ \t...
1 votes
1 votes
1 answer
3
go_editor asked Jul 13, 2016
1,158 views
Which is the method used to retrieve the current state of a check box?get State ( )put State ( )retrieve State ( )write State ( )