15.4k views
2 votes
Suppose

static void nPrint(String message, int n) {
while (n > 0) {
System (message);
n--;
}
}
What is the printout of the call Print('a', 4)?
(a) aaaaa
(b) aaaa
(c) aaa
(d) aa
(e) nvalid call.

1 Answer

3 votes

Final answer:

The given code defines a method called nPrint that takes a String message and an integer n. The method uses a while loop to print the message n times. Therefore, the printout of the call nPrint('a', 4) will be aaaa.

Step-by-step explanation:

The given code defines a method called nPrint that takes a String message and an integer n.

The method uses a while loop to print the message n times. Each time the message is printed, the value of n is decremented until it becomes zero.

Therefore, the printout of the call nPrint('a', 4) will be aaaa as the message 'a' will be printed 4 times.

User Tianlinhe
by
8.2k points