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
C (NOTE: String is immutable)
+1
D is correct
-1
C is correct svar.replace(svar,”convertibles”); was never assigned to svar