Returning From A Function

When a function is called, controls are sent to the function. As function finishes its execution, controls are sent back to the caller code. When a function terminates after accomplishing some work, its controls with that work or some value are returned to the caller code. The return type specifies the type of value returned by the function. The return statement is useful in two ways: for immediate exit from a function and to return a value to the calling code.

A function may contain several return statements. However, only one of them gets executed. The return statement can be used even if the function does not return any value. Constructor is a function with the same name as that of the class name. It is invoked automatically as the object of the class is created. Constructor in Java does not have a return type. A class in Java can have many constructors but with different signatures.

To Access the full content, Please Purchase