+ 2
Constructors in java
When and how the default constructor is made? And why do we need to create the default constructor when we implement constructor overloading?
4 Antworten
+ 2
Thanks for the info..
+ 2
when you create a class. JVM automatically creates an empty default constructor.for instance,
class Demo{
Demo(){
super();
}
}
This constructor is implicitly created by JVM at run time along with the super statement.
It is needed to create because, object class is the super most class java.Hence the super() statement inside the constructor is used to call the super class constructor from subclass constructor.
Note : Every class in java directly or indirectly extended by Object class.
+ 1
@Bharath_Teki thanks bro.. That helped...