Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Child cObj = new Parent()
Wahts the output ?

Answers were Sorted based on User's Feedback



Child cObj = new Parent() Wahts the output ?..

Answer / deepthi

An error. We cant create such kinda objects.

Is This Answer Correct ?    20 Yes 5 No

Child cObj = new Parent() Wahts the output ?..

Answer / bhavin pandya

It will give yo Error :-
Object reference not set to an instance of an object.


If you want to create object then

Child cObj = new Child()
this is the right way

Is This Answer Correct ?    8 Yes 3 No

Child cObj = new Parent() Wahts the output ?..

Answer / austin j seelan

Child cObj = new Parent()
This will through the compiletime error.
but we can create an instance like the foll.way
parent objparent = new child()

Is This Answer Correct ?    7 Yes 2 No

Child cObj = new Parent() Wahts the output ?..

Answer / bangarraju

This is the DownCasting,but using like this
Child* obj=down_cast<Child* >(Parent) either using RTTI
mechanism in C++

Is This Answer Correct ?    1 Yes 0 No

Child cObj = new Parent() Wahts the output ?..

Answer / donga bangarraju

sorry for the earlier post, this output is giving error like
initializing cannot convert to Paretn* to Child*, if u want
correct this code write like this, this is downcasting or
using RTTI mechanism in C++;

Parent* p =new Child;
Child* obj= dynamic_cast<Child*>(p);

Is This Answer Correct ?    1 Yes 1 No

Child cObj = new Parent() Wahts the output ?..

Answer / aditya

Its java syntax where there is no pointers.
So its dynamic method dispatch which is same as virtual
functions of c++.

Is This Answer Correct ?    0 Yes 0 No

Child cObj = new Parent() Wahts the output ?..

Answer / chetan

it will execute without an error. if Parent class is
parent/base class and child is the child/drive class which
inherit parent class.
In the other worlds you are invoking drive class method with
the reference of base class.

Is This Answer Correct ?    3 Yes 3 No

Child cObj = new Parent() Wahts the output ?..

Answer / giri

You can write below ways [Upcasting].

Child *cObj = new Parent();

Is This Answer Correct ?    5 Yes 10 No

Post New Answer

More OOPS Interview Questions

me get an assignent n its question is this 1.creat a set as in math i.ea={1,2} 2.insert element in it3. delete element don,t repeat any element 4.union 5. intersection of two sets plz help me i always pray for u n send me at ayeshawzd@hotmail.com f u have c++ how to program 5th addition then it is the 10.9 question in 10th chapter exercise

1 Answers  


Finding of the 4 larger (bigger) numbers from the list like{1245,4587,2145,1163,29987,65783.....}

1 Answers   Wipro,


what is the difference between class and object?

9 Answers  


What are the 4 pillars of oop?

0 Answers  


The IT giant Tirnop has recently crossed a head count of 150000 and earnings of $7 billion. As one of the forerunners in the technology front, Tirnop continues to lead the way in products and services in India. At Tirnop, all programmers are equal in every respect. They receive identical salaries and also write code at the same rate. Suppose 14 such programmers take 14 minutes to write 14 lines of code in total. How long will in take 5 programmers to write 5 lines of code in total ?

6 Answers   TCS,


inheritence with example

1 Answers  


How to calculate the age from the date of birth by using the program?

2 Answers   Accenture,


Why do we use virtual functions?

4 Answers  


What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?

0 Answers   NIIT, SRA,


What is the difference between a constructor and a destructor?

0 Answers  


Get me a number puzzle game-program

0 Answers  


Prepare me a program for the animation of train

0 Answers  


Categories