0% found this document useful (0 votes)
18 views3 pages

String-Manipulations_output2020

The document provides a series of Java string manipulation exercises with their corresponding outputs. It covers various string methods such as charAt, length, substring, lastIndexOf, indexOf, endsWith, compareTo, and character case conversions. Each example demonstrates a specific string operation along with the expected result.

Uploaded by

Saradha S
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)
18 views3 pages

String-Manipulations_output2020

The document provides a series of Java string manipulation exercises with their corresponding outputs. It covers various string methods such as charAt, length, substring, lastIndexOf, indexOf, endsWith, compareTo, and character case conversions. Each example demonstrates a specific string operation along with the expected result.

Uploaded by

Saradha S
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/ 3

ICSE Computer Application

String Manipulations

Find the output:


1.String str=”Computer Science”;
System.out.println(str.charAt(4));
Ans: u
2. String wd=”Vidhya Jyoti”;
System.out.println(wd.length());
Ans: 12
3. String word=”Desktop Computer”;
System.out.println(word.substring(2,5));
Ans: skt
4. String str="Computer Science";
System.out.println(str.lastIndexOf('e',8));
Ans:6
5. String str="The red ball is lying on the red carpet";
String str1="blue";
System.out.println(str.indexOf(str1,15));
Ans: -1
6. String str1="Knowledge is Power”;
String str2="Power”;
System.out.println(str1.endsWith(str2));
Ans: true
7. String str1="Computer Application”;
String str2="Computer Science”;
System.out.println(str1.compareTo(str2));
Ans: -18
8. String str1="Object Oriented";
System.out.println(str1.substring(6,13));
Ans: Orient

1
9. String wd1="Computer"+"Science"+"1"+"2";
String wd2="Arya Publishing Company";
System.out.println(wd1);
System.out.println(wd2);
Ans: ComputerScience12
Arya Publishing Company
10. String str1="Super Power";
String str2="India";
System.out.println (str1+str2);
System.out.println (str1.length ());
System.out.println(str1.charAt(5));
System.out.println(str1.equals(str2));
Ans: Super PowerIndia
11
False
11. String str=new String("Super computer");
System.out.println(str.toUpperCase());
System.out.println(str.substring(5));
System.out.println(str.substring(5,10));
Ans: SUPER COMPUTER
computer
comp
12. String str="cOmPutER";
for(int a=0;a<str.length();a++)
{
System.out.println(Character.isLowerCase(str.charAt(a)));
}
Ans:
True
False
True

2
False
True
True
False
False

13. String str1="Java Application";


String str2="Java application";
String str3="Java Application";
String str4="Platform Independence";
System.out.println(str1.compareTo(str3));
System.out.println(str1.compareTo(str2));
System.out.println(str1.compareTo(str4));
Ans:
0
-32
-6
14. String str="The green bottle is in the green bag";
String str1="green";
System.out.println(str.indexOf(str1));
Ans: 4
15. System.out.println(Character.toLowerCase('B'));
System.out.println(Character.toLowerCase(66));
System.out.println(Character.toLowerCase(48));
Ans:
b
98
48

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy