Can we create object of class with private constructor?

Answer Posted / rajneesh

Public class mainclass
{
private static mainclass _obj = null;
private constr()
{
}
public static mainclass obj
{
get
{
return _obj
}
}

}

after that you can access the obj in other class .

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is abstraction with example?

825


What is the purpose of polymorphism?

876


What is encapsulation in simple terms?

766


What is encapsulation in ict?

808


What is the purpose of enum?

765


What do you mean by abstraction?

815


State what is encapsulation and friend function?

942


Which is not an object oriented programming language?

737


Can an interface inherit a class?

779


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<

1636


What is overriding in oop?

787


What are oops functions?

781


What is oops and its features?

829


What is polymorphism oop?

820


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?

2155