Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Not Understanding Polymorphism

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    7
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Not Understanding Polymorphism

    Hello,

    The past week or 2, I've been trying to understand polymorphism, but i don't understand it still. Can someone give me good definition of polymorphism and if possible an example please ...


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Not Understanding Polymorphism

    Polymorphism basically is treating one type of object as another.

    For example, a car is an automobile. A truck is also an automobile. thanks to polymorphism, we can treat a car as an automobile, and we can also treat a truck as an automobile. A boat is not an automobile. This allows us to write generic code which works for any type of automobile, and nothing else. We could even use a more generic category for vehicle which would include automobiles, boats, and airplanes.

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    7
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Not Understanding Polymorphism

    Quote Originally Posted by helloworld922 View Post
    Polymorphism basically is treating one type of object as another.

    For example, a car is an automobile. A truck is also an automobile. thanks to polymorphism, we can treat a car as an automobile, and we can also treat a truck as an automobile. A boat is not an automobile. This allows us to write generic code which works for any type of automobile, and nothing else. We could even use a more generic category for vehicle which would include automobiles, boats, and airplanes.
    Thank Your very Much for your reply, I understand what you've written but I don't understand how I would put that example into code form, could I you produce that example in code form please.

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Not Understanding Polymorphism

    Thread moved from "Whats wrong with my code?"

  5. #5

  6. #6
    Junior Member
    Join Date
    Jul 2013
    Posts
    7
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Not Understanding Polymorphism

    Quote Originally Posted by jps View Post
    Thread moved from "Whats wrong with my code?"
    ok thats fine

Similar Threads

  1. Polymorphism Question
    By BuhRock in forum Java Theory & Questions
    Replies: 1
    Last Post: October 1st, 2012, 11:09 AM
  2. Polymorphism.
    By TP-Oreilly in forum Java Theory & Questions
    Replies: 2
    Last Post: March 11th, 2012, 09:28 AM
  3. Polymorphism Question
    By kutysam in forum Java Theory & Questions
    Replies: 11
    Last Post: August 30th, 2011, 11:59 AM
  4. Polymorphism test
    By speedycerv in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 29th, 2011, 07:15 AM
  5. Polymorphism issue
    By LDM91 in forum Java Theory & Questions
    Replies: 5
    Last Post: November 28th, 2010, 03:26 PM