This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

static binding with function overloading in java and memory space use with function overload ?

 
shyam ji gautam
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Report post to moderator
class OverloadDemo
{
void triangleArea(float base, float height)
{
float area;
area = base * height / 2.0f;
System.out.println(“Area = “ + Area);
}

void triangleArea(float side1, float side2, float side3)
{
float area,s;
s = (side1 + side2 + side3) / 2.0;
area = Math.sqrt(s*(s-side1) * (s-side2) * (s-side3) );
System.out.println(“Area = “ + area);
}
}



class MainOverloadDemo
{
public static void main(String args[])
{
OverloadDemo ovrldDemo = new OverloadDemo();
ovrldDemo.triangleArea(20.12,58.36);

ovrldDemo triangleArea(63.12,54.26,95.24);
}
}

my first question is
is it static binding or not ?
according to me here compiler is aware at compile time that need to call void triangleArea(float base, float height)
Because no of parameter different and the JVM invokes void triangleArea(float base, float height) in the class OverloadDemo at run time


but i also knows that All the instance method calls are always resolved at runtime, and here void triangleArea(float base, float height) is also a instance method so i am confuse which statement is right ?


and third doubt is that when we use method overloading then memory space uitilization is improve how with refernce to java ?

 
Winston Gutkowski
Bartender
Pie
Posts: 10236
58
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Shyam,

Please don't double-post. I'm locking this thread.

Winston
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic