SCJP 1.6版考題 169
出自 陳富國維基館
Given: 12. NumberFormat nf = NumberFormat.getInstance(); 13. nf.setMaximumFractionDigits(4); 14. nf.setMinimumFractionDigits(2); 15. String a = nf.format(3.1415926); 16. String b = nf.format(2); Which two statements are true about The result if the default locale is Locale.US? (Choose two.) A. The value of b is 2. B. The value of a is 3.14. C. The value of b is 2.00. D. The value of a is 3.141. E. The value of a is 3.1415. F. The value of a is 3.1416. G. The value of b is 2.0000.
解答
Ans: C F
解說:
那二個敘述是真的? 預設的locale是Locale.US nf.setMaximumFractionDigits(4); 設定小數位置最大4位,若發生截位,則進行4捨5入,如F nf.setMinimumFractionDigits(2); 設定小數位置最小2位,如C
|