OOPs Concepts
Programming and Technical
What is the difference between a constructor and a method?
Read Solution (Total 4)
-
- 1)constructors don't have return type
Methods have return type
2)Constructor called automatically when object of that class is created
We have to call method explicitly - 10 years agoHelpfull: Yes(4) No(0)
- constructor is a special type of sub pgm with the class name it will be executed when object is created
Method we have to call explicitily then it will be exceuted. - 10 years agoHelpfull: Yes(0) No(0)
- Constructor automatically initialize its property directly upon its creation thats why it has same name as class name but method does not and constructor have no return type
- 9 years agoHelpfull: Yes(0) No(0)
- A constructor is a special member method that has no return type
A method on the other hand always has a return type - 9 years agoHelpfull: Yes(0) No(0)
OOPs Concepts Other Question