why constructor dont have returns type?

Answer Posted / vishwanath

because it is called implicitly when object is created... so it doesn't have any target to return values....
for ex..
int v=Integer.parseInt(X.readLine());
int n=fact(v);
int fact(int)
{
.....return ans
}
so it return ans to the variable n which is assigned to calling statement..... when compared the constructor don't have any target to return

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is runtime polymorphism or dynamic method dispatch?

513


How to set the permissions to a file in java?

529


What is java in simple terms?

544


What does a void function return?

539


What is a java list?

572






What is Session reduplication and how its done?

1558


Is 0 a prime number?

559


Can we declare array without size in java?

541


Explain the importance of throwable class and its methods?

561


What is the difference in between cpp and java? Can u explain in detail?

598


How many bits is a string?

517


How do generics work in java?

514


What is the difference between equals() and == in java?

517


Explain the difference between intermediate and terminal operations in java8?

559


Can we override private methods?

536