[go: up one dir, main page]

0% found this document useful (0 votes)
7 views2 pages

Module 2 QB

This document covers various aspects of string handling in Java, including string construction, modification methods, and string comparison. It includes programming tasks such as removing duplicate characters, counting occurrences of characters, and sorting names. Additionally, it explains methods from both the String and StringBuffer classes, providing examples for clarity.

Uploaded by

nandanms030
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)
7 views2 pages

Module 2 QB

This document covers various aspects of string handling in Java, including string construction, modification methods, and string comparison. It includes programming tasks such as removing duplicate characters, counting occurrences of characters, and sorting names. Additionally, it explains methods from both the String and StringBuffer classes, providing examples for clarity.

Uploaded by

nandanms030
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/ 2

Module 2

String Handling
1. What is string in JAVA ? Write a program that demonstrates four constructors of
string class
( Define String . Explain the different ways constructing strng object)
2. Explain how to modify a string by using following methods with suitable examples
i. Substring()
ii. Concat()
iii. replace()
iv. trim()
3. write a program to remove duplicate characters in a given string and display new
string without any duplicates.
4. Differentiate between equals ( ) and = = with respect to string comparison.
5. Explain the following methods of stringBuffer class with suitable example
i. append( )
ii. insert ( )
iii. reverse ( )
iv. replace ( )
6. Explain how to check the occurrences of a substring or characters in a given string.
7. Develop a java program to count the occurrence of character in a given string.
8. Differentiate between string and string Buffer explain reverse ( ) method of string
Buffer with an example .
9. Explain the following character extraction methods :
i. charAt( )
ii. to charArray ( )
10. Explain insert ( ) and append ( ) stringBuffer methods with an example .
11. Explain the following stringBuffer methods with examples
i. capacity ( )
ii. reverse ( )
iii. charAt ( )
iv. deleteCharAt( )
12. write a program to remove duplicate characters from a given string and display the
resultant string
13. How compareTo( ) method differs from compareToIgnoreCase ( ) method ?
14. Explain how to check the occurance of a substring in a given string.
15. Explain the following built in methods with respect to string buffer class :
i. Capacity ( )
ii. delete ( )
iii. replace ( )
iv. append ( )
v. substring ( )
16. Explain any two character handling functions in string class
17. Write a java program to sort names in bubble sort .
18. Explain string comparison function with suitable programs
19. Explain indexof( ) and Lastindexof ( ) methods of string class with an example
20. What is tostring( ) function ? write a program to override tostring( ) and provide you
string representations.
21. Write a program in java to replace all the matching substring with a given string .

You might also like