can any one explain clearly what is the difference between the Method and a Function, if possible by using some syntax and examples.
can any one explain clearly what is the difference between the Method and a Function, if possible by using some syntax and examples.
no difference according to me...
method is OO concept related to class
i.e. function written for a class = method
this is my wild guess...
as per my knowledge it hardly makes any difference.
Hi,
method should declares and defines within the class only. so it has access controlling mechanism. used in oops.
function declares and defines anywhere in the code. it has not access controlling. used in structured language.
even behavior is same.
thanks
hi,
In java function is call itself as a method.... there is not any difference in those thng.... it just using of terms...like in c++ we call it functins..and in java we call it as methods. In more simple terms Method does not take any arguement and it is invoked by method call
whereas function may or may not take the arguements?
Also Method does't return any thing but the function can return any thing
Thanks
Sushma
both r same but method does't return any thing and function returns any thing
Hi,
method should declares and defines within the class only. so it has access controlling mechanism. used in oops.
function declares and defines anywhere in the code. it has not access controlling. used in structured language.
even behavior is same.
thanks
Function and Method both are same. But if it is declared outside of class it is function and if it is declared within class that is method.
In case of C++ it will support both functions and methods
But In case of Java there is no Functions concept only method is alloed.
METHODS FUNCTIONS
1.METHODS CALLED BY REFERENCE 1.FUNCTIONS DO NOT HAVE ANY REFERENCE
VARIABLES VARIABLES
2.METHOD DOES NOT RETURN VALUE 2.FUNCTION GIVES RETURN VALUE
AS SUBROUTINE(OR) PROCEDURE
3.IT IS IMPLICITLY PASSED THE 3.ALL DATA THAT IS PASSED TO A FUNCTION
OBJECT FOR WHICH IT WAS CALLED IS EXPLICITLY PASSED
4.IT HAS ACCESS CONTROLLING 4.IT HAS NOT ACCESS CONTROLLING i.e.,METHOD SHOULD MECHANISM i.e.,FUNCTION DECLARES AND
DECLARES AND DEFINES IN THE DEFINES ANY WHERE IN THE CODE
CLASS ONLY
SIVA REDDY(ANITS- 3/4 IT): Differences Between Method and Function
METHODS :
1.METHODS CALLED BY REFERENCE VARIABLES
2.METHOD DOES NOT RETURN VALUE AS SUBROUTINE(OR) PROCEDURE
3.IT IS IMPLICITLY PASSED THE OBJECT FOR WHICH IT WAS CALLED
4.IT HAS ACCESS CONTROLLING i.e.,METHOD SHOULD DECLARES AND DEFINES IN THE CLASS ONLY
FUNCTIONS:
1.FUNCTIONS DO NOT HAVE ANY REFERENCE VARIABLES
2.FUNCTION GIVES RETURN VALUE
3.ALL DATA THAT IS PASSED TO A FUNCTION IS EXPLICITLY PASSED
4.IT HAS NOT ACCESS CONTROLLING i.e.,FUNCTION DECLARES AND DEFINES ANY WHERE IN THE CODE
The terms method, function, procedure, subroutine, and subprogram are all roughly synonymous, although the term function is generally reserved for a subroutine that returns a value. Some languages like Fortran use slightly different syntax to define functions vs. procedures. For my part, I tend to use method when I'm talking about a subroutine that's a class member and function for subroutines that aren't class members, regardless of whether they return a value or not.