READ Free Dumps For Oracle- 1z0-804
Question ID 21457 | 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?
|
Option A | There are 27 sports cars and 5 trucks
|
Option B | There are 27 convertibles and 5 trucks
|
Option C | There are 9 sports cars and 5 trucks
|
Option D | There are 9 convertibles and 5 trucks
|
Option E | IllegalFormatConversionException is thrown at runtime
|
Correct Answer | C |
Explanation Explanation: Answer C: Strings are immutable, therefore no change at line: svar.replace(svar,"convertibles"); Format String Syntax: %[argument_index$][flags][width][.precision]conversion The optional argument_index is a decimal integer indicating the position of the argument in the argument list. The first argument is referenced by "1$", the second by "2$", etc. The optional flags is a set of characters that modify the output format. The set of valid flags depends on the conversion. 's', 'S' general 'd' integral The result is formatted as a decimal / integer
Question ID 21458 | Given the code fragment:
String s = "Java 7, Java 6";
Pattern p = Pattern.compile("Java.+\\d");
Matcher m = p.matcher(s);
while (m.find()) {
System.out.println(m.group());
}
What is the result?
|
Option A | Java 7
|
Option B | Java 6
|
Option C | Java 7, Java 6
|
Option D | Java 7
java 6
|
Option E | Java
|
Correct Answer | C |
Explanation Explanation: regex: Java / one or more anything !!! / ends with a digit so it is the source string