Polymorphism
Polymorphism
- The process of calling the sub class methods by using the super class reference with the help of Overriding,Inheritance and Casting concepts.
- After we override a method of a super class inside a subclass,we can do casting and then through the super class reference,we can call the sub class method.
- We can perform many tasks in different classes by using this concept.
- This simply means "Many Forms".
- Assume that there is a company.It stores Biscuits and Cakes seperately.For that we have to develop a system to store them in the correct manner.
- As Java is a compiler,it executes its codes line by line.
- Now if we have either cakes or biscuits,the should have to store in their correct places.
- So for that we can use polymorphism with casting,inheritance and method overriding concepts.
- We can create seperate objects for those sub classes.
- Super class is called and then the sub class is executed.
This is a simple idea about how we can use polymorphism practically.
Comments
Post a Comment