32.method overloading
// method overloading
class message{
void a()
{
System.out.println("Mehtod without argument");
}
void a(int no)
{
System.out.println("method with one int argument");
System.out.println(no);
}
void a(String nm)
{
System.out.println("method with one String argument");
System.out.println(nm);
}
void a(int no, String nm)
{
System.out.println("method with two argument");
System.out.println(no);
System.out.println(nm);
}
}
class method_overloading{
public static void main(String[] args) {
message obj = new message();
obj.a();
obj.a(12);
obj.a("milan");
obj.a(11, "bakotra");
}
}
Comments
Post a Comment