+ 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
3 ответов
+ 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.
+ 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
}
+ 1
An Object class constructor.. Since it's a super class for all classes...