Code to demonstrate method overloading by extending another class.
package oops;
class Superclass
{
public void m1()
{
System.out.println("no arg");
}
}
public class OLSuperSub extends Superclass {
public void m1(int i)
{
System.out.println("one arg");
}
public static void main(String a[])
{
OLSuperSub s=new OLSuperSub();
s.m1(); // no arg
s.m1(10); // one arg
}
}
0 comments:
Post a Comment