inside static block a = 4 inside constructor a = 11
(B) Compiler Error
(C) Run Time Error
inside static block a = 4 inside constructor a = 5
inside static block a = 10 inside constructor a = 11
Explanation: Static blocks are called before constructors. Therefore, on object creation of class Test, static block is called. So, static variable a = 4.
Then constructor Test() is called which assigns a = 10. Finally, function func() increments its value.
Quiz of this Question
Please comment below if you find anything wrong in the above post
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.