What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?
Answers
Answered by
2
aDefault constructor is also known as zero argument constructors. Default constructor does not have any parameters and is used to set (initialize) class data members. Since, there is no argument used in it, it is called "Zero Argument Constructor".
In a class, if there is no default constructors defined, then the compiler inserts a default constructor with an empty body in the class in compiled code.
Constructor can also be defined outside of the class; it does not have any return type
In a class, if there is no default constructors defined, then the compiler inserts a default constructor with an empty body in the class in compiled code.
Constructor can also be defined outside of the class; it does not have any return type
Answered by
6
▬▬▬▬ ▬▬▬▬
• It could happen that the constructor might be defined as private or true headed then this kind of problem occurs
⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ If no constructor is defined within the class the Java compiler automatically invokes a default constructor that initially as all the fields or data members with its default values
Similar questions
English,
7 months ago
Social Sciences,
7 months ago
Math,
7 months ago
Business Studies,
1 year ago
English,
1 year ago
Math,
1 year ago
Physics,
1 year ago