Differentiate between a constructor and a method? Can we mark constructors final?


A constructor constructs the value, by providing data for the object. It is a special type of method that is used to initialize the object. The constructor has the same name as the class itself, has no return type, and is invoked using the new operator. A method is an ordinary member function of a class. A method can be invoked using the dot operator and has its own name, and a return type. No, declaring the constructor as final is not possible.

0 answers