Ask Question
2 June, 06:06

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 June, 06:53
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers