This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of React Cookbook: Recipes for Mastering the React Framework and have David Griffiths & Dawn Griffiths on-line!
See this thread for details.
Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Polymorphism

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can we achieve Polymorphism in java

1)overriding
2)overloading

or both 1 and 2
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Polymorphism In Java
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
still i don't have clear idea is both overloading and overriding support Polymorphism??

 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

aruna sameera wrote:still i don't have clear idea is both overloading and overriding support Polymorphism??


Polymorphism - Many Forms.

So one method exhibit and behave in many forms.

In both(Overloading and Overridng), same method name will show different results as per the object who calls it(method overriding) and as per method parameters passed(method overloading).

Can you make any example from it?
 
Ranch Hand
Posts: 492
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Polymorphism is derived from the chains of inheritance in Java. Inheritance shows a relationship between two or more classes in which the parent class (also called the superclass) passes attributes and methods to the child class (also called the subclass).

Example:
You have three classes: Insect, Termite, and Bee;
In inheritance the more broad term is always the Parent class, so in this case the Parent class is Insect; because insect can apply to any number of different types of insect.

The two child classes (Termite and Bee) inherit attributes and methods from the Parent class (Insect).









Output of testInsects:
The bee flys away
The termite crawls away

Name: Bee hasWings: true
Name: Termite hasWings: false


Hope this helps.

Hunter M.

(Please note I'm not sure if Termites do or do not have wings but for this example, let's just assume they dont )
 
You guys haven't done this much, have ya? I suggest you study this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic