Difference Between Method and Constructor
The main Difference Between Method and Constructor is;Method call by programmer manually but constructor call automatically when the object of the class is created.
Some Important Differences between Method and Constructor are;
- Constructor are used to initialize the state of object,where as method is expose the behavior of object.
- Constructor must not have return type where as method must have return type.
- Constructor name same as the class name where as method may or may not the same class name.
- Constructor invoke implicitly where as method invoke explicitly.
- Constructor compiler provide default constructor where as method compiler does't provide.
No comments:
Post a Comment