Given the proper imports, and given:
17. public void go() { 18. NumberFormat nf, nf2; //from www .jav a2s . c o m 19. Number n; 20. Locale[] la = NumberFormat.getAvailableLocales(); 21. for(int x=0; x < 10; x++) { 22. nf = NumberFormat.getCurrencyInstance(la[x]); 23. System.out.println(nf.format(123.456f)); 24. } 25. nf2 = NumberFormat.getInstance(); 26. n = nf2.parse("123.456f"); 27. System.out.println(n); 28. }
Given that line 20 is legal, which are true? (Choose all that apply.)
A is correct.
The parse()
method throws an Exception that must be handled or declared.
If the exception was handled, C, D, and E would be correct.
Remember that when you create a NumberFormat object, its Locale is immutable, but in this code we're creating a new NumberFormat object with each iteration of the loop.