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 the purpose of encapsulation?

667


What are scalar data types?

628


Can inner class extend any class?

738


What does next mean in java?

661


Is 0 true or false in java?

647






What is a byte string?

747


What is static variable with example?

689


What is bufferedwriter?

677


What do you know about the garbate collector?

724


Explain the overview of UDP messaging.

865


What is the do while loop syntax?

676


What is the purpose of stub and skeleton?

674


What is the use of arraylist class in java?

681


Can we assign null to double in java?

689


Can variables be used in java without initialization?

681