Which code fragment, when inserted at // insert code here, enables the code to compile and and print a b c?

Given the code fragment: Which code fragment, when inserted at // insert code here,
enables the code to compile and and print a b c?

Given the code fragment: Which code fragment, when inserted at // insert code here,
enables the code to compile and and print a b c?

A.
List update (String[] strs)

B.
Static ArrayListupdate(String [] strs)

C.
Static List update (String [] strs)

D.
Static void update (String[] strs)

E.
ArrayList static update(String [] strs)



Leave a Reply 3

Your email address will not be published. Required fields are marked *


renko

renko

Answer: C

Code question:
import java.util.ArrayList;
import java.util.List;

public class Test {
public static ArrayList data = new ArrayList();

//List update(String[] strs) { //A:
//static ArrayListUpdate(String[] strs) { //B:
static List update(String[] strs) { //C:
//static void update(String[] strs) { //D:
//ArrayList static update(String[] strs) { //E:
for (String x : strs) {
data.add(x);
}
return data;
}
public static void main(String[] args) {
String[] d = {“a”, “b”, “c”};
update(d);
for (String s : d) {
System.out.print(s + ” “);
}
}

}
Output:
a b c BUILD SUCCESSFUL (total time: 0 seconds)