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

 Print  |  
Question:  Java Polymorphism

Answer: Describe why Java supports only runtime polymorphism?


July 07, 2009 08:55:22 #1
 Gaurav_soni   Member Since: May 2009    Total Comments: 1 

RE: Java Polymorphism
 

Polymorphism means when an entity behaves differently depending upon the context its being used.Moreover In other words Polymorphism is the capability of an action or method to do different things based on the object that it is acting upon. Means, polymorphism allows you define one interface and have multiple implementation. That being one of the basic principles of object oriented programming.

The method overriding is an example of runtime polymorphism. You can have a method in subclass overrides the method in its super classes with the same name and signature. Java virtual machine determines the proper method to call at the runtime, not at the compile time.

And when java was being developed they removed all hazziness of C++ or things that create a lot of confusion like removed pointer an memory allocationbut still kept things same as c++ so that one migrating from C++ to java doesn't gets a shock that one needs to learn new things. Hence, they decoded that every function whould get resolved at runtime only.

     

 

Back To Question