Wednesday, February 10, 2021

 What is Constructor ??


Before moving on Constructor part we will know about 1st what is Object in programming language object is a real entity which is  our daily day life you can say in programming we relate real life entity to it It means that suppose you have a box of name box1 that is a real life entity

in programming we say that it is box1 object 


so Constructor is basically used for initializing the object 

if you make obect of box1 then simply comiler will make a default constructor which is initialized the object with assigning by default values like 

0, 0.0, null,false which is dafault values of primitive data type...



but you think and imagine of box1 object ??? 

is there any object exist with length =0; breadth=0,heigth=0,  No there is not 

so how could you make this real object ??


yes you can make object with the help of Constructor 


initialize the variables of length=5;heigth=8; breadth=8; 

 this will represent the actual object in your programming ...


so this is the basic concept of Constructor if you want more about it then simply switch this link it will help to understand the 

basic concept of Constructor ...


No comments:

Post a Comment

Featured Posts