Why is it important to provide a default constructor in Java What happens if your class doesn’t have a no argument constructor?

The arguments of a constructor can only be found by type, not by name, so there is no way for the framework to reliably match properties to constructor args. Therefore, they require a no-arg constructor to create the object, then can use the setter methods to initialise the data .

Sizin İçin Seçtik  Is it always necessary to provide a default constructor for a class Why or why not?

Leave a Reply

Your email address will not be published. Required fields are marked *