Friday, February 13, 2009

Method Overriding

//Method Overriding - save prog as "overrid.java" //
//To call super class methods remove the comment at super.mtd() in the prg

import java.io.*;

class oa
{
public void mtd()
{
System.out.print("super class");
}
}
class ob extends oa
{
public void mtd()
{
//super.mtd();
System.out.print("sub class");
}
}
public class overrid {
public static void main(String args[])
{
ob obj=new ob();
obj.mtd();
}
}

No comments:

Post a Comment