aspose file tools*
The moose likes Java in General and the fly likes Hi Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hi Question" Watch "Hi Question" New topic
Author

Hi Question

Fred Man
Greenhorn

Joined: Nov 07, 2005
Posts: 8
what is What is polymorphism and why is it important in Object Oriented programming.?

Please help
Fred Man
Greenhorn

Joined: Nov 07, 2005
Posts: 8
Also can you give example of code
Gaurav Chhabras
Ranch Hand

Joined: Sep 21, 2005
Posts: 126
First of all please keep this thing in your mind that

Write some meaningful subject in the subject line so that one can see the subject and come to know that what type of question it contains

This is Ranch policy , so please follow this.

Now , regarding polymorphism, you can understand with the help of methord overriding. In this we have two different classes but some methords are with same name.

Like -:

class A
{
void test()
{
System.out.println("I am in Class A");
}
}

class B extends A
{
void test()
{
System.out.println("I am in Class B");
}
}

Now there are two classes A and B.Both have one function with same name i.e test(). Now at runtime it will depend on the Object that test() methord of which class will be get called.

Thanks
Regards
Gaurav
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Have a look at How My Dog Learned Polymorphism by Kathy Sierra.


[Jess in Action][AskingGoodQuestions]
Fred Man
Greenhorn

Joined: Nov 07, 2005
Posts: 8
yeah sorry about not mentioning the title of the topic in the suject, but you did not answer my secoud part of the question, y do programmers use this

thank you
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Read the story.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hi Question