Can we create object of class with private constructor?

Answers were Sorted based on User's Feedback



Can we create object of class with private constructor?..

Answer / cracker singh

yes

Is This Answer Correct ?    12 Yes 5 No

Can we create object of class with private constructor?..

Answer / fareed

yes we can

public class Person{
privat Person(){
}
public hai(){
System.out.prinln("hai guys");
}
public static Person getobj(){
return new Person();
}

public class Manage{
public static void main(String[] args){
Person pr=Person.getobj();
pr.hai();
}
}

Is This Answer Correct ?    0 Yes 0 No

Can we create object of class with private constructor?..

Answer / 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

Can we create object of class with private constructor?..

Answer / supriya

No we cannot create the objects of class with private
constructor outside the class

Is This Answer Correct ?    0 Yes 1 No

Can we create object of class with private constructor?..

Answer / rahul dhangar

class Rahul
{
private:
int a,b,c;
Rahul()
{ cout<<"enter the no";
cin>>a>>b;
c=a+b;
cout<<c;

}
};
void main()
{
Rahul();
getch();


}

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More OOPS Interview Questions

What is the real life example of polymorphism?

0 Answers  


What is the main feature of oop?

0 Answers  


who is the founder of c++?

15 Answers   Hexaware, ONGC,


which feature are not hold visual basic of oop?

0 Answers   Ignou,


what do you mean by static member variable?

2 Answers  






Explain polymorphism? What r the types of polymorphism? pls give examples?

4 Answers   HCL,


write a program that takes input in digits and display the result in words from 1 to 1000

0 Answers   Wipro,


What is basic concept of oop?

0 Answers  


What does oop mean in snapchat?

0 Answers  


write knight tour problem which is present in datastructure

0 Answers  


Write a program to demonstrate the use of 'Composition' in C++

2 Answers  


what is overloading and overriding?

7 Answers  


Categories