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
What is delegates in c# and uses of delegates?
Can we override constructor in c#?
Explain About stateless and state full web service
Can constructor have return type c#?
Explain how do you debug an asp.net web application?
What does args mean in c#?
What is a web service in c#?
What is use of list in c#?
Explain get and set accessor properties?
What is uint64_t?
What is polymorphism c# example?
What do you understand by an Implicit Variable?
What is delegate in c# interview questions?
If multiple interfaces are inherited and they have conflicting method names; What will happen ?
What is deferred execution in c#?