1. We can give any suitable name to function but constructor name will be the name of class.
In the following example you can see that i have created constructor pqr which is on the name of class but i have created function with the name of sum().
public class pqr
{
public int p, q;
public pqr()
{
p = 10;
q = 20;
}
public int sum()
{
return (p + q);
}
}
2. Function have return type but constructor don't have return type not even void.
//constructor
public pqr()
{
p = 10;
q = 20;
}
// function
public int sum()
{
return (p + q);
}
3. Constructor calls once at the time of object creation but funcation can be called with object and without object(static funcation) many times.