Quiz 6
Friday
With a piece of paper, write down your name and answers to the following questions.
What is one of the methods that are common to both the
String
and theStringBuilder
classes?length
insert
append
delete
The
isLetter
,isDigit
, andisUpperCase
methods are members of which class?Char
Character
StringBuilder
String
These
static
final
variables are members of the numeric wrapper classes, and they hold the minimum and maximum values for a particular data type. What are they?MIN_VALUE
andMAX_VALUE
MIN
andMAX
MINIMUM
andMAXIMUM
LOWEST
andHIGHEST
Is the following statement correct, and why?
To use a numeric wrapper class, such as
Character
, you need to write the correspondingimport
statement.Answer: False, first, the
Character
wrapper class is not numeric; second, wrapper classes are part of thejava.lang
package, so there is no need for animport
statement.Find and correct the error in the following program.
import java.util.StringTokenizer; public class Program { public static void main(final String[] args) { // Tokenize a string that is delimited with semicolons. This // string contains three tokens: "one", "two", and "three". StringTokenizer tokenizer = new StringTokenizer("one;two;three"); while (tokenizer.hasMoreTokens()) System.out.println(tokenizer.nextToken()); } }
Correction:
import java.util.StringTokenizer; public class Program { public static void main(final String[] args) { // Tokenize a string that is delimited with semicolons. This // string contains three tokens: "one", "two", and "three". StringTokenizer tokenizer = new StringTokenizer("one;two;three", ";"); while (tokenizer.hasMoreTokens()) System.out.println(tokenizer.nextToken()); } }
Or:
import java.util.StringTokenizer; public class Program { public static void main(final String[] args) { // Tokenize a string that is delimited with spaces. This // string contains three tokens: "one", "two", and "three". StringTokenizer tokenizer = new StringTokenizer("one two three"); while (tokenizer.hasMoreTokens()) System.out.println(tokenizer.nextToken()); } }
Student Performance and Statistics
A histogram of student performance on percentage grades for Quiz 6 on Friday.
A table showing the average performance for each question in Quiz 6 on Friday.