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
Explain About multi level and multiple inheritance how to achieve in .net
What is datetime minvalue in c#?
Why are strings immutable c#?
Name the property of the textbox which cannot be changed at runtime?
What is a linked list c#?
What is a generic in c#?
Can I define a type that is an alias of another type (like typedef in c++)?
What is var c#?
Explain the 3 types of properties in c# with an example?
What is an object and a class?
What is the use of getcommandlineargs() method in c#.net?
What is boxing in c#?
What are events in C#?
Can an abstract class inherit from another abstract class c#?
Where do we use static class in c#?