What will be the output of the following codes: [4]
String s1=”JAVA APPLICATIONS”;
String s2=”COMPUTER APPLICATIONS”;
System.out.println(s1.substring(0,5));
System.out.println(s1.indexOf(‘P’)+ s2.indexOf(‘P’));
System.out.println(s1.repalce(s.charAt(3),’*’));
System.out.println(s1.comapreTo(s2));
reply it fast urgent
WHO WILL RePLY FAST I WILL FOLLOW HIM
Answers
Answered by
1
JAVA
5 3
J*V* *PPLIC*TIONS
6
Answered by
1
Output:
JAVA
9
J*V* *PPLIC*TIONS
7
Explanation:
As Index 0 to 4 in s1 is "JAVA".
As Index of 'P' in s1 is 6 and Index of 'P' in s2 is 3.
> 6 + 3
> 9
Replace 'A' with '*'.
> J*V* *PPLIC*TIONS
Index differs at Index 0 so,
> 'J' - 'C'
> 74 - 67
> 7
Similar questions