Which of the following is/are true about constructors in Java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Which of the following is/are true about constructors in Java?

1) Constructor name should be same as class name. 2) If you don't define a constructor for a class, a default parameterless constructor is automatically created by the compiler. 3) The default constructor calls super() and initializes all instance variables to default value like 0, null. 4) If we want to parent class constructor, it must be called in first line of constructor.

7th Jan 2018, 2:42 PM
Mr.Learner
Mr.Learner - avatar
4 Answers
+ 1
1 2 3 4 all are correct
8th Jan 2018, 3:08 AM
Mr.Learner
Mr.Learner - avatar
+ 3
ok then hooray
7th Jan 2018, 4:15 PM
shobhit
shobhit - avatar
+ 2
all are true (1,2,3,4)
7th Jan 2018, 2:42 PM
Mr.Learner
Mr.Learner - avatar
0
all 4
23rd Oct 2023, 10:58 PM
Maria Tornabene
Maria Tornabene - avatar