File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes static binding with function overloading in java and memory space use with function overload ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

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

shyam ji gautam
Ranch Hand

Joined: Sep 17, 2011
Posts: 49
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

Joined: Mar 17, 2011
Posts: 8420
    
  23

Shyam,

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

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: static binding with function overloading in java and memory space use with function overload ?