CLASS-10_STRING-OUTPUT2020
CLASS-10_STRING-OUTPUT2020
String r;
r=s.replace(“went”,“is going”);
System.out.println(r);
2. Give the output of the following program fragment:
String s=“String”;
int a=12,b=45;
System.out.println(s+a+b);
System.out.println(a+s+b);
System.out.println(a+b+s);
3.Give the output of the following program fragment:
String s=“india”,s1=“IndIA”,s2=s;
System.out.println(s.equals(s1));
System.out.println(s.equalsIgnoreCase(s1));
System.out.println(s2==s);
System.out.println(s.toUpperCase()==s1.toUpperCase());
System.out.println(s.startsWith(“IN”.toLowerCase()));
System.out.println(s1.endsWith(“iA”.toUpperCase()));
4. What do the following functions return for:
String x =“hello”;
String y =“world”
System.out.println(x + y);
System.out.println(x.length();
System.out.println(x.charAt(3));
System.out.println(x.equals(y));
(i) System.out.println(x.substring(1,5));
(ii) System out.println(x.indexOf(x.charAt(4)));
(iii) System.out.println(y+x.substring(5));
(iv) System.out.println(x.equals(y));
7. What will be the output of the following code?
char x = ‘A’; int m;
(ii) “DEDICATE”.compareTo(“DEVOTE”)
11. 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”);
12. Give the ouput of the following string functions:
(i) “MISSISSIPPI”.indexOf(‘S’)+“MISSISSIPPI”.lastIndexOf(‘I’)
(ii) “CABLE”.compareTo(“CADET”)
13. State the output of the following program segment when executed:
String a = “Smartphone”, b = “Graphic Art”;
String h = a.substring(2, 5);
String k = b.substring(8).toUpperCase();
System.out.println(h);
System.out.println(k.equalsIgnoreCase(h));
14. State the output of the following program segment:
String str1 = “great”; String str2 = “minds”;
System.out.println(strl.substring(0,2).concat(str2.substring(1)));
System.out.println((“WH” + (strl.substring(2).toUpperCase())));
String s = “malayalam”;
System.out.println(s.indexOf(‘m’));
System.out.println(s.lastIndexOf(‘m’));
17. Give the output of the following:
String n = “Computer Knowledge”;
String m = “Computer Applications”;
System.out.println(n.substring (0,8).concat(m.substring(9)));
System.out.println(n.endsWith(“e”));
18. Give the output of the following code:
String p = "20", q = "19";
int a = Integer.parseInt(p);
int b = Integer.valueOf(q);
System.out.println(a + "" + b);
19. State the data type and value of res after the following is executed:
char ch = '9';
res = Character.isDigit(ch);
20. Write the output for the following:
String s1 = "phoenix";
String s2 = "island";
System.out.println(s1.substring(0).concat(s2.substring(2)));
System.out.println(s2.toUpperCase());
21 Give the output of the following Java statements:
(i) "TRANSPARENT".toLowerCase()
(ii) "TRANSPARENT".compareTo("TRANSITION")
22. Write a Java statement for each to perform the following tasks:
(i) Find and display the position of the last space in a string str.