String Processing Flashcards
Which deprecated class splits a String into elements but does not support enhanced for iteration?
StringTokenizer
In a regular expression, which character indicates an optional subpattern that can match only once?
?
What does the format parameter %s specify?
String conversion
In a regular expression, which metacharacter specifies a word boundary?
\b
In a regular expression, which metacharacter specifies an upper/lowercase letter or digit?
\w
In a regular expression, which character indicates zero or more subpattern match?
*
In a format string, what does the % character specify?
The beginning of a format parameter
In a String, which character is required to escape the initial backslash for Java?
\
When using manipulation methods of the StringBuffer and StringBuilder class, how is the underlying String affected?
The underlying String is modified.
What does the format parameter %b specify?
Boolean conversion
When using the format parameter %b, which two values will convert to false?
false, null
Which String method accepts a regular expression and replacement string for each match, and returns a manipulated string?
replaceAll
Which Scanner method accepts a regular expression and returns the next match found in the source line?
findInLine
In a format string, what does the $ character specify?
the end of an argument location
What does “3” in format string %3.4s represent
Minimum number of characters to output.
What does “4” in format string %3.4s represent
The number of characters of the argument string to output.
What would the following printf statement output:
System.out.printf(““,1234);
>
1234
What would the following printf statement output:
System.out.printf(““,1234);
> 1234
What does format flag “-“ do?
System.out.printf(““,1234);
Left justifies (default is right justify)
What does format flag “+” do?
Outputs a plus or minus sign for a numerical value.
What would the following statement output?
System.out.printf(““,1);
> +000000001
Can more than one format flag be used in a format statement?
Yes,
System.out.printf(“>%0+10d+000000001
What is the output of this statement?
System.out.printf(““,1);
java.util.IllegalFormatFlagsException
Using “0” for zero fill and “-“ for left jistify together is not valid.
What does format flag “0” do?
forces numerical values to be zero-padded (default is blank padding).