Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Fresher Job


 

Search Host

Monthly Fee($)
Disk Space (MB)
Register With us for Newsletter!
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

Tutorials

Java Server Pages

JAXB

Java Beans

JDBC

MySQL

Java Servlets

Struts

Bioinformatics

Java Code Examples

Interview Questions

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Web Promotion

Web Submission

Submit Sites

Manual Submission?

Web Promotion Guide

Hosting Companies

Web Hosting Guide

Web Hosting

Linux

Beginner Guide to Linux Server

Frameworks

Persistence Framework

Web Frameworks

Free EAI Tools

Web Servers

Aspect Oriented Programming

Free Proxy Servers

Softwares

Adware & Spyware Remover

Open Source Softwares

core java - Use of polymorphism in object oriented programming
Expert:harikrishna
<p>Hi all, I am digging for an example of polymorphism in object orient programming. Can anyone please help?</p>
Answers
Use of polymorphism in object orient programming – using Overloading and Overriding Concept<br /><br />Polymorphism<br />It is a basic feature in OOP’s Strategy of programming emulated or being followed by high-level languages .<br />In java it states using of one single interface with a set of actions that is like one name may be referred to different functionality .<br /><br />For example in creating a java program we create method<br /> void Amount( )<br />{<br /> -----<br /> -----<br />}<br /><br />Amount (int xyz)<br />{<br /> ---<br /> ---<br />}<br />Amount(int cat)<br />{<br />}<br /><br />Now see carefully here in the small brackets of same method I have assigned three different”int amt, int xyz, int cat” parameters<br />(parameters are value data like that we assign in method)<br />this is called Overloading <br /><br />And in case of same parameters it is said Overriding.<br /><br />See In both cases method “Amount()” is being more than one time and this what above definition say “using of one single interface with a set of actions”.<br /><br />For further details with examples concerning Encapsulation, Inheritance and Polymorphism chech undersigned URL.<br /><br /><a href="http://www.roseindia.net/java/learn-java-in-a-day/oops.shtml"; target="_blank">http://www.roseindia.net/java/learn-java-in-a-day/oops.shtml</a><br /><br /><br />BaadshahKhan
What is polymorphism?what is the exactly use of it?how we can use polymorphism in object orient programming.<br /><br />Polymorphism :-<br /><br />Polymorphism means the ability to take more than one form. Polymorphism means 'any forms.' In OOP, it refers to the capability of objects to react differently for the same method.<br /><br />In OOP methodoverloading refers to the capability of objects to react differently for the same method. Polymorphism can be implemented in Java language in form of multiple methods having the same method name. Java code uses a late-binding for supporting polymorphism, the method which is invoked is decided at runtime.<br /><br />In polymorphism by using a same function name with the different signature we can perform the multiple task this is called method overloading &amp; using a same function name with the same signature we can extend the functionality of the superclass functions according to our requirement.<br /><br />In java Polymorphism can be used in two ways :<br /><br />1. Method Overloading<br /><br />2. Method Overriding <br /><br />1. Method Overloading :-<br />Overloaded methods are methods have the same name, but different argument lists. <br />Overloaded methods have the same names but different argument lists. The arguments may differ in type or number, or both. However, the return types of overloaded methods can be the same or different. <br /><br />An example of the method overloading is given below:<br /><br />class methodOverloading{<br />int add( int a,int b)<br />{<br />return(a+b);<br />}<br /><br />float add(float a,float b)<br />{<br />return(a+b);<br />}<br />double add( int a, double b,double c)<br />{<br />return(a+b+c);<br />}<br />}<br />class mainClass extends methodOverloading <br />{<br />public static void main( String arr[] )<br />{<br />mainClass temp = new mainClass();<br />System.out.println(temp.add(10,20));<br />System.out.println(temp.add(1.5f,2.3f));<br />System.out.println(temp.add(10,20.4,25.6));<br />}<br />}<br /><br /> The output of the above program is given below:<br /><br />30<br /><br />3.8<br /><br />56.0<br /><br />2. Method Overriding :-<br />Overriding means when a subclass method has the same name, same return type, and same argument list as the superclass method.<br /><br />class methodOverriding<br /><br />{<br />String showMessage()<br />{<br />return(&quot;THIS IS SUPERCLASS METHOD&quot;);<br /><br />}<br />}<br />class mainClass extends methodOverriding <br />{<br />public static void main( String arr[] )<br />{<br />String showMessage()<br />{<br />System.out.println(&quot;THIS IS SUBCLASS METHOD&quot;);<br />}<br />mainClass temp = new mainClass();<br />System.out.println(temp.showMessage());<br />}<br /><br />}<br /><br />The output of the above program is given below:<br /><br />THIS IS SUBCLASS METHOD
More Questions
Post Answers
 
Ask Question Facing Programming Problem?
Useful Links
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.