java method overloading

public class methodover {

public static void main(String[] args) {

int newScore = calculateScore(“Tim”,500);

System.out.println(“New score is “ + newScore);

calculateScore(75);                   // this is method with one parameter

calculateScore(“Prashant”,32);         // this is refer to 1st method with 2 parameter


// TODO Auto-generated method stub

}                          // method overloading is same method name with different paramater

public static int calculateScore(String playerName, int score){

System.out.println(“Player” + playerName + “scored” +score+ “points”);

return score*1000;


public static int calculateScore(int score){           // 2nd method  with 1 paramater .

System.out.println(“Unnamed player scored”  +score+ “points”);

return score*1000;


public static int calculateScore(){                       // 3rd method with no paramter .

System.out.println(“Unnamed player no player score.”);

return 0;



Leave a Reply

Your email address will not be published.