Can we have a private constructor ?

Answers were Sorted based on User's Feedback



Can we have a private constructor ?..

Answer / namrata ahuja

no. constructors are always declared publicly. they are used
to initialize data members of a class. they are
automatically invoked by a class object declaration so if it
is private it cannot be invoked.

Is This Answer Correct ?    6 Yes 39 No

Can we have a private constructor ?..

Answer / ravi`

no,
we can not make a constructor private , if we make a
constructor private its method cannot access in main method .

Is This Answer Correct ?    17 Yes 136 No

Post New Answer

More OOPS Interview Questions

write a program to find 2 power of a 5digit number with out using big int and exponent ?

0 Answers  


Base class has two public data members. How can i derive a new class with one datamember as public and another data member as private?.

2 Answers  


what are the ways in which a constructors can be called?

0 Answers  


String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?

0 Answers   HCL,


what are abstract classes and how they impliment , with example

2 Answers  






what isthe difference between c structure and c++ class

5 Answers  


create a class complex having real and imaginary part of a complex no. as a data member. overload the binary operators(+,- and *) to perform the operations on complex no. objects. overload binary operator using friend function.

2 Answers   CTS, Delhi University,


what is costructor?

1 Answers  


assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).

0 Answers  


what is namespace? what are the uses of namespace?

1 Answers  


What is inheritance in oop?

0 Answers  


What is abstraction?

9 Answers  


Categories