I have the following code in two separate files.

package animal;

public class Frog
{
    protected void ribbit()
    {
        System.out.println("In Frog class!");
    }
}





package other;

import animal.*;

public class Tadpole extends Frog

{
    protected void ribbit()
    {
        System.out.println("In Tadpole class!");
    }

    public static void main(String[] args)
    {
        Tadpole t = new Tadpole();
        t.ribbit();

        Frog f = new Tadpole();
        f.ribbit(); // Does not compile
    }
}


The first Tadpole object assigned to Tadpole type obviously compiles fine and the call to ribbit() will be to the Tadpole's ribbit() implementation. The second Tadpole object that is created and assigned to a Frog reference. However, the call to ribbit() results in a compiler error. 

I know that if you create a subclass object in the subclass and assign to a superclass reference that is outside of the subclass's package and try to call a superclass method, this is not allowed. But in this case, shouldn't polymorphism make the object reference "f" call the Tadpole's ribbit() method since a Tadpole object was assigned to it? Why does this cause a compiler error and why is this is not allowed?


Question: Daydream with transparent background
Answer: This question may have the answer you need:
How to create Transparent Activity in Android?

You can do that by creating a Transparent theme and applying it to your activity.