Wednesday, November 21, 2012

method overriding and method overloading in java

Method overriding and method overloading in java

class BaseClass
{
    public void methodOverride()
    {
        System.out.println("Now in BaseClase");
    }
}
class DerivedClass extends BaseClass
{
    public void methodOverride()
    {
        System.out.println("Now in DerivedClase");
    }
}
class MainClass
{
    public static void main(String[] args)
    {
        System.out.println("Main class!");
        DerivedClass dc=new DerivedClass();
        dc.methodOverride();

    }
}

OutPut:

0 comments:

Post a Comment