69 Compile time polymorphism | Static polymorphism | Early Binding in Java

Code:

class Test
{
static void m1()
{
System.out.println("  super class Test m1() ");
}
}

class Demo extends Test
{
static void m1()
{
System.out.println("  sub class Demo m1() ");
}

public static void main( String args[] )
{
Test t = new Demo(); // UpCasting
t.m1();
m1();
}

}


Output:



Previous
Next Post »