0
Why an empty class also internally contains default constructor after compiling?
Without creating any new instance or object what's the use of that constructor, that the compiler generates automatically and why?
3 Answers
+ 11
The default constructor implicitly calls the superclass's nullary constructor, then executes an empty body. All fields are left at their initial value of 0 (integer types), 0.0 (floating-point types), false (boolean type), or null (reference types).
Source:
https://en.m.wikipedia.org/wiki/Default_constructor
0
But m talking about only a simple class having no super class also creates a constructor implicitly. why?
0
From my study i got that an empty class also contains a constructor because object of this class can be created in other class and compiler doesn't know when and which class will create obeject of this class. [Generally .class file depends on its .java file]