My dear friends today I am going to tell you about a very very special thing on opp.
That is methord overloding.
Method overloading has got following special properties.
1. Over loading and over loaded methords should have the same method name but the output diiferent.
2. Overloaded method signature must be equal to Overloading method signature.
3. Argument in overloaded method may be different of types,order,numbers.
Refer the following java program of method overloading and try to understand it.
class animal{
void get(){
System.out.println("Tiger is my name");
}
}
class tiger extends animal{
void get(int a){
System.out.println("About 10 years");
}
public static void main(String args[]){
tiger t=new tiger();
t.get();//This is method overloading
t.get(10);//This is method overloading
}
}
That is all about method overloading...
The output should is below....See the order of result for t.get and t.get(10)
That is methord overloding.
Method overloading has got following special properties.
1. Over loading and over loaded methords should have the same method name but the output diiferent.
2. Overloaded method signature must be equal to Overloading method signature.
3. Argument in overloaded method may be different of types,order,numbers.
Refer the following java program of method overloading and try to understand it.
class animal{
void get(){
System.out.println("Tiger is my name");
}
}
class tiger extends animal{
void get(int a){
System.out.println("About 10 years");
}
public static void main(String args[]){
tiger t=new tiger();
t.get();//This is method overloading
t.get(10);//This is method overloading
}
}
That is all about method overloading...
The output should is below....See the order of result for t.get and t.get(10)