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
Can partial class be inherited?
What is xor operator in c#?
Is null empty or whitespace c#?
1. Describe page life cycle?
How do I run managed code in a process?
Can hashset contain duplicates c#?
Why we use extension method in c#?
Difference between abstract classes and interfaces
How many dimensions can an array have?
What is using directive in c#?
What operators can be used to cast from one reference type to another without the risk of throwing an exception?
Do events have return type c#?
explain Garbage collector’s functionality on unmanaged code
What are the namespace level elements?
What language is c# similar to?