Introduction to Java Programming, Sixth Edition, Y. Daniel Liang
Chapter 26 Internationalization
Section 26.2 The Locale Class
1
How do you set a button jbt's text to a character with the Unicode 13AE?
A.
jbt.setText("13AE");
B.
jbt.setText("\13AE");
C.
jbt.setText("\u13AE");
D.
jbt.setText("/u13AE");
E.
jbt.setText('\u13AE');
2
How do you create a locale for the United States?
A.
new Locale("en", "US");
B.
new Locale("US", "en");
C.
Locale.US;
D.
Locale.getLocale("en", "US")
3
Which of the following methods is defined in the Locale class?
A.
getLanguage();
B.
getCountry();
C.
getVariant();
D.
all the above;
4
Which of the following method is correct to obtain the available locales in the classes Calendar, Collator, DateFormat, and NumberFormat?
A.
getLocales();
B.
getAllLocales();
C.
getAvailableLocales();
D.
None of the above;
5
Which of the following classes have the getAvailableLocales() method?
A.
Calendar
B.
Collator
C.
DateFormat
D.
NumberFormat
Section 26.3 Processing Date and Time
6
Which of the following set of code lines displays the current time in locale sensitive format?
A.
GregorianCalendar gcal = new GregorianCalendar(); System.out.println(gcal.toString());
B.
Date d = new Date(); System.out.println(d.toString());
C.
GregorianCalendar gcal = new GregorianCalendar(new TimeZone("CST")); System.out.println(gcal.toString());
D.
GregorianCalendar gcal = new GregorianCalendar(); DateFormat myFormat = DateFormat.getDateTimeInstance(); myFormat.setTimeZone(TimeZone.getTimeZone("CST")); System.out.println(myFormat.format(gcal.getTime()));
7
Which of the following code is correct to obtain hour from a Calendar object cal?
A.
cal.getHour();
B.
cal.hour();
C.
cal.get(Hour);
D.
cal.get(Calendar.HOUR);
8
Which of the following code is correct to set a time zone in a Calendar object?
A.
cal.timeZone("CST");
B.
cal.setTimeZone("CST");
C.
cal.getTimeZone();
D.
cal.get(Calendar.HOUR);
9
Which of the following constants are the valid date and time format?
A.
DateFormat.SHORT
B.
DateFormat.MEDIUM
C.
DateFormat.LONG
D.
DateFormat.FULL
10
Which of the following statements are true?
A.
SimpleDateFormat is a subclass of DateFormat.
B.
DateFormatSymbols is a subclass of SimpleDateFormat.
C.
SimpleDateFormat enables you to choose any user-defined pattern for date and time formatting.
D.
You can obtain localizable date-time formatting data, such as the names of the months, the names of the days of the week, and the time zone data, from an instance of DateFormatSymbols.
11
Suppose DateFormatSymbols symbols = new DateFormatSymbols(), Which of the following statement is correct to return month names?
A.
String[] monthNames = symbols.getMonths();
B.
String[] weekdayNames = symbols.getWeekdays();
C.
String[] eras = symbols.getEras();
D.
String[] eras = symbols.getAmPmStrings();
12
Which of the following are in the java.text package?
A.
DateFormatSymbols
B.
DateFormat
C.
SimpleDateFormat
D.
Date
E.
Locale
Section 26.4 Formatting Numbers
13
Which of the following code is correct to create an instance for formatting numbers?
A.
NumberFormat.getInstance();
B.
NumberFormat.getNumberInstance(locale);
C.
NumberFormat.getInstance(locale);
D.
NumberFormat.getNumberFormatInstance(locale);;
14
Which of the following code is correct to create an instance for formatting numbers in currency?
A.
NumberFormat.getCurrencyInstance(locale);
B.
NumberFormat.getCurrencyInstance();
C.
NumberFormat.currencyInstance(locale);
D.
NumberFormat.currencyInstance();
15
Which of the following code is correct to create an instance for formatting numbers in percent?
A.
NumberFormat.getPercentInstance(locale);
B.
NumberFormat.getPercentInstance();
C.
NumberFormat.percentInstance(locale);
D.
NumberFormat.percentInstance();
16
Which of the following are valid methods in NumberFormat?
A.
format(double)
B.
format(long)
C.
setMaximumIntegerDigits(int)
D.
setMinimumIntegerDigits(int)
17
Which of the following code displays the numbers with at least two digits before and after the decimal point?
A.
NumberFormat numberForm = NumberFormat.getNumberInstance(); DecimalFormat df = (DecimalFormat)numberForm;<br>df.applyPattern("00.00");
B.
NumberFormat numberForm = NumberFormat.getNumberInstance(); numberForm.setMaximumFractionDigits(2); numberForm.setMinimumFractionDigits(2);
C.
NumberFormat numberForm = NumberFormat.getNumberInstance();<br>numberForm.setMaximumFractionDigits(2);
18
Suppose that NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(Locale.US). Which of the following statement is legal?
A.
Number number = NumberFormat.parse("$5,000.56");
B.
Number number = currencyFormat.parse("$5,000.56");
C.
Number number = currencyFormat.parseCurrency("$5,000.56");
D.
Number number = currencyFormat.parse("5,000.56");
19
Which of the following statements are true?
A.
DecimalFormat is a subclass of NumberFormat.
B.
You can create an instance of DecimalFormat using new DecimalFormat(Local).
C.
You can create an instance of NumberFormat using new NumberFormat(Local).
D.
You can create an instance of NumberFormat using the static factory methods in NumberFormat.
E.
An instance created using the static factory methods in NumberFormat is also an instance of DecimalFormat.
20
Which of the following statements are true regarding DecimalFormat?
A.
A pattern can specify the minimum number of digits before the decimal point and the maximum number of digits after the decimal point.
B.
The characters '0' and '#' are used to specify a required digit and an optional digit, respectively.
C.
The optional digit is not displayed if it is zero.
D.
If there are more actual digits before the decimal point, all the digits are displayed.
E.
If there are more digits after the decimal point, the digits are rounded.
21
Suppose you apply the pattern "00.0##" on a DecimalFormat object f using f.applyPattern("00.0##"). What the return value from decimalFormat.format(111.2226)?
A.
11.223
B.
111.222
C.
111.223
D.
11.2226
22
Suppose you apply the pattern "00.0##%" on a DecimalFormat object f using f.applyPattern("00.0##"). What the return value from decimalFormat.format(111.2226)?
A.
11.223%
B.
111.222%
C.
11122.3%
D.
1122.3%
E.
11122.26%
Section 14.5 Resource Bundles (Optional)
23
A resource bundle is ___________
A.
a Java source code the contains image, audio, and text files.
B.
a Java class file or a text file that provides locale-specific information.
C.
an image file.
D.
an audio file.
24
Which of the following code is correct to create an instance of ResourceBundle?
A.
ResourceBundle.getBundle();
B.
ResourceBundle.getBundle(locale);
C.
ResourceBundle.getBundle(resourcefilename);
D.
ResourceBundle.getBundle(resourcefilename, locale);