English

Write the output of the codes given below. String sp = "HOCKEY 12 CRICKET 100 FOOTBALL 4"; int r1 = Integer.valueOf(sp.substring(7,9)) + sp.indexOf('K');

Advertisements
Advertisements

Question

Write the output of the codes given below.

String sp = "HOCKEY 12 CRICKET 100 FOOTBALL 4";
int r1 = Integer.valueOf(sp.substring(7,9)) + sp.indexOf('K');
System.out.println(" R1 = " + r1);
String sq = sp.replace('O', sp.charAt(4)); System.out.println(" SQ = " +sq);
int dif = sp.compareTo(sq); System.out.println(" DIF = " +dif);
Very Short Answer
Advertisements

Solution

R1 = 15

SQ = HECKEY 12 CRICKET 100 FEETBALL 4

DIF = 10

shaalaa.com
  Is there an error in this question or solution?
Chapter 10: String Handling - Exercises [Page 247]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 10 String Handling
Exercises | Q 3. (h) | Page 247
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×