Question: For the following program segment, give the output produced by the segment: 1 2 3 4 5 6 7 8 9 10 11 12 13
For the following program segment, give the output produced by the segment: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 String a="potato", b="tophat"; String output=""; int pos=0; while (pos=0) { if (a.charAt(pos) == b.charAt(pos2)) { output=output+a.charAt(pos); } pos2=pos2-1; } pos = pos + 1; } System.out.println("The final output is: "+output);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
