GeekInterview.com
Series: Subject: Topic:
Question: 160 of 460

In a multilevel hierarchy how are the constructors are called

A) TopDown
B) BottomUp
C) None
Asked by: Interview Candidate | Asked on: Jan 1st, 2006
Showing Answers 1 - 7 of 7 Answers
sahu

Answered On : Jan 5th, 2006

View all questions by sahu   View all answers by sahu

ans:

B) BottomUp

  
Login to rate this answer.
naveentej

Answered On : Jan 7th, 2006

View all answers by naveentej

Ans: A--- TopDown

Always a parent class constructor is executed before child class' constructor does .. when u instantiate a child/derived class.

Yes  1 User has rated as useful.
  
Login to rate this answer.
Sean Paul

Answered On : Apr 1st, 2006

Bottom Up,  The question is how are they called, not order in which they are they executed. i.e. first the derived class' constructer will be called which in turn will call the parent class' constructor

Yes  1 User has rated as useful.
  
Login to rate this answer.
Ashish

Answered On : Feb 5th, 2007

It will always be topdown: class a { public a() { Console.WriteLine("Class a"); Console.ReadLine(); } } class b:a { public b() { Console.WriteLine("Class b"); Console.ReadLine(); } } class c : b { public c() { Console.WriteLine("Class c"); Console.ReadLine(); } static void Main(string[] args) { c obj = new c(); } }It will give the result:Class aClass bClass C

Yes  1 User has rated as useful.
  
Login to rate this answer.
LordAlex

Answered On : Nov 4th, 2011

View all answers by LordAlex

An object of derived type is constructed from the base class to the derived class by calling the constructors for each class in order.

Rational:Each class's constructor can use base class members in the class constructor.

  
Login to rate this answer.
Philc137

Answered On : Nov 9th, 2011

View all answers by Philc137

Bottom up.

A parent class has no reference to the child class, it's the other way around. The code calls the child class, which then calls the parent class, and so on up. Then the constructors are executed top down.

  
Login to rate this answer.
Sivavt

Answered On : Mar 26th, 2012

View all answers by Sivavt

Order of call: From child to parent
Order of execution: From parent to child

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.