java - Does Object's constructor call super()? Which superclass constructor would that call? -
this question has answer here:
if object class contains default constructor generated compiler must have super(); declaration. if declaration there parent class constructor calling? , how?
because object parent of classes, think if call super(); in object class constructor should give compile time error because know object doesn't inherit anything.
class test { test() { super(); } public static void main(string[] args) { test t = new test(); } }
no. jls-8.8.9. default constructor says (in part)
if class being declared primordial class
object, default constructor has empty body. otherwise, default constructor invokes superclass constructor no arguments.
Comments
Post a Comment