?
Solved

Polymorophism

Posted on 2003-03-30
9
Medium Priority
?
187 Views
Last Modified: 2010-03-31
Hi:
   Can someone show/explain how a static method can demonstrate polymorphism?  
0
Comment
Question by:LearningJava
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 8235284
You can still extend static methods...

...is this an exam question?  

Hmmm...

I hear the EE police coming...
0
 

Accepted Solution

by:
purrbert earned 750 total points
ID: 8235444
Hi,

Say I've created a class with methods...

public class Customer {
   private String _name;
   private String _address;

   // method 1
   public void Delete(){
      ....}
   // method 2
   public boolean Delete(Customer ct) {
      ....}
}

Notice that within my class, I have 2 methods named "Delete".  How can I do that?  Polymorphism!
One method (2) will let you pass the Customer instance to it and perform some operation (denoted by the ....).  The other will Delete the "current" customer.
If you are familiar with other programming languages, the methods are like functions.  However, in other languages,
you can't have 2 functions that are named the same but will accept different input parameters.  Thus the power of Java.
If you are confused by the "current" customer comment, it refers to the keyword "this".  If that is confusing let me know.

Hope this helps!
Jill
0
 

Author Comment

by:LearningJava
ID: 8235463
No! This is not an exam question.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 8235486
So your question was "What is Polymorphism?"
0
 

Expert Comment

by:purrbert
ID: 8235519
I didn't care if it was an exam question or not.
Tim, was my explanation appropriate?  I used "this".. even though I used in incorrectly in my own inquiry.
LearningJava, did you understand my explanation?
Jill
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8235531
Yeah, I had forgotten exactly what polymorphism was ;-)

hee hee...ignoe me, it's past my bed time >_<
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8235532
Bah...see what I mean >_<

ignoe==ignore
0
 

Author Comment

by:LearningJava
ID: 8235567
Yes, the explanation was adequate.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8237745
 You can find a nice explanation of polymorphism here: http://www.javaworld.com/javaworld/javatips/jw-javatip30.html as well. Also a nice article on parametric polymorphism (polymorphism obtained through parameters what purrbert explained essentially): http://www.javaworld.com/jw-02-2000/jw-02-jsr.html but you might find it a bit too advanced.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question