how a default constructor is created | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

how a default constructor is created

what will be the value of default constructor

2nd Sep 2016, 6:44 AM
Jithin Sathianandan
Jithin Sathianandan - avatar
5 Réponses
+ 2
if your class does not have any constructor, java automatically creates the default constructor. You cant see default constructor in your source code (thats obvious), but it is present in .class file after compilation by javac. Furthe, even if you defined a constructor with null (like the default constructor is), it wont be called as called as default constructor. Means you cant create default constructor by your own.
2nd Sep 2016, 10:16 AM
Vinay
Vinay - avatar
0
if you don't define a constructor then default constructor is automatically created. there is no other way to create a default constructor. and default constructor provides random values to attributes, every time u create an object. you can see that value by using class A { int x; system.out.println(int x); }
9th Sep 2016, 9:01 PM
sourabh patel
sourabh patel - avatar
0
default constructor has no parameters
1st Oct 2016, 5:56 PM
balram sao
balram sao - avatar
- 2
class c { c () {} }
2nd Sep 2016, 8:19 AM
Sunil Darshan
Sunil Darshan - avatar
- 3
The default contractor is created : class NameClass{ NameClass{ } }
6th Sep 2016, 3:25 PM
Abdelghani
Abdelghani - avatar