The purpose behind the Parameterized constructor

What is the purpose behind using Parameterized constructor. Will it be use when we have to execute the program with some predefined values?

Thanks

Comments

  • not exactly...constructors run code only once...so if you instantiate (create) an object from a class it will run the code in the constructor...parameters in the constructor label an objects predefined value...

    so if you have an object called dog
    you can use parameters to make the dogs
    weight
    breed
    height

    etc...
    remember constructors are named after the class...and never return a value

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion