Ask Question
10 February, 14:19

Consider the following methods:

public static void printSport (double n) {

System. out. print ("football ");

printSport ((int) (n));

}

public static void printSport (int n) {

System. out. print ("basketball ");

}

What is output by the method call printSport (8) ?

1. football

2. basketball

3. football basketball

4. football football basketball basketball

5. basketball football

+1
Answers (1)
  1. 10 February, 14:23
    0
    2. basketball This is a classic case of overloading in C++. You have 2 functions, both named "printSport", but one of the functions receives an input of type double, and the other receives an input of type int. The specified method call passes a parameter of type int, so the version of printSport is called that receives a parameter of type int. And that version of printSport only prints the word "basketball". The other version of printSport is never called at all.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Consider the following methods: public static void printSport (double n) { System. out. print ("football "); printSport ((int) (n)); } ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers