• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is compile time polymorphism?  RSS feed

 
sachink kulkarnik
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is such term exist?
As per my knowlegde there is no such term in oop.
Since all the oop concept are appicable at run time only.
If it is there, then there must be compile time inheritance and encapsulation.
Please correct me if I am wrong.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
 
swapnil kachave
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
As per your question on polymorphism , We normally say overloading is compile time polymorphism. At time of compilation ,Compiler follow certain number of steps , in that one step is to check methods which called by using object is there or not.
So that we say overloading is resolved at compiler time.

 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes.......at compile time....overloading is resolved
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sachink kulkarnik wrote:As per my knowlegde there is no such term in oop.

Agree. there is nothing called compile-time polymorphism. this topic discussed mant time here in javaranch. search for more details.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:
sachink kulkarnik wrote:As per my knowlegde there is no such term in oop.

Agree. there is nothing called compile-time polymorphism. this topic discussed mant time here in javaranch. search for more details.


serach on google....found that .....
compile time polymorphism is called as method overloading.....which is achieved by overloading functions and operators.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
swapnil kachave wrote:
one step is to check methods which called by using object is there or not.
So that we say overloading is resolved at compiler time.


objects are created at runtime.......so at compile time,compiler will decide which method to call by using reference type only
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shanky sohar wrote:objects are created at runtime.......so at compile time,compiler will decide which method to call by using reference type only
Nonsense.

I know there are people who say "compile-time polymorphism" but I think that is a very bad term. There is overloading, hiding, obscuring, shadowing, and there are several other things; there is a list of those in Java Puzzlers by Bloch and Gafter (I recently referred to it here, where you can probably find the page number). I don't believe those should be called polymorphism. you should reserve the name polymorphism in Java for overridden methods (that means only non-private instance methods), where the actual method called can be resolved at run-time. not at compile time.

Overloaded methods are resolved at compile time; you are correct about that.

Different languages may have different models of polymorphism.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I know there are people who say "compile-time polymorphism" but I think that is a very bad term.

I agree with that. I think the key idea behind polymorphism is "we will treat these objects in the same way, and they will all behave appropriately depending on what actual type they are".

Overriding follows this model. But using overloading, we aren't treating the objects in the same way; we're sending them different messages.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay ....i agree to your point.........
but in which language this compile time polymorphism exists.........
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shanky sohar wrote: . . . in which language this compile time polymorphism exists.........
Don't know.
 
sachink kulkarnik
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for clarification
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for clearing.....some searches on net creates confusion sometimes........

 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shanky sohar wrote:thanks for clearing
You're welcome
some searches on net creates confusion sometimes........
Yes, don't they
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!