What is the difference between constructor and method?
Ask by Pushpendra Singh
Updated 18 Sep 2020
A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.
Constructor does not have a return type.
Name of constructor is the same as that of class in which it is declared.
public class ClassA {public ClassA()
{
// Initilize code in the constructor.
}
}