+ 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?
3 Answers
+ 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)?
+ 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.
+ 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.