Can we have private constructor in our class file. When we
are trying to create instance for the class will it create
or throw error regarding that?
Answer Posted / ranjeet saini
it does not throw an exception
bcoz we can create private constructor if we have static member in class
in this we can create a reference object with the help of static method.
class A
{
private A()
{
C.w.l(" Hi");
}
public static display()
{
return new A();
}
S V M ( S[] args)
{
A a=a.display()
}
}
Is This Answer Correct ? | 1 Yes | 4 No |
Post New Answer View All Answers
Is class reference type c#?
What is boxing in c#?
What is the use of thread join in c#?
How do I enforce const correctness in c#?
Is linkedhashset synchronized?
List some of the common data providers for ado.net framework?
what is IEquatable
Why do we use readonly in c#?
Explain the process of Serialization?
Are all methods virtual in c#?
What is the use of command builder?
What is the difference between icomparer and icomparable in c#?
What is AutoMapper in C#?
What is the difference between struct and class c#?
Explain the process of inheriting a class into another class?