Parameterized_Constructor1
 
  • Constructor: If you don't define constructor, system will provide default constructor, which will allocate memory and initialize instance variable.
  • Naming constructor:
    • The name of the constructor must be the same as the name of the class
    • A constructor can't have return type or void
    • A constructor can't be declared as static or any type, but can take parameters
  •  Parameterized Constructors:
  • Overloading of constructors:

Feeding parameters from a caller class:

Output: