CSC/ECE 517 Fall 2007/wiki2 8 c9: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 2: Line 2:


Overloading vs. overriding. Skrien delineates the difference between overloading and overriding in Section 2.8. He does this in the context of Java. How do other languages make this distinction, especially those like CLOS that define multi-methods?
Overloading vs. overriding. Skrien delineates the difference between overloading and overriding in Section 2.8. He does this in the context of Java. How do other languages make this distinction, especially those like CLOS that define multi-methods?
</b>Polymorphism</b>
  Polymorphism is usually expressed by the phrase “One interface, multiple methods”. This allows a super class to specify methods that will be common to all of its subclasses, while allowing the subclasses to define their own specific methods.
It means design a generic interface and use it for group of related activities. This helps reduce complexity by allowing the same interface to be used to specify a general class of action. It is the compiler’s job to select the specific action (that is, method ) as it applies to each situation.
<b> Overloading</b>
  In Java it is possible to define 2 or more methods within the same class that share the same name, as long as their parameter declarations are different. The methods are said to be overloaded. This process is referred as method overloading. It is one of the way by which java implements polymorphism.Java uses the type and /or number of arguments to determine which of the overloaded methods to be overloaded. The overloaded methods may differ in return type or the number of parameters in the method call.

Revision as of 17:34, 21 October 2007

                                                Topic 8 : Overloading Vs Overriding

Overloading vs. overriding. Skrien delineates the difference between overloading and overriding in Section 2.8. He does this in the context of Java. How do other languages make this distinction, especially those like CLOS that define multi-methods?


Polymorphism

  Polymorphism is usually expressed by the phrase “One interface, multiple methods”. This allows a super class to specify methods that will be common to all of its subclasses, while allowing the subclasses to define their own specific methods.

It means design a generic interface and use it for group of related activities. This helps reduce complexity by allowing the same interface to be used to specify a general class of action. It is the compiler’s job to select the specific action (that is, method ) as it applies to each situation. Overloading

  In Java it is possible to define 2 or more methods within the same class that share the same name, as long as their parameter declarations are different. The methods are said to be overloaded. This process is referred as method overloading. It is one of the way by which java implements polymorphism.Java uses the type and /or number of arguments to determine which of the overloaded methods to be overloaded. The overloaded methods may differ in return type or the number of parameters in the method call.