The title can be a bit confusing, let me explain with an example.
Suppose that I have two classes:
class Parent {}
class Child extends Parent {}
Then somewhere else I define a method that has a single parameter of type Parent, like this:
public void doSomething(Parent parameter) {...}
Because of polymorphism I can pass to the method above also an object of type Child because it extends Parent.
Now let's do an overload
public void doSomething(Parent parameter) {...}
public void doSomething(Child parameter) {...}
and then in some other part of the code call doSomething passing a parameter of type Child
Child myElement = new Child();
doSomething(myElement);
In this case both the overloaded method are valid because the element of type Child can be passed to both.
Which one will be called?
I wrote a test and it seems that the second one (the one that takes the parameter of type Child in input) is executed, and it make also sense to me, but I would like to know if it is a well defined behavior or can vary basing on for example the jvm implementation or the order in which the two methods are declared or just randomly etc.