+ 15
What Is Polymorphism???
C++
8 Answers
+ 18
In object-oriented programming,polymorphism (from the Greek meaning "having multiple forms") is the characteristic of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
+ 8
It's the ability of an object to take many forms. mainly used when a super class reference is used to refer sub class object. In general we have run time polymorphism & compile time polymorphism.
Ex:
1.Run time polymorphism
class A {
public void show (){
System.out.println("In class A");
}
class B extends A {
public void show (){
System.out.println("In class B");
}
class main {
public static void main(string [] args){
B obj=new B();
obj.show ();
}
}
output :In class B
2.compile time polymorphism
class A {
public void show (){
System.out.println("default");
}
public void show(int i){
System.out.println ("parameterized ");
}
}
class main {
public static void main (string args []){
A obj=new A();
obj.show ();
}
}
output :default
+ 6
Thanks To All For Helping Me..đđđ
+ 4
It's simply the ability of a variable, function or object to take on multiple forms.For example,in a programming language that exhibits polymorphism,object of classes belonging to the same hierarchicalâ tree may process functions bearing the same name,but each having different behaviors.
+ 2
it is the feature of c++ ...object oriented programming ...polymorphism it means in Greek word ( having multiple forms ) it is done by two forms 1 function overloading ..2 . operator overloading
+ 2
Polymorphism is a OOPs concept where one name can have many forms.
For example, you have a smartphone for communication. The communication mode you choose could be anything. It can be a call, a text message, a picture message, mail, etc. So, the goal is common that is communication, but their approach is different. This is called Polymorphism.