Total members 11894 |It is currently Thu Nov 21, 2024 9:53 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





What is Polymorphism?
----------------------------


Polymorphism gives us the ultimate flexibility in extensibility. Polymorphism is a term that describes a situation where one name may refer to different methods. In java there are two type of polymorphism: overloading type and overriding type.

When you override methods, java determines the proper methods to call at the programs run time, not at the compile time. Overriding occurs when a class method has the same name and signature as a method in parent class. Overloading occurs when several methods have same names with different method signature. Overloading is determined at the compile time.

Example: Overloading

java code
Class Book{
String title;
String publisher;
float price;
setBook(String title){
}
setBook(String title, String publisher){
}
setBook(String title, String publisher,float price){
}
}


Example: Overriding

java code
Class Tool{
void operate_it(){
// implementation here.
}
}
Class ScrewDriver extends Tool{
void operate_it(){
// implementation here.
}
}




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 109
Have thanks: 5 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : What is Polymorphism?!!
 polymorphism     -  
 run time polymorphism     -  
 Inheritance & polymorphism checker code     -  



Topic Tags

Java OOP
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com