Q.– Given the code fragment:
String[ ] strs = {"A", "B"};
int idx = 0;
for (Strings : strs) {
strs[idx] .concat(" element " + idx);
idx++;
}
for (idx = 0; idx <strs.length; idx++) {
System.out.println(strs[idx]);
}
What is the result?
A) A element 0
B element 1
B) A 0
B 1
C) A
B
D) A NullPointerException is thrown at runtime.
String[ ] strs = {"A", "B"};
int idx = 0;
for (Strings : strs) {
strs[idx] .concat(" element " + idx);
idx++;
}
for (idx = 0; idx <strs.length; idx++) {
System.out.println(strs[idx]);
}
What is the result?
A) A element 0
B element 1
B) A 0
B 1
C) A
B
D) A NullPointerException is thrown at runtime.
⧪ please give your answer in a comment section.
7 Comments
This comment has been removed by the author.
ReplyDeleteOption D
ReplyDeleteOption D
ReplyDeletec
ReplyDeleteC
ReplyDeleteC
ReplyDeleteC
ReplyDelete