GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Concepts  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 6 of 63    Print  
Explain the different forms of Polymorphism.
From a practical programming viewpoint, polymorphism exists in three distinct forms in Java:
Method overloading
Method overriding through inheritance
Method overriding through the Java interface



  
Total Answers and Comments: 18 Last Update: April 03, 2008   
  
 Sponsored Links



 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
July 25, 2005 06:10:32   #1  
Rahul Sen        

RE: Explain the different forms of Polymorphism.
it is not very clever answer at all.
 
Is this answer useful? Yes | No
August 04, 2005 07:59:29   #2  
amarjyoti de        

RE: Explain the different forms of Polymorphism.
the answer does in anyway give a full perspective of olymorphism
 
Is this answer useful? Yes | No
August 04, 2005 08:08:37   #3  
John        

RE: Explain the different forms of Polymorphism.
Why don't some one answer in detail insted of comlaining about the level of detail... helps others
 
Is this answer useful? Yes | No
August 04, 2005 18:19:27   #4  
Paul        

RE: Explain the different forms of Polymorphism.
Uses of Inheritance 
 
The classic examples of an inheritance hierarchy are borrowed from animal and plant taxonomies. For example, there could a class corresponding to the Pinaceae (pine) family of trees. Its subclasses could be Fir, Spruce, Pine, Hemlock, Tamarack, DouglasFir, and TrueCedar, corresponding to the various genera that make up the family.  
 
The Pine class might have SoftPine and HardPine subclasses, with WhitePine, SugarPine, and BristleconePine as subclasses of SoftPine, and PonderosaPine, JackPine, MontereyPine, and RedPine as subclasses of HardPine. 
There's rarely a reason to program a taxonomy like this, but the analogy is a good one. Subclasses tend to specialize a superclass or adapt it to a special purpose, much as a species specializes a genus. 
 
Here are some typical uses of inheritance: 
 
 
Reusing code. If two or more classes have some things in common but also differ in some ways, the common elements can be put in an a single class definition that the other classes inherit. The common code is shared and need only be implemented once.  
 
For example, Faucet, Valve, and WaterPipe objects, defined for the program that models water use, all need a connection to a water source and they all should be able to record the rate of flow. These commonalities can be encoded once, in a class that the Faucet, Valve, and WaterPipe classes inherit from. A Faucet can be said to be a kind of Valve, so perhaps the Faucet class would inherit most of what it is from Valve, and add very little of its own.  
 
Setting up a protocol. A class can declare a number of methods that its subclasses are expected to implement. The class might have empty versions of the methods, or it might implement partial versions that are to be incorporated into the subclass methods. In either case, its declarations establish a protocol that all its subclasses must follow.  
 
When different classes implement similarly named methods, a program is better able to make use of polymorphism in its design. Setting up a protocol that subclasses must implement helps enforce these naming conventions.  
 
Delivering generic functionality. One implementor can define a class that contains a lot of basic, general code to solve a problem, but doesn't fill in all the details. Other implementors can then create subclasses to adapt the generic class to their specific needs. For example, the Appliance class in the program that models water use might define a generic water-using device that subclasses would turn into specific kinds of appliances.  
 
Inheritance is thus both a way to make someone else's programming task easier and a way to separate levels of implementation.  
 
Making slight modifications. When inheritance is used to deliver generic functionality, set up a protocol, or reuse code, a class is devised that other classes are expected to inherit from. But you can also use inheritance to modify classes that aren't intended as superclasses. Suppose, for example, that there's an object that would work well in your program, but you'd like to change one or two things that it does. You can make the changes in a subclass.  
 
Previewing possibilities. Subclasses can also be used to factor out alternatives for testing purposes. For example, if a class is to be encoded with a particular user interface, alternative interfaces can be factored into subclasses during the design phase of the project. Each alternative can then be demonstrated to potential users to see which they prefer. When the choice is made, the selected subclass can be reintegrated into its superclass.  
 
 
Click here to Complete Book Online

 
Is this answer useful? Yes | No
October 24, 2005 00:58:35   #5  
Raju        

RE: Explain the different forms of Polymorphism.
Different forms of Polymorphism.
 
Is this answer useful? Yes | No
November 07, 2005 03:42:59   #6  
avinash        

RE: Explain the different forms of Polymorphism.

different types of polymorphism

1. compile time polymorphism

2.run time polymorphism


 
Is this answer useful? Yes | No
November 15, 2005 12:33:58   #7  
rekhila.k        

RE: Explain the different forms of Polymorphism.

1.overriding

2.overloading


 
Is this answer useful? Yes | No
January 23, 2006 05:02:47   #8  
prathibhagb Member Since: December 2005   Contribution: 4    

RE: Explain the different forms of Polymorphism.
the first answer is correct
 
Is this answer useful? Yes | No
January 24, 2006 10:14:25   #9  
gaurav26_bagga Member Since: January 2006   Contribution: 2    

RE: Explain the different forms of Polymorphism.

1. compile time polymorphism(function and operator overloading)

2.runtime polymorphism.(virtual functions)


 
Is this answer useful? Yes | No
March 06, 2006 07:12:24   #10  
kishore        

RE: Explain the different forms of Polymorphism.
CLient & run time
 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links



 
Sponsored Links

 
Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape