1
Reply

Assume that a class, Class1, has both instance and static constructors. Given the code below, how many times will the static and instance constructors fire?

Samir Bhogayta

Samir Bhogayta

Jun 25, 2016
211
0

    Class1 c1 = new Class1(); Class1 c2 = new Class1(); Class1 c3 = new Class1();By definition, a static constructor is fired only once when the class is loaded. An instance constructor on the other hand is fired each time the class is instantiated. So, in the code given above, the static constructor will fire once and the instance constructor will fire three times.

    Samir Bhogayta
    June 25, 2016
    0