Which class is super class of every class

What are differences between Constructors and Methods

Answer : Below are differences:

Constructor

Method

Name of constructor must be same with name of the classMethod can have any arbitrary name in Java.
Constructor has no return typesMethod can have return type otherwise should be void
Constructor have chaining to forward call to its super classMethod there is no such terminology available.
Constructor cannot be inheritedMethod can be inherited
this and super can be used to call constructor of same class and super classNo such functionality is available for methods
Constructor create and initialize objects that doesn’t exists yetMethod perform operation on objects that is already exists
Constructor cannot call directly they are called explicitly using new keyword which create an objectMethod can be called directly on an object that is already created using new keyword

Leave a Reply

Your email address will not be published. Required fields are marked *