Given: What is the result?
A.
Marrown String out of limits JesOran
B.
Marrown NanRed JesOran
C.
Marrown String out of limits Array out of limits
D.
Marrown String out of limits
Given: What is the result?
A.
Marrown String out of limits JesOran
B.
Marrown NanRed JesOran
C.
Marrown String out of limits Array out of limits
D.
Marrown String out of limits
A
Agree, and so does compilejava.net.
b
tested
Why B?
I tested and the result was A
Answer: A
Code question:
public class Test3 {
public static void main(String[] args) {
String names[] = new String[3];
names[0] = “Mary Brown”;
names[1] = “Nancy Red”;
names[2] = “Jessy Orange”;
try {
for (String n: names){
try {
String pwd = n.substring(0, 3) + n.substring(6,10);
System.out.println(pwd);
}
catch (StringIndexOutOfBoundsException sie) {
System.out.println(“string out of limits”);
}
}
}
catch (ArrayIndexOutOfBoundsException e) {
System.out.println(“array of of limits”);
}
}
}
Output:
Marrown
string out of limits
JesOran