Output in case of chaining inheritance
<pre><code>class Monster {
    boolean frighten(int x) {
        System.out.println("Monster");
        return true;
    }
}

class Vampire extends Monster {
    boolean frighten(byte x) {
        System.out.println("Vampire");
        return true;
    }
}

class Dragon extends Monster {
    boolean frighten(int x) {
        System.out.println("Dragon");
        return true;
    }
}


class Sample {
    public static void main(String s[]) {
        Monster[] inst = new Monster[3];
        inst[0] = new Monster();
        inst[1] = new Vampire();
        inst[2] = new Dragon();

        for (int i = 0; i &lt; 3; i++) {
            inst[i].frighten(i);
        }
    }
}
</code></pre>

<p>When I run the above code with <code>x</code> as <code>int</code> in <code>Monster</code> or <code>Dragon</code> class, the code works fine in the way I expect.  However, when I run the code by changing the type of <code>x</code> from <code>int</code> to <code>long</code> either in <code>Monster</code> or <code>Dragon</code> classes, it prints the following:           </p>

<pre><code>Monster                           
Monster                                 
Monster                                   
</code></pre>

<p>Can someone explain the logic behind the output?</p>