ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
When a private constructer is being inherited from one 
class to another class and when the object is instantiated 
is the space reserved for this private variable in the 
memory??
 Question Submitted By :: Neha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 1
constructors can not be inherited!
bcoz their work is to initialise the object of the class to 
which they belong to!
so if they get inherited,how can they initialise the object 
of the derived class!
 
Is This Answer Correct ?    1 Yes 0 No
Uttama
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 2
yes
 
Is This Answer Correct ?    1 Yes 0 No
Varsha Vilas Kalebag
 
 
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 3
yes.
 
Is This Answer Correct ?    0 Yes 0 No
Vatsa
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 4
How do u expect a private part of a class to be inheritable
Do u have any code to support your views
I am ready to solve the same
 
Is This Answer Correct ?    0 Yes 0 No
Kamlesh
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 5
The question is very absurd. From where did we get the 
variable stuff? And ya, how on earth do we get private 
members/functions being inherited? Kamlesh is right in 
saying that The whole idea stinks.
 
Is This Answer Correct ?    1 Yes 0 No
Karandeep Malik
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 6
before invoking derived class constructor base-class 
constructor should be called.
1. first base-class object will be created then derived-
class object will be created. 
2. here the base class constructor is private, so derived-
class cannot invoke it.

 No object is created in derived-class.
 
Is This Answer Correct ?    0 Yes 0 No
Balakishore
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 7
Private Constructor is not inherited.
When private member varible is not inherited but the size is
occupid in dervied class object.

e.g. 
#include <iostream.h>
class A
{
   int x;
   int y;
};

class B : private A
{
};

int main()
{ 
   cout << sizeof(B);
}

output :
8
 
Is This Answer Correct ?    1 Yes 0 No
Sanjay Makwana, Puna
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 8
Neha, your question is not proper, please edit that. Some 
where inheritance of private constructor and some where 
private variable.
Please edit it so that people can help you.
 
Is This Answer Correct ?    1 Yes 0 No
Reejusri
[********]
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 9
When a constructor is made private, object of that class 
can not be created. That is called as Abstract class.  
constructors can not be inherited. Moreover, when this 
class is inherited, the base class object can not be 
created. So we can not create the derived class object 
also.
 
Is This Answer Correct ?    0 Yes 1 No
Veena
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 10
When a constructor is made private, object of that class 
can not be created. That is called as Abstract class.  
constructors can not be inherited. Moreover, when this 
class is inherited, the base class object can not be 
created. So we can not create the derived class object 
also.



the above ans is irrelevant to the current situation,
here the thing is, a constructor cannot b private coz there
is no use of .

but if a situation occurs as such in the given prob, yes the
space is reserved for that useless private constructor.
 
Is This Answer Correct ?    0 Yes 0 No
Sillu Nu Oru C Coder
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 11
constructors cannot be private.
 
Is This Answer Correct ?    1 Yes 0 No
Nk
 
  Re: When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??
Answer
# 12
public class TrialClass
{
    protected int i, j;
    public TrialClass(int one, int two)
	{
        i = one;
        j = two;
	}
    public TrialClass(int joo)
    {

    }
    public int squareArea()
    {
        int side1;
        int side2;
        side1 = i;
        side2 = j;
        return side1 * side2;
    }
    
}
public class myDerivedClass : TrialClass

{
     int rd;
     int dr;
    public myDerivedClass(int Age, int ages):base(Age)
    {
        rd = ages;
        dr = Age;    
    }
    
} 

Try making the base class single parameterized constructor
private.You will get your answer.
 
Is This Answer Correct ?    0 Yes 0 No
Ankur Sehgal
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
how to find no of instances of an object in .NET? Infosys1
sir i want to know which posting to apply since i am BE CSE.. also want to know what are the rounds there for my interview...Expecting for ur valuable answer....  1
What is late bound function call and early bound function call? Differentiate.  2
Which is faster post increment or pre increment ? and in which cases should u use either - to increase speed? EA-Electronic-Arts2
What do you mean by pure virtual functions?  4
pointers are support in C#? if yes then how to use it? Softvision-Solution4
What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 2) 17 3) 16.5 TCS10
What is Iteration Hierarchy? What is what is Object behavioral concept?  1
what is a ststic variable and stiticfunction briefly explain with exmple and in which case we use HCL1
What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?  1
What is the correct syntax for inheritance? 1) class aclass : public superclass 2) class aclass inherit superclass 3) class aclass <-superclass  4
How Do you Code Composition and Aggregation in C++ ? IBM1
what is multithreading in c++ , what is difference between multithreading and singlethreading.  1
write a c++ program to find maximum of two numbers using inline functions.  1
what is new modifier in C# HCL6
What is OOPS and How it is different from Procedural Programming ? HP10
What is encapsulation? TCS8
why c++ is called OOPS? waht is inherutance? what is compiler?  2
what is the function of 'this' operator ?  4
When will a constructor executed?  2
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com