Question: Consider the following method public static String joinTogether(int num, String[] arr) { String result = ; for (String x : arr) { result = result
Consider the following method
public static String joinTogether(int num, String[] arr)
{
String result = "";
for (String x : arr)
{
result = result + x.substring(0, num);
}
return result;
}
The following code appears in another method in the same class.
String[] words = {"dragon", "chicken", "gorilla"};
int number = 4;
System.out.println(joinTogether(number, words));
What is printed when the code above is executed?
-
dragonchickengorilla
dragonchickengorilla
-
drachigor
drachigor
-
dragochickgoril
dragochickgoril
-
There is an error in the program, it does not run
There is an error in the program, it does not run
-
dragchicgori
dragchicgori
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
