Given:.
2. import java.text.*; 3. public class Main { 4. public static void main(String[] args) throws Exception { 5. String s = "123.456xyz"; 6. NumberFormat nf = NumberFormat.getInstance(); 7. System.out.println(nf.parse(s)); 8. nf.setMaximumFractionDigits(2); 9. System.out.println(nf.format(s)); 10. } //from w ww . ja va 2s .c o m 11. }
Which are true? (Choose all that apply.).
C and E are correct.
The invocation of parse()
will return 123.456.
The invocation of format()
will throw an exception.