Interviews15 answers
These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }
15 Answers
Static constructor must be parameterless.
sushil kumarPosted Feb 20, 2019, 1:38 AM EST
static constructor does not contain any parameter or access modifier or return type.
sushil kumarPosted Jul 20, 2017, 10:34 AM EDT
1. Incorrect because static constructor will not have return type
2&3. Incorrect because static constructor must be parameterless
parvathi somanahalliPosted Mar 18, 2017, 11:32 AM EDT
Your class is not static how should you define constructor its compile time error.
ashish bhuiPosted Oct 6, 2016, 5:03 AM EDT
Your class is not static it gives you compile time error..
ashish bhuiPosted Oct 6, 2016, 5:02 AM EDT
Your class is not static it gives you compile time error..
ashish bhuiPosted Oct 6, 2016, 5:02 AM EDT
Your class is not static it gives you compile time error..
ashish bhuiPosted Oct 6, 2016, 5:02 AM EDT
Your class is not static it gives you compile time error..
ashish bhuiPosted Oct 6, 2016, 5:02 AM EDT
Static constructors should be parameter less
Mangesh KulkarniPosted Jul 31, 2016, 11:00 AM EDT
Static Constructor must be parameter less
Mangesh KulkarniPosted Jul 31, 2016, 10:59 AM EDT
Constructor don't have return type
Mukesh kumarPosted May 8, 2016, 2:48 AM EDT
Please see below
class A
{
statc intA()
{
Correct
}
static A(int x,int y)
{
Incorrect
}
static A(int x)
{
Incorrect
}
}
Static constructor automatically invoked/called by CLR so access modifer or parameters are not allowed
Raghvandra ShuklaPosted Mar 27, 2016, 4:06 AM EDT
Static constructor will automatically be invoked only once. It happens either creation of the first object or accessing its static members. Any way we cannot explicitly invoke the static constructor so access modifer or parameters are not allowed
vipin kvPosted Mar 10, 2016, 3:46 AM EST
no
Anil JhaPosted Mar 3, 2016, 8:31 AM EST
A static constructor does not take access modifiers or have parameters.
Rajesh SinghPosted Nov 16, 2015, 5:34 AM EST



