static void nPrintString message int n while n 0 Systemou

static void nPrint(String message, int n) { while (n > 0) { System.out.print(message); } } What is the printout of the call aPrint\"b\", 3.0)? a. aaaaa b. aaaa c. aaa

Solution

This will give a compilation error. Here, in the function call nPrint(\"b\", 3.0) , 3.0 is treated as double data type and in function definition, second argument is integer. So, the error will be thrown as :

Incompatible types: possibly loosy conversion from double to int

So, this is the answer.

Extra:

If you will change it to 3 from 3.0, the output will be bbb.

Do comment if there is any confusion. :)

 static void nPrint(String message, int n) { while (n > 0) { System.out.print(message); } } What is the printout of the call aPrint\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site