Question: Consider the following code segment: String[] firstArray, secondArray; String s1, s2; s1 = rack; s2 = train; s2 = t + s1; firstArray = new
Consider the following code segment:
String[] firstArray, secondArray;
String s1, s2;
s1 = "rack";
s2 = "train";
s2 = "t" + s1;
firstArray = new String[3];
secondArray = firstArray;
firstArray[0] = s1;
firstArray[1] = s1;
firstArray[2] = s1;
secondArray[1] = s2;
s1 = "train";
for (int k = 0; k < 3; k++)
System.out.print(firstArray[k] + " ");
What happens when this code segment executes?
Step by Step Solution
There are 3 Steps involved in it
Lets go step by step through the code segment to see what happens String firstArray secondArray Two ... View full answer
Get step-by-step solutions from verified subject matter experts
