Can we create object of class with private constructor?
Answers were Sorted based on User's Feedback
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 |
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 |
Answer / supriya
No we cannot create the objects of class with private
constructor outside the class
Is This Answer Correct ? | 0 Yes | 1 No |
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 |
What is the real life example of polymorphism?
What is the main feature of oop?
who is the founder of c++?
which feature are not hold visual basic of oop?
what do you mean by static member variable?
Explain polymorphism? What r the types of polymorphism? pls give examples?
write a program that takes input in digits and display the result in words from 1 to 1000
What is basic concept of oop?
What does oop mean in snapchat?
write knight tour problem which is present in datastructure
Write a program to demonstrate the use of 'Composition' in C++
what is overloading and overriding?