Difference between method and function in oops

Object oriented languages or oops is the most reliable source of technical aspect that is being used in each and every technical operations. Now, there are many languages that offer the advantages of object oriented aspect such as java, python etc. Now, here comes the tricky part, do you know what is the difference between method and function in oops?

Let’s discuss the difference between method and function in oops and remove the ambiguity that we were facing:

  • method is just a piece of code that is called by the name with which it is associated with an object. 

  • function is a piece of code that is called by a name.

  • A function is on an object while a method is independent of an object.

  • Functions are defined outside the classes, while the method is defined inside and are part of classes.

  • Here,  myObj.work is a method.

  • Here, myFun is a function.

So, these were the difference between method and function in oops. Do share the knowledge.

  • Add Your Comment