Ang Imhr.ca ay tumutulong sa iyo na makahanap ng mga sagot sa iyong mga katanungan mula sa isang komunidad ng mga eksperto. Kumuha ng mabilis at mapagkakatiwalaang mga solusyon sa iyong mga tanong mula sa mga bihasang propesyonal sa aming komprehensibong Q&A platform. Tuklasin ang malalim na mga sagot sa iyong mga tanong mula sa isang malawak na network ng mga propesyonal sa aming madaling gamitin na Q&A platform.

What is POLYMORPHISM in JAVA Programming Panguage ?

Sagot :

The polymorphism principle is basically have a parent class and creating subclasses (children) that have almost the same functionality or are similar to the parent class but are unique in their own way.

For example you have an animal. There are many types of animals but they have some similar characteristics for example, let's say that all animals need to eat and sleep and they all have names. So the parent class, Animal, would have those eat and sleep methods.

public class Animal{
public void sleep();
public void eat();
}

But there are many types of animals such as birds, fish, etc. They have unique characteristics. So the children subclasses for example could look like this.

public class Bird extends Animal{
public void fly();
}

and a fish subclass could look like this...

public class Fish extends Animal{
public void swim();
}

The subclasses inherits the methods of Animal and add their own unique twist to it. :)
Pinahahalagahan namin ang iyong pagbisita. Sana'y naging kapaki-pakinabang ang mga sagot na iyong natagpuan. Huwag mag-atubiling bumalik para sa karagdagang impormasyon. Umaasa kaming nahanap mo ang hinahanap mo. Huwag mag-atubiling bumalik sa amin para sa higit pang mga sagot at napapanahong impormasyon. Bumalik sa Imhr.ca para sa karagdagang kaalaman at kasagutan mula sa mga eksperto.