Distinguish between default constructor and default value constructor? When do you need default value constructor?

Subject Object Oriented Programming
NU Year Set: 6.(a) Marks: 5 Year: 2009

The default constructor is a type of constructor that is called automatically when the programmer has not defined any constructor in the program. In contrast, the parameterized constructor is a type of constructor defined by the programmer by passing parameters to give initial values to the instance variables in the class. That is the main difference between default and parameterized constructor.

Most high-level programming languages support Object Oriented Programming (OOP). In OOP, everything is a class, which helps to build objects. These objects communicate with each other in the program. The constructor is a concept in OOP. It is a special method that allows initializing an object on its creation. The constructor can either be default or parameterized.

Login to post your comment.