What is the result?

Give:

public class Test {

public static void main(String[] args) {

String svar= “sports cars”;

svar.replace(svar,”convertibles”);

System.out.printf(“There are %3$s %2$s and %d trucks.”,5,svar,2+7);

}

}

What is the result?

Give:

public class Test {

public static void main(String[] args) {

String svar= “sports cars”;

svar.replace(svar,”convertibles”);

System.out.printf(“There are %3$s %2$s and %d trucks.”,5,svar,2+7);

}

}

What is the result?

A.
There are 27 sports cars and 5 trucks

B.
There are 27 convertibles and 5 trucks

C.
There are 9 sports cars and 5 trucks

D.
There are 9 convertibles and 5 trucks

E.
IllegalFormatConversionException is thrown at runtime



Leave a Reply 5

Your email address will not be published. Required fields are marked *


John

John

C (NOTE: String is immutable)

Gina

Gina

C is correct svar.replace(svar,”convertibles”); was never assigned to svar