What are differences between Constructors and Methods
Answer : Below are differences:
Constructor | Method |
Name of constructor must be same with name of the class | Method can have any arbitrary name in Java. |
Constructor has no return types | Method can have return type otherwise should be void |
Constructor have chaining to forward call to its super class | Method there is no such terminology available. |
Constructor cannot be inherited | Method can be inherited |
this and super can be used to call constructor of same class and super class | No such functionality is available for methods |
Constructor create and initialize objects that doesn’t exists yet | Method perform operation on objects that is already exists |
Constructor cannot call directly they are called explicitly using new keyword which create an object | Method can be called directly on an object that is already created using new keyword |