Interviews5 answers
Whats is the use of a private constructor? Calling non- static method from a static class, Is this possible?
5 Answers
1.We can prevent object creation from outsider class when we have only Private Constructor(s).
2. Create an instance of non static's method's class and invoke nonstatic method
Manju KaniappanPosted Sep 6, 2017, 7:24 AM EDT
1.We can prevent object creation from outsider class when we have only Private Constructor(s).
2. Create an instance of non static's method's class and invoke nonstatic method
Manju KaniappanPosted Sep 6, 2017, 7:24 AM EDT
Yes
Mukesh KumarPosted Sep 4, 2017, 3:13 AM EDT
you can call non-static method from static method. See example
public class MyClass
{
private void data1()
{
}
private static void data2()
{
MyClass c = new MyClass();
c.data1();
}
}
sushil kumarPosted Jul 20, 2017, 9:55 AM EDT
Not Possible.Class cannot have private constructor and static class cannot have non static method.
Ayappan AlagesanPosted Feb 10, 2017, 4:07 AM EST


