Java Method OverLoading .






  Here   is  example of    method   overloading .  This    is  a simple java code  of  method
  over loading .  Here   is  only   focus is that   our  return  type . Each method  have
   different   return    type . 


   

public class MethodLoading {
int   addn(int a, int b){
  int  d=a+b;
 
  return d;
}
   
float   addn( float a, float b){
  float d=a+b;
 
  return d;
}
String    addn(  String s , String  g) {
  return    s.concat(g);
}

public static void  main(String[] args) {
// TODO Auto-generated method stub

  System.out.println( new    MethodLoading().addn( 8, 8) );
  System.out.println( new    MethodLoading().addn( 8.5f, 8.9f) );
  System.out.println( new    MethodLoading().addn( "mukesh", "kumar") );

}

}



 Simple   program  out is ...

16
17.4

mukeshkumar

Java Method OverLoading . Java Method OverLoading . Reviewed by Mukesh Jha on 3:16 AM Rating: 5

No comments:

Add your comment

All Right Reserved To Mukesh Jha.. Theme images by Jason Morrow. Powered by Blogger.