Ask Question
17 December, 12:48

The overloaded printString method is defined as follows: public static void printString (String s) { System. out. println (s); } public static void printString (String s, int n) { if (s. length () > n) printString (s. substring (0, n)); else printString (s); } Exactly one of these statements is such that, when executed, it causes the String "Scrum" to be printed to the output window. Which one?

+4
Answers (1)
  1. 17 December, 15:52
    0
    Complete Question:

    The overloaded printString method is defined as follows: public static void printString (String s) { System. out. println (s); } public static void printString (String s, int n) { if (s. length () > n) printString (s. substring (0, n)); else printString (s); } Exactly one of these statements is such that, when executed, it causes the String "Scrum" to be printed to the output window. Which one?

    A. printString ("Scrump");

    B. printString ("Scrumptious");

    C. printString ("Scrumptious", 4);

    D. printString ("Scrumptious", 5);

    E. printString ("Scrumptious", 6);

    Answer:

    Option D: printString ("Scrumptious", 5);

    Explanation:

    The method call printString ("Scrumptious", 5); is to the second overloaded method since it is the one that accepts two parameters.

    This method prints the substring from 0 to n, in this call, n = 5 (i. e the indexes 0,1,2,3,4) and these are the letters Scrum that is outputed to the console
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “The overloaded printString method is defined as follows: public static void printString (String s) { System. out. println (s); } public ...” 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