0% found this document useful (0 votes)
66 views

CLASS-10_STRING-OUTPUT2020

Uploaded by

R siva surya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

CLASS-10_STRING-OUTPUT2020

Uploaded by

R siva surya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Computer Application

Output questions:String Manipulation

1. Give the output of the following program fragment:


String s=new String(“He went to the market”);

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

5. What is the output of the following:


System.out.println (“four :” + 4 + 2);
System.out.println (“four :”+(2+2));
6. If, String x = “Computer”;
String y = “Applications”;
What do the following functions return for:

(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;

m=(x= =’a’) ? ‘A’ : ‘a’;


System.out.println(“m=”+m);

8. Write a statement each to perform the following task on a string:


(i) Find and display the position of the last space in a string s.

(ii) Convert a number stored in a string variable x to double data type


9. Write a statement each to perform the following task on a string:
(i) Extract the second last character of a word stored in the variable wd.
(ii) Check if the second character of a string str is in uppercase.
10. Give the output of the following string functions:
(i) “ACHIEVEMENT”.replace(‘E’,‘A’)

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

15. State the output of the following program segment.


String s = “Examination”;
int n = s.length();
System.out.println(s.startsWith(s.substring(5, n)));
System.out.println(s.charAt(2) == s.charAt(6));
16. What will the following code output?

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.

(ii) Extract the second character of the string str.


23.

You might also like