Java Reference
In-Depth Information
18. What is the result of the following code?
10. DecimalFormat df = new DecimalFormat(“#,#00.00##”);
11. double d = 3.141592653;
12. System.out.println(df.format(d));
A. 03.1415
B. 3.0016
C. 3.1416
D. 03.1416
E. 00.0015
19. What is the result of the following code?
10. try {
11. NumberFormat nf =
12. NumberFormat.getPercentInstance(Locale.US);
13. String s = “75%”;
14. double d = (Double) nf.parse(s);
15. System.out.println(d);
16. }catch(ParseException e) {
17. System.out.println(“Something failed”);
18. }
A. 75%
B. 0.75
C. 0.00
D. Something failed.
E. Line 14 generates a compiler error.
20. Given the following code:
3. try {
4. DateFormat df =
5. DateFormat.getDateInstance(DateFormat.SHORT,
6. Locale.US);
7. String s = “10/19/1987”;
8. Date d = df.parse(s);
9. System.out.println(d.getTime());
10. }catch(ParseException e) {
11. System.out.println(“Something failed”);
12. }
which of the following statements are true? (Select two.)
Search WWH ::




Custom Search