Explain Polymorphism in java

Posted on 2011-10-18
Last Modified: 2013-11-24
Explain Polymorphism in java
Question by:stmani2005
    1 Comment
    LVL 47

    Accepted Solution

    Polymorphism means that if you have

    class A {
    void method1() {
    // some stuff


    class B extends A {

    void method1(){
    //anotyher stuff


    now somewhere in you code you'll create instance

    A  b = new B();

    in this case //another stuff will be executed, not //some stuiff

    this is callled polymorphism - when instance was created as subclass
    and it excutes metyhod which is overriden in scbclass it will always
    execute the stiff in the method of subclass, not in the method of class

    let me know if there ias somethiong not clear about it


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
    Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now