created: July 14, 2006


Quiz on Formatting

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.



1. The characters used in formatting numbers depends on the locale of the operating system. What is the name for this?

A.    universal locale
B.    automatic locale
C.    default locale
D.    virtual locale

2. A locale usually contains what two parts?

A.    time zone and language
B.    city and country
C.    language and dialect
D.    language and country

3. What class of object is used (in this chapter) to created formatted number strings?

A.    DecimalString
B.    DecimalFormat
C.    FloatingFormat
D.    Format

4. What character is usually used in a format pattern to indicate the thousand's separator, even in locales that use a different separator?

A.    . (dot)
B.    ; (semicolon)
C.    , (comma)
D.    / (slash)

5. What character is usually used in a format pattern to separate the integer part of a number from the fractional part (the decimal separator), even in locales that use a different separator?

A.    . (dot)
B.    ; (semicolon)
C.    , (comma)
D.    ' ' (space)

6. What character is usually used in a format pattern to separate the subpattern for positive numbers from the subpattern for negative numbers.

A.    . (dot)
B.    ; (semicolon)
C.    , (comma)
D.    % (percent)

7. What character is used in the format pattern to show where one of the digits '0' through '9' must go.

A.    #
B.    9
C.    0
D.    X

8. What character is used in the format pattern to show where one of the digits '0' through '9' may go, except that leading or trailing zeros are omitted?

A.    #
B.    9
C.    0
D.    X

9. When a floating point number is converted into a string what happens if there are two few digits in the format pattern for the integer part of the number?

A.    The output string shows the number rounded to the number of digits the format calls for.
B.    The output string shows the integer part truncated to the number of digits the format calls for.
C.    The output string shows the integer part with as many digits as needed to show it completely.
D.    An error string is output.

10. When a floating point number is converted into a string what happens if there are two few digits in the format pattern for the decimal fraction part of the number?

A.    The output string shows the number rounded to the number of digits the format calls for.
B.    The output string shows the number truncated to the number of digits the format calls for.
C.    The output string shows as many digits in the fraction are used as needed for full precision.
D.    An error string is output.

11. Which of the following format strings is appropriate for integers that will be converted to a minimum of 4 characters?

A.    0
B.    ####
C.    0000
D.    #

12. Which of the following format strings is appropriate for floating point numbers that will have at least one digit in the integer part and exactly one digit in the decimal fraction.

A.    0
B.    0;0
C.    #.0
D.    0.0

13. Which of the following format strings is appropriate for floating point numbers that will start with a + when positive and will start with a - when negative

A.    #0.0#
B.    #0.0#;-#0.0#
C.    +#0.0#;-#0.0#
D.    --#0.0#;-#0.0#

14. Which of the following format patterns is seriously incorrect?

A.    000.000#;-000.00#
B.    ###,000.###
C.    000,000.000,000
D.    Result = 0.0

15. Which of the following format patterns is seriously incorrect?

A.    000,000.###
B.    0000.00##
C.    ####.##00
D.    ###0.0#

The number you got right:       Percent Correct:       Letter Grade:   


Click here

If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.