vinay
vinay

Reputation: 83

is it calling a Overriden method in a overriding method using "super", are we doing overloading with the call?

Does it represent both overriding and overloading at same time? in class B

public class A{
    void someMethod(){
    System.out.println("Class A's some method");
    }
}

class B extends A{
    void someMethod(){
    super.someMethod();   // does this line reperesnt overloading of super class method??
    System.out.println("Class B's some method");
    }
}

Upvotes: 0

Views: 49

Answers (1)

Eran
Eran

Reputation: 393821

There is no method overloading in this code snippet. Overloading occurs when two methods with a different list of arguments (either different number of arguments or different types of arguments) have the same name.

And the overriding occurs simply due to class B having a method with the same signature and access level as class A - someMethod(). It doesn't make a difference whether B's implementation of that method executes A's implementation (using super.someMethod()) or not.

Upvotes: 4

Related Questions