• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compile-time polymorphism

 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ranchers ,

there is runtime polymorphism in java , i have no doubt in that but Is there compile time polymorphism ?

if yes what could be the example of the case?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One example would be method overloading.
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok.

apart from that what can be compile time polymorphic ?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

naveen yadav wrote:
apart from that what can be compile time polymorphic ?




I think you also need to define "what is compile time polymorphism"?

For example, is polymorphism (overriding methods) truly runtime? There is definitely a runtime component, as the methods are resolved at runtime. But isn't there also a compile time component? It is the compiler that figures out the code that builds the jump tables, etc.



IMO, the definition isn't completely clear, certainly not enough to give you a clear answer.

Henry
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

I think you also need to define "what is compile time polymorphism"?
Henry



i meant to say that what are "other thing" in java which shows polymorphic nature at compile time ?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

naveen yadav wrote:

Henry Wong wrote:

I think you also need to define "what is compile time polymorphism"?
Henry



i meant to say that what are "other thing" in java which shows polymorphic nature at compile time ?



We know that. The problem is there are multiple valid definitions for polymorphism. If we don't know exaclty how you are defining it, we can't give you a precise or complete answer according to your definition.

Which brings us to the question: Why do you care? How will it help your understanding of Java or help you to write better code if somebody tells you that, "Behavior X is considered compile-time polymorphism"?
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to emphasise that how you're defining it matters, and how different people mean different things by it - I personally don't believe there is such a thing as "compile-time polymorphism". Not in Java, anyway. I consider polymorphism to mean that you perform the same action on different objects and they behave in different ways. I don't consider method overloading to meet this definition, as you're calling different methods (that just happen to have the same name). But others will take a different view.
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
things get more clear https://coderanch.com/t/412204/java/java/Polymorphism-applies-overriding-not-overloading

thank you all.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

naveen yadav wrote:things get more clear https://coderanch.com/t/412204/java/java/Polymorphism-applies-overriding-not-overloading

thank you all.



How is that more clear? It says exactly the same things we've been telling you: That the answer to your question depends on your definition of "polymorphism," and that there is no one single universally accepted standard definition.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Method overloading is compile time polymorphism , also operator overloading is compile time polymorphism.
Aren't you mixing compile time polymorphism with compile time behaviour of Java?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chandraprakash Sarathe wrote:Method overloading is compile time polymorphism , also operator overloading is compile time polymorphism.


It may or may not be, depending on one's interpretation of the term, as already discussed in this thread.


Aren't you mixing compile time polymorphism with compile time behaviour of Java?



No, we're discussing compile-time polymorphism as one aspect of Java's compile time behavior.
reply
    Bookmark Topic Watch Topic
  • New Topic