+ 2

If a class has no constructor, then if we create an object of that class, what will be the values of attributes? Default values?

26th Oct 2016, 3:00 AM
Aswini Ventrapragada
3 Réponses
+ 1
@Lara: Yes, a default constructor will be called. My question was what are the attributes values? For example, if there is an integer attribute in the class. Then what's the value of that integer(for a new object)?
3rd Nov 2016, 1:10 AM
Aswini Ventrapragada
+ 10
even if you do not write constructor, there is always a default constructor and when you create an object of that class the default constructor will be called.
26th Oct 2016, 7:50 AM
Lara
Lara - avatar
+ 3
In case you did not set a value to an attribute, then by calling the cunstructor the default value will be set. For example for int variable it is zero.
6th Nov 2016, 12:07 PM
Mowlana
Mowlana - avatar