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

Mention some interfaces implemented by linked list in java.

536


What does null mean in java?

627


Can we create object of static class?

528


How garbage collection is done in java?

550


How to reverse a string in java?

522






What is method in research paper?

573


Differentiate between static and non-static methods in java.

561


what is aggregation in java?

584


Is class is a data type?

571


How many types of methods are there?

546


What is the Concept of Encapsulation in OOPS

556


What is the difference between a loader and a compiler?

525


Is boolean a wrapper class in java?

600


What is the difference between the final method and abstract method?

539


Why lambda expression is used in java?

568