Results 1 to 6 of 6

Thread: Polymorphism VS Inheritance

  1. #1
    Join Date
    Dec 2009
    Posts
    18

    Polymorphism VS Inheritance

    I am intermediate programmer in the programming world. Right now i am studying the programming languages: C++, C#, Java, Html and SQL. I have understood the basic OOP(object oriented programming) principles very well, but when it comes to programming i want to know the actually difference between the Polymorphism and Inheritance, and which one is better? Please help me.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Polymorphism VS Inheritance

    I think many people get confuse between this two(Polymorphism and Inheritance) OOP principles. They both are really differ from each other. The one of the major difference is that by using Inheritance for class level we can achieve the re-usability and whereas by using Polymorphism for processing objects differently depending on their class, becomes quite useful. Hope your problem will be fix.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Polymorphism VS Inheritance

    You asked very good question. This query or doubt will always be there to new person in the programming languages/world. The Polymorphism differs vastly to the Inheritance, they both are very dissimilar, but yet confuse people to understand about it. According to me, one main difference is the polymorphism is use for overloading(means method with same name but different parameter) and whereas the inheritance is used for Overriding(means methods with same and parameters, 2nd method hides or over ride the another method).

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Polymorphism VS Inheritance

    Inheritance: It is the mechanism that allows to generalize or specialize classes into hierarchy's, and the base class is said to be most generic, while the classes which is getting inheriting from the base class adding some specialization.
    Polymorphism: It is the ability which allows us to use an object without knowledge what its type is, only by using the base class as a type and being able to call method (virtual method) for it.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Polymorphism VS Inheritance

    Yes, there is difference between Polymorphism and Inheritance. Their function are very different and are equally important in the programming the world, without this both function programming becomes useless. I would give you the simple example to understand the difference in them:
    abstract class Father
    {
    }

    class Son : Father
    {
    }

    class Daughter: Father
    {
    }

    Son and Daughter are examples of Inheritance.

    Father f1 = new Son();
    Father f2 = new Daughter();

    This is an example of polymorphism. Class Father is "polymorph" - it can take multiple form

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Polymorphism VS Inheritance

    I think this question will make everyone confused, because one can do argument on sharing method attributes between the super or the abstract class with a derived class could be described by either using the Polymorphism or Inheritance. We can significantly do difference by telling when or under what circumstances you would you use one or the other. Inheritance can be used when you want to make an whole new class, but you want to take a group of few existing attributes or methods resident in an existing Abstract or super Class. While, Polymorphism can be used best when you to apply an existing SubClass that you wants to modify or add a feature that will take a method that is existing in a higher class.

Similar Threads

  1. Replies: 3
    Last Post: 08-01-2011, 06:32 AM
  2. Inheritance and polymorphism in static method
    By Vodka in forum Software Development
    Replies: 5
    Last Post: 04-03-2010, 11:46 AM
  3. What does polymorphism mean in OOP?
    By Khan Baba in forum Software Development
    Replies: 5
    Last Post: 06-02-2010, 02:14 PM
  4. Runtime polymorphism Vs Compile time polymorphism
    By Owen Fernandes in forum Software Development
    Replies: 4
    Last Post: 03-02-2010, 11:06 AM
  5. Polymorphism in SQL database
    By cobra2008 in forum Software Development
    Replies: 2
    Last Post: 04-04-2009, 09:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,930,941.90159 seconds with 17 queries