ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
what is polymorphism?
 Question Submitted By :: Arun
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is polymorphism?
Answer
# 1
Overloaded methods are methods with the same name signature 
but either a different number of parameters or different 
types in the parameter list. For example 'spinning' a 
number may mean increase it, 'spinning' an image may mean 
rotate it by 90 degrees. By defining a method for handling 
each type of parameter you achieve the effect that you want.

Overridden methods are methods that are redefined within an 
inherited or subclass. They have the same signature and the 
subclass definition is used.

Polymorphism is the capability of an action or method to do 
different things based on the object that it is acting 
upon. This is the third basic principle of object oriented 
programming. Overloading and overriding are two types of 
polymorphism . Now we will look at the third type: dynamic 
method binding.

Assume that three subclasses (Cow, Dog and Snake) have been 
created based on the Animal abstract class, each having 
their own speak() method.

Example:
--------
public class AnimalReference
{
  public static void main(String args[])
  Animal ref                    // set up var for an Animal
  Cow aCow = new Cow("Bossy");  // makes specific objects
  Dog aDog = new Dog("Rover");
  Snake aSnake = new Snake("Earnie");

  // now reference each as an Animal
  ref = aCow;
  ref.speak();
  ref = aDog;
  ref.speak();
  ref = aSnake;
  ref.speak();
}
Notice that although each method reference was to an Animal 
(but no animal objects exist), the program is able to 
resolve the correct method related to the subclass object 
at runtime. This is known as dynamic (or late) method 
binding.
 
Is This Answer Correct ?    0 Yes 0 No
Ganesh
 
  Re: what is polymorphism?
Answer
# 2
Polymorphism means the ability of a single variable of a 
given type to be used to reference objects of
different types, and automatically call the method that is 
specific to the type of object the variable references.
The benefit of polymorphism is that it is very easy to add 
new classes of derived objects without breaking the calling 
code that uses the polymorphic classes or interfaces.
When you send a message to an object even though you
don’t know what specific type it is, and the right thing 
happens, that’s called polymorphism. The process used by
object-oriented programming languages to implement 
polymorphism is called dynamic binding.
 
Is This Answer Correct ?    1 Yes 0 No
Navieen
 
 
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Which class is extended by all other classes?  2
how can u create the object with out new operator  2
what is Thread?  3
what is sendredirect? TCS2
Which characters are allowed to use as the second character of an identifier, and which characters are not allowed?  1
What is the use of an interface?  3
How can you take string into InputStream?  3
Howmany number of objects we can store in an ArrayList. Is there any limit? TCS4
What are interfaces?  1
what is d difference between deep cloning and shallow cloning in core java? Satyam2
What is encapsulation? Elaborate with example? BMC1
What is a package?  2
What is the life cycle of Thread ? HCL6
Differentiate Vector and ArrayList? Wipro3
What is a reflection package?  2
where do we use init()  1
diff between abstract methods and interfaces with programing (code) example?  2
what is ennumaration? AMDOC1
How to find the length and capacity of a string buffer ?  1
what Data encapsulation in java?  2
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com