Results 1 to 4 of 4

Thread: Is java supports polymorphism?

  1. #1
    Join Date
    May 2008
    Posts
    69

    Is java supports polymorphism?

    Hi friends,

    I just started the java programming. I want to know that , Is java supports to the polymorphism?

    Can you explain what is polymorphism and how it can be implemented in JAVA language with suitable example.

    Your help greatly appreciated...

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

    Re: Is java supports polymorphism?

    Hi,

    Obviously java supports polymorphism. Because JAVA is fully object oriented language.

    Below details will give you the idea about polymorphism:

    Polymorphism gives the ultimate flexibility in extensibility. Polymorphism describes a situation in which one name might refer to other different methods.

    Basically in java supports two type of polymorphism:
    1. overloading type.
    2. overriding type.

    When you override any methods in java, java determines the proper methods to call at the run time.

    Overriding occurs when a class method has the same name and signature as a method in base class it is called as overriding.

    Example of Overloading:
    Class Book{
    String title;
    String publisher;
    float price;
    setBook(String title){
    }
    setBook(String title, String publisher){
    }
    setBook(String title, String publisher,float price){
    }
    }
    Example of Overriding:

    Class Book{
    String title;
    String publisher;
    float price;
    setBook(String title){
    }
    setBook(String title, String publisher){
    }
    setBook(String title, String publisher,float price){
    }
    }

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

    Re: Is java supports polymorphism?

    Polymorphism is the one of the basic feature of the OOP(Object Oriented Programming).

    And I think you are not aware that java is object oriented language,So there is no doubts that java supports polymorphism concept.

    I don't have that much knowledge about this concept But I know that "polymorphism means when an entity behaves entirely different depends upon the context in which it is being used."

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

    Re: Is java supports polymorphism?

    Hello friends,

    Polymorphism stands for Poly(Many) + morhism(foru) which means that multiple forms.
    It is an Object oriented language feature through which multiple things can be done with only one program code by changing its input parameters only.

    Java supports polymorphism concept through method overloading and method overriding.

    refer following example:

    public class MountainBike extends Bicycle{
    private String suspension;

    public MountainBike(int startCadence, int startSpeed, int startGear, String suspensionType){
    super(startCadence, startSpeed, startGear);
    this.setSuspension(suspensionType);
    }

    public String getSuspension(){
    return this.suspension;
    }

    public void setSuspension(String suspensionType){
    this.suspension = suspensionType;
    }

    public void printDescription(){
    super.printDescription();
    System.out.println("The MountainBike has a " + getSuspension()
    + " suspension.");
    }
    }

Similar Threads

  1. Is Nokia N9 supports Java MIDP 2.1?
    By Bhuvnesh 1 in forum Portable Devices
    Replies: 4
    Last Post: 21-01-2012, 12:32 AM
  2. Dynamic and Static Polymorphism in Java
    By Ardent in forum Software Development
    Replies: 4
    Last Post: 19-08-2010, 03:37 PM
  3. Runtime polymorphism Vs Compile time polymorphism
    By Owen Fernandes in forum Software Development
    Replies: 4
    Last Post: 03-02-2010, 11:06 AM
  4. Is Sony Ericsson K530i supports JAVA Application ?
    By Omesh in forum Portable Devices
    Replies: 2
    Last Post: 06-06-2009, 09:36 PM
  5. Run - Time polymorphism with Overriden method in JAVA
    By NAYASA in forum Software Development
    Replies: 1
    Last Post: 04-12-2008, 07:11 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,714,025,870.86267 seconds with 17 queries