As we know abstract classes can never be instantiated .then what is the use of building the constructer by the compiler during copilation of abstract class
for example if i declare my abstract class
when i decompile my class file..
Constructors in abstract classes are typically used, when you want all your subclasses to share some data. In your example all subclasses will inherit 'i'
Every class needs at least one constructor, for constructor chaining. If a class (abstract or not) does not have a constructor sub classes cannot call it. Therefore, you would not be able to sub class the class at all. In fact, this is exactly what happens if you only provide a private constructor.
I do not think the "decompiled" version posted by the OP is the constructor generated by the compiler. The compiler will generate a default constructor which is no args andempty
Surprisingly, it is. Apparently the compiler puts all initializations that occur when declaring in source code, into all constructors. For instance:
As you can see, the initialization of x to 10 is moved to both constructors.
Interesting.
What do you get if you do not provide any constructors at all? Your existing code has two.
PS. I am not being lazy, but I do not have any decompile tools setup on my home laptop ;)