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 polymorphism and its types?

827


hi all..i want to know oops concepts clearly can any1 explain??

1905


just right the logic of it 1--> If few people are electing then every time ur candidate should win 2--> arrange books in box, if box carry weight == books weight then take another box..... find the no of box required.

6723


Why is abstraction needed?

777


What is inheritance in oop?

817


What are the benefits of interface?

820


What is methods in oop?

755


Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

2236


What is oops with example?

791


Can main method override?

854


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

1926


write a programe to calculate the simple intrest and compund intrest using by function overlading

1925


Can abstract class have normal methods?

809


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

2077


What is ambiguity in inheritance?

868