+ 3

Which constructor is called ?

We don't write any constructor in class then complier provide default constructor and it's 1st line is super(); then which constructor is call ?  My class is doesn't contain patent class. https://code.sololearn.com/cW1Ezjw8hHMu/?ref=app

6th Mar 2020, 2:50 AM
Ketul Patel
Ketul Patel - avatar
3 Respuestas
+ 6
Every class in Java is a subclass of the Object class. You need not extend the Object class because all the class by default inherit that class. The Object class has a no argument default constructor which is called whenever you create an instance of a class in Java.
6th Mar 2020, 4:20 AM
Avinesh
Avinesh - avatar
+ 2
All classes have at least one constructor. If a class does not explicitly declare any, the Java compiler automatically provides a no-argument constructor, called the default constructor. This default is the Object class constructor if the class has no other parent. public class Program { super(); // This is the call to the parent class constructor }
7th Mar 2020, 7:02 AM
ROBIN C R
ROBIN C R - avatar
+ 1
An Object class constructor.. Since it's a super class for all classes...
6th Mar 2020, 6:41 PM
Ashwini Chandrashekaraiah
Ashwini Chandrashekaraiah - avatar