Output writing – indexOf, substring – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-ICSE2017-03F #JAVA#7241    siteicon   siteicon  

Problem Statement - Output writing – indexOf, substring

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”);

Solution

TC++ #7241

Run Output

0
Today i Holiday

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


Share

CSKC| Created: 15-Apr-2019 | Updated: 28-Nov-2019|ICSE2017






Back