Computer Science, asked by angelinawilliam8437, 1 year ago

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 charayavarun
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

Answered by Anonymous
6

▬▬▬▬ \huge\mathfrak{Answer} ▬▬▬▬

• 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