How to pass a derived class to a function accepting the parent type
<p>I have a Sport base class that has a couple variables. I also have a few different classes derived from Sport such as Volleyball, Soccer, etc. that have additional methods and variables. They look somewhat like this.</p>

<pre><code>public class Sport {
    public String commonVar;
    public Sport(String c) {
        this.commonVar = c;
    }
}
</code></pre>

<p>And then Volleyball:</p>

<pre><code>public class Volleyball extends Sport {
    public String onlyVolleyball;
    public Volleyball(String c, String thisVar) {
        super(c);
        this.onlyVolleyball = thisVar;
    }
}
</code></pre>

<p>Now I want to be passing the derived classes of Sport into a function elsewhere, but making the parameters</p>

<pre><code>public otherFunction(int one, int two, Sport sport) { }
</code></pre>

<p>Only treats sport as a Sport object (it will accept the derived classes but I cannot access any of the variables and methods not common to Sport). My question is how do I create a function that I am able to send all types of Sport derivatives to without losing any data?</p>
