+ 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?

18th Feb 2018, 12:22 AM
Aman Kumar Jha
Aman Kumar Jha - avatar
4 Respuestas
+ 2
Thanks for the info..
18th Feb 2018, 2:14 AM
Aman Kumar Jha
Aman Kumar Jha - avatar
+ 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.
18th Feb 2018, 2:22 AM
Bharath_Teki 🇮🇳
Bharath_Teki 🇮🇳 - avatar
+ 1
@Bharath_Teki thanks bro.. That helped...
18th Feb 2018, 2:44 AM
Aman Kumar Jha
Aman Kumar Jha - avatar