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 object in oops?

609


Get me an image implementation program.

1557


Give two or more real cenario of virtual function and vertual object

1849


Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer

1615


Templates mean

1586






given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy

2142


What causes polymorphism?

568


write knight tour problem which is present in datastructure

2160


Is data hiding and abstraction same?

566


Plese get me a perfect C++ program for railway/airway reservation with all details.

3426


What do you mean by variable?

572


What is difference between class and object with example?

561


What does no cap mean?

590


Who invented oop?

647


Is react oop?

607