Ask Question
2 July, 06:10

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. 2 July, 07:34
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers