answersLogoWhite

0

Where to use polymorphism?

Updated: 12/21/2022
User Avatar

Wiki User

10y ago

Best Answer

Polymorphism is used whenever you wish to achieve specific behaviour from a generic object, where the object's actual type may not be known or would be impossible to determine at compile time. By declaring virtual methods in the generic type (the base class), and overriding them in the derived type, you ensure that the derived object does "the right thing" regardless of its actual type, and regardless of whether the method is called directly or indirectly via the base class. With polymorphism, there is no need to determine the actual runtime type of the object, you get that for free simply by calling the appropriate virtual methods.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Where to use polymorphism?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Polymorphism in coelentrates?

polymorphism in coelentrates


How can be different forms of polymorphism achieved?

Implicit Parametric PolymorphismSubtype PolymorphismExplicit Parametric Polymorphism


What do you use if you want to ensure that all methods and properties are implemented?

polymorphism


What is polymorphism and its types?

Polymorphism means multiple form of a function, variable or object. In Computer Science, polymorphism is a programming language feature that allows values of different data types to be handles using a common interface. There are three types : Ad-Hoc Polymosphism, Parametric Polymorphism, Subtype/Inclusion Polymorphism. Source: Wikipedia.


What kind of drugs commonly has polymorphism?

Polymorphism is common with barbiturates, steroids, and sulphonamides.


Is polymorphism exist between prokaryotes?

Yes, polymorphism exists between the prokaryotes.


What is Difference between dynamic polymorphism and static polymorphism with example?

Static polymorphism is used the concept of early binding or we can say compile time binding where as dynamic polymorphism used the concept of late binding or run time binding.


How can one detect polymorphism by genetic marker?

One can detect polymorphism by genetic marker using single-nucleotide polymorphism which is able to even tell mutation of a gene.


What is drug polymorphism?

Drug polymorphism is a customerÕs variation in response to a drug is by gender, body composition, size and age. The first polymorphism was first labelled over 40 years ago.


Define compile time polymorphism with short examples?

compiler can decide which form of the object should be invoked during compile time.this type of polymorphism is know as compile time polymorphism


Is Interfaces in Java a kind of polymorphism?

No. Interfaces in Java are a construct to get polymorphism ( subtype polymorphism ) working in Java, but they are not a "kind" of polymorphism. In polymorphism happens when two objects respond to the same message ( method call ) in different way ( hence poly -> many, morphism -> way or shape : polymorphism -> many ways). In Java to be able to send the same message to two different objects you have to either inherit the same parent, or implement the same interface.


In what study would one find polymorphism?

Polymorphism is the changing of one subject to an altered state. There are actually two areas of study where polymorphism would be particularly common: chemistry and web programming.