4

What is the difference between

extends(inheritance)

and

override(polymorphism)

?

Heisenbug
  • 38,762
  • 28
  • 132
  • 190
Benny
  • 2,250
  • 4
  • 26
  • 39
  • Check out this discussion for further reference http://stackoverflow.com/questions/154577/polymorphism-vs-overriding-vs-overloading – abhiasawa Jun 27 '11 at 12:35
  • Also this seems to be an accurate distinction http://wiki.answers.com/Q/What_is_the_difference_between_inheritance_and_polymorphism – abhiasawa Jun 27 '11 at 12:37
  • 1
    Don't get why this was downvoted. Although it may be a elementary question it was clear and to the point. +1 to offset the ridiculous downvote. –  Jun 27 '11 at 12:42
  • @inium : Inheritance supports class level reuse of existing code.... Overriding supports method level modification with the same signature.... Is Inheritance doesn't support method modification? – Benny Jun 27 '11 at 12:45
  • 1
    @Ascension Systems: Thanks for your care. | I am novice to as3, that's y making elementary questions something like this. – Benny Jun 27 '11 at 12:51
  • 1
    No problem, it wasn't meant as an insult (saying elementary). When I started working in flash I just started out in programming and didn't know the first thing. In fact when I went for my first job interview as a flash developer I didn't even know the key concepts of OOP. lol –  Jun 27 '11 at 13:00

3 Answers3

8

Extends: we create a new class(Inherited class) with the features of Existing (class Base class) and some additional features. This comes in picture in case of inheritance.

Example: NokiaBasic Handset. NokiaNSeries(Extends the features of NokiaBasic Handset features)

Overriding: comes to picture when functionality changes in the derived class. We override the functionality of a particular function in a derived class(Dynamic Polymorphism).

Example: All the functionality which NokiaBasicHandset has, are implemented in NokiaNSeries but there is a difference in the way we operate. (Picking a call, sending a message, sharing a file, etc.)

viveknaskar
  • 2,136
  • 1
  • 20
  • 35
Pearl
  • 526
  • 3
  • 9
  • 13
5
  • Extends is about classes. This keyword represents the process of deriving a subclass from a base class.
  • Overriding is about methods declaration and invocation. It means to define a method in a subclass with the same signature of a method previously declared in its base class.
Heisenbug
  • 38,762
  • 28
  • 132
  • 190
2

Extends: you're inheriting all the functionality of the object you are inheriting from Override: you're changing/adding to the functionality of something you have inherited

mikeq
  • 817
  • 5
  • 5