224k views
0 votes
What is the relationship between a method and a function

2 Answers

6 votes
A function is a piece of code that is called by name. It can be passed data to operate on (i.e. the parameters) and can optionally return data (the return value). All data that is passed to a function is explicitly passed. A method is a piece of code that is called by a name that is associated with an object
User Payam Shakibafar
by
4.4k points
2 votes

Answer:

Method and a function are the same,whit the different terms. A method is a procedure or function in object - oriented programming. A function is a group of reusable code which can be called anywhere in your program. This eliminates the need for writing the some code again and again.

User DonutReply
by
5.4k points