In what situation does a method return a value?
60 Likes
For a method to return a value, it should have a return type other than void in its method prototype and it should return a value of the corresponding type using the return statement in the method body.
Answered By
37 Likes
Write down the main method which calls the following method:
int square(int a) { return(a*a); }
What happens when a method is passed by reference? Explain.
Differentiate between pure and impure methods.
Write a method which is used to swap the values of two memory locations by using a third variable.