write three advantages of using method in a program
plz don't scam
Answers
Explanation:
Methods are a cluster of operations that a type (or object) provides. Generally easier to go through all functions that something is passed over. Similarly, it provides a kind of namespace. In the above example “add” is too vague for free function form, so it may have to be named like “addContact”, but you don’t need that in the former since contactList (or its type) works like a namespace.
Better for hiding information. Above contactList may have internal state that should be accessible in add() method. In the latter free function case, the internal state has to be accessible by add function, and does that mean that’s accessible by ANY functions? Of course there are other ways like package level information hiding in some languages, having methods is a reasonable way to implement this.
Polymorphism and duck-typing though having method isn’t the only way to implement them. Imagine you are getting whatever that has add method with 2 string args and call whatever.add(“John”, “222–333–4444”). There could be multiple implementation of whatever and having add() as a method is much cleaner than a single free function with select-case for each type of the first argument. Of course function overloading can solve this issue and methods doesn’t work nicely for branching for multiple arg combinations, but it’s a pretty good simple solution.
hope it's help full
mark as brainlist answer and follow me I will follow u
i ) Methods provide the means to avoid duplication of code and helps in code reusability.
ii) They help divide complex programs into manageable code blocks.
iii) They help us understand the flow of a program
Hope it helps you this in not copied from Google or any other websites