Java String Manipulation: Properties and Methods, Quizzes of Data Structures and Algorithms

Various properties and methods of java strings, including treating strings as single units, creating strings from character arrays, determining string length, accessing characters, comparing strings, and manipulating strings using methods like substring, concat, valueof, stringbuffer, scanner, and stringtokenizer.

Typology: Quizzes

Pre 2010

Uploaded on 08/01/2009

koofers-user-pwo
koofers-user-pwo 🇺🇸

3

(1)

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1. Is string series of characters treated as single unit?
a. TRUE
2. Class string represent characters in java ....
False
3. char charArray[] = { 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a', 'y' };
String s4 = new String( charArray, 6, 3 );
a. s4=”day”
4. Method length determines the length of a String
a. TRUE
5. Method charAt Get character at specific location in String
6. Method equals tests two objects for equality using lexicographical comparison
a. TRUE
7. Method startsWith determines if String starts with specified characters
a. TRUE
8. Method indexOf finds last occurrence of character in String
a. FALSE
9. String letters = "abcdefghijklmabcdefghijklm";
letters.substring( 20 ) );
a. Hijklm
10. String s1 = new String( "Happy " );
String s2 = new String( "Birthday" );
s1.concat( s2 )
a. Happy Birthday
11. Method valueOf returns String representation of object, data, etc.
a. TRUE
12. StringBuffer buffer2 = new StringBuffer( 10 );
System.out.printf( "buffer2 = \"%s\"\n", buffer2.toString() );
a. buffer2 = ""
13. method append Allow data values to be added to StringBuffer
14. Method insert Allows data-type values to be inserted into StringBuffer
15. Scanner scanner = new Scanner( System.in );
scans the input from console
a. True
16. java.util.StringTokenizer Partition String into individual substrings
17. String method replaceAll replaces the first occurrence of a pattern match
a. FALSE

Partial preview of the text

Download Java String Manipulation: Properties and Methods and more Quizzes Data Structures and Algorithms in PDF only on Docsity!

1. Is string series of characters treated as single unit? a. TRUE 2. Class string represent characters in java .... False 3. char charArray[] = { 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a', 'y' }; String s4 = new String( charArray, 6, 3 ); a. s4=”day” 4. Method length determines the length of a String a. TRUE 5. Method charAt Get character at specific location in String 6. Method equals tests two objects for equality using lexicographical comparison a. TRUE 7. Method startsWith determines if String starts with specified characters a. TRUE 8. Method indexOf finds last occurrence of character in String a. FALSE 9. String letters = "abcdefghijklmabcdefghijklm"; letters.substring( 20 ) ); a. Hijklm 10. String s1 = new String( "Happy " ); String s2 = new String( "Birthday" ); s1.concat( s2 ) a. Happy Birthday 11. Method valueOf returns String representation of object, data, etc. a. TRUE 12. StringBuffer buffer2 = new StringBuffer( 10 ); System.out.printf( "buffer2 = "%s"\n", buffer2.toString() ); a. buffer2 = "" 13. method append Allow data values to be added to StringBuffer 14. Method insert Allows data-type values to be inserted into StringBuffer 15. Scanner scanner = new Scanner( System.in ); scans the input from console a. True 16. java.util.StringTokenizer Partition String into individual substrings 17. String method replaceAll replaces the first occurrence of a pattern match a. FALSE