Friday, 9 October 2015

Method overloading example in java (dynamic polymorphism)


public class First {

public static void main(String[] args) {
// TODO Auto-generated method stub
Second obj = new Second();
obj.show();

}

}


public class Second {
int i,k;
float j;
void show(){
System.out.println("No argument method");
}
void show(int k){
this.k=k;
System.out.println("The value of k is " +k);
}
void show(int i,float j){
this.j=j;
this.i=i;
System.out.println("The value of i,j is " +i +j);
}
}

output:-
No argument method

No comments:

Post a Comment