What is the result? Given: What is the result? Given: What is the result? A. 123456 B. 123456xxx C. 123xxx D. 123 E. Compilation fails Show Hint ← Previous question Next question →
renko Answer: C Code question: public class String1 { public static void main(String[] args) { String s = “123”; if (s.length() > 2) s.concat(“456”); for(int x = 0; x < 3; x++) s += "x"; System.out.println(s); } } Output: 123xxx Reply
Answer: C
Code question:
public class String1 {
public static void main(String[] args) {
String s = “123”;
if (s.length() > 2)
s.concat(“456”);
for(int x = 0; x < 3; x++)
s += "x";
System.out.println(s);
}
}
Output:
123xxx