explain me clearly what is instance method and what is constructor method.
Instructor
Yogesh Chawla Replied on 30/06/2023
Constructors job is to initialize all non static variables of a class whereas
Instance or non static or methods are used to execute certain statements(Business Functionality).
Constructors:
Constructor is used to create and initialize an Object.
Constructor is invoked implicitly.
Constructor is invoked when new keyword is used to create an object.
Constructor don't have a return type.
Constructor initializes an object which is not existent.
Constructor's name must be same as that of class name.
All constructor execute in subclass in case of inheritance.
Methods:
Method is used to execute Business Functionality through certain statements.
Method is to be invoked during program code.
Method is invoked when it is called.
Method have a return type.
Method can be invoked only on existing object.
Method's name may or may not be same as class name but preferably they should not be same.
Method has to executed separetely when inherited by a subclass.