View RSS Feed

Overloading

Java Overloading

  1. Overloading Methods

    by , 04-26-2012 at 05:41 PM
    Overloading methods are supported by the Java programming language and methods could be distinguished by Java using various method signatures. Within class, methods might be having similar name when different lists of parameters are present.

    Let us assume that a class is there which uses calligraphy for different data type drawing and which have a method to draw each type of data. New names are used for every method, like drawString, drawFloat and drawInteger & so on. Same name ...
    Categories
    Overloading
  2. What is overloading in java

    by , 04-26-2012 at 05:40 PM
    Two or more than two methods could be defined in Java, within similar class which has similar names with different parameter declarations. In this particular case, methods are overloaded and this is known as method overloading. Method overloading is method by which polymorphism is implemented.

    Sample program of overloading:
    Java Code:
    class Overloading {
    void test() {
    System.out.println("No parameters");
    }
    
    void test(int a, int b) {
    ...
    Categories
    Overloading
  3. Basics of Method Invocation

    by , 04-26-2012 at 05:39 PM
    Let us revive the method invocation features present in JVM. To invoke a method new frame is made at the execution stack. Every frame consists of oerand stack and local variable array. After the frame creation, operand stack gets emptied & the local variable gets quite populated, along with this which is the target object, and arguments of method. On operand stack, all processing occurs. Maximum stack slots and local variable numbers, that are used while the invocation of method shall be known, ...
    Categories
    Overloading
  4. Overloading on return values

    by , 04-26-2012 at 05:39 PM
    It is commonly wondered that why method argument & class names lists? Why methods shall not be distinguished ,based at return values? E.g, two methods having similar arguments and name get distinguished quite easily from each other:

    void f() {}
    int f() {}

    It will be working fine if unequivocally a compiler finds out the meaning, as in int x = f( ). But, a method could be called and return value can be ignored; which is referred as method calling for sideeffects, ...
  5. Using Name Hiding for Overriding

    by , 11-30-2011 at 02:45 AM
    Sometimes you will have a java base class that has a method thatís been overloaded several times. It is important for the programmer to remember that redefining the method name in the derived class does not hide any of the base-class versions. Therefore you should keep in mind that overloading works irrespective of whether the method has been defined at this level or in a base class:

    Java Code:
    import static com.acme.examples.Print.*;
    
    public class Mother {
    	char foo(char
    ...