Tuesday, February 24, 2009

Example code to demonstrate method overriding

// simple example to demonistrate method overriding
package oops;


class Baseclass
{
public void sm()
{
System.out.println("super class");
}
}

public class OverridingDemo extends Baseclass{
public void sm()
{
System.out.println("sub class");
}
public static void main(String a[])
{
OverridingDemo s=new OverridingDemo();
s.sm(); // sub class
}
}


0 comments:

Post a Comment