Q&A ICSE2017-03F #7241
Question:
Write the output for the following:
String s=”Today is Test” ;
System.out.println(s.indexOf(‘T’));
System.out.println(s.substring(0,7) + ” ” +”Holiday”);
Answer:
s.indexOf(‘T’) = 0
s.substring(0,7)+ ” “+ “Holiday”
= “Today is Test”.substring(0,7) + ” ” + “Holiday”
= “Today i” + ” ” + “Holiday”
= “Today i Holiday”
Output is
0
Today i Holiday
