• 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

Overloaded Methods in Java are early binded or late binded

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

During my recent interviews I was asked about Polymorphism and early binding and late binding. Every time I said that overloaded methods implementations are binded dynamically during runtime until the method is static or final(private are implictly final). But every time I was told by the interviewers that overloaded methods are early binded.
Could you please suggest what is correct with overloaded methods and Why?
[ October 17, 2005: Message edited by: Amar Shrivastava ]
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are talking about overloading, then yes, there is no dynamic binding involved... So i can agree with your interviewers. On the other hand overriding requires runtime binding.
 
Amar Shrivastava
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But how could you ever say that the overloaded method will not be overridden in the subclasses.

Let's say:

public class A{

int x(String s){...}
int x(int i){...}
void x (String s, int i){}
....
....
}

public class B extends A{
int x(String s){...}
int x(int i){...}
void x (String s, int i){}
......
....
}

class Client {
public static void main(String []args){
A a= new B();
a.x("java");
}
}

In this case looking at class A alone which does not no that it has a sub class and the class Client uses a class A reference and calls a method x.
Now how could this be resolved at compile time.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to Java in General (Intermediate). I am not sure that it belongs there, but that is where your other copy of the same question is. In future, please Carefully Choose One Forum. You can find the new version here.
[ October 17, 2005: Message edited by: Andrew Monkhouse ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic