Howdy, Stranger!

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

Categories

The purpose behind the Parameterized constructor

akhendre88akhendre88 MumbaiMember Posts: 2

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

  • Warren BrandtWarren Brandt irelandMember Posts: 2

    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.