Solved

Example of Polymorphis

Posted on 2006-06-11
3
240 Views
Last Modified: 2010-03-31
For the Class "Date" give examples of Polymorphis.  I can not find one example I will like to know if some one can send me to the right place.  Thanks
0
Comment
Question by:martinez1112
[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
  • 2
3 Comments
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 300 total points
ID: 16883179
Polymorphism basically refers to existence in more than one form. Method overloading, etc are all implementations of polymorphism, e.g.,

public class MyClass
{
  public void someMethod ( String a )
  {
  }
  public void someMethod ( int i )
  {
  }
}

MyClass obj = new MyClass () ;
obj.someMethod ( "Hi" ) ; // calls the first method
obj.someMethod ( 1 ) ; // calls the second method
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 300 total points
ID: 16883185
0
 
LVL 8

Accepted Solution

by:
colr__ earned 200 total points
ID: 16883696
An example is the constructor of the Date class. It has the following variants:

Date()
Date(int year, int month, int date)
Date(int year, int month, int date, int hrs, int min)

... plus several more constructors.

Accorign to wikipedia:

In object-oriented programming theory, polymorphism is the ability of objects belonging to different types to respond to methods of the same name, each one according to the right type-specific behavior. The programmer (and the program) does not have to know the exact type of the object in advance, so this behavior can be implemented at run time (this is called late binding or dynamic binding).

colr__
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
V.simple question about Android packages and libraries 1 46
spring jars download 1 68
Crystal Reports Licensing Questions 4 85
American Express @Work site and Java 4 95
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

734 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