Answer B QUESTION 177 Given NumberFormat nf

Answer b question 177 given numberformat nf

This preview shows page 87 - 91 out of 144 pages.

Answer: B QUESTION 177 Given: NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(4); nf.setMinimumFractionDigits(2); String a = nf.format(3.1415926); 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.
Image of page 87
Answer: CF QUESTION 178 Which three statements concerning the use of the java.io.Serializable interface are true? (Choose three.) A. Objects from classes that use aggregation cannot be serialized. B. An object serialized on one JVM can be successfully deserialized on a different JVM. C. The values in fields with the volatile modifier will NOT survive serialization and deserialization. D. The values in fields with the transient modifier will NOT survive serialization and deserialization. E. It is legal to serialize an object of a type that has a supertype that does NOT implement java.io.Serializable. Answer: BDE QUESTION 179 Given: 12. String csv = "Sue,5,true,3"; 13. Scanner scanner = new Scanner( csv ); 14. scanner.useDelimiter(","); 15. int age = scanner.nextInt(); What is the result? A. Compilation fails. B. After line 15, the value of age is 5. C. After line 15, the value of age is 3. D. An exception is thrown at runtime. Answer: D Explanation/Reference: Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at Breaker.main(Breaker.java:8 ) QUESTION 180 Given: 11. String test = "a1b2c3"; 12. String[] tokens = test.split("\\d"); 13. for (String s: tokens) System.out.print(s + " "); What is the result? A. a b c B. 1 2 3 C. a1b2c3
Image of page 88
D. a1 b2 c3 E. Compilation fails. F. The code runs with no output. G. An exception is thrown at runtime. Answer: A QUESTION 181 Given: 33. Date d = new Date(0); 34. String ds = "December 15, 2004"; 35. // insert code here 36. try { 37. d = df.parse(ds); 38. } 39. catch (ParseException e) { 40. System.out.println("Unable to parse " + ds); 41. } 42. // insert code here too What creates the appropriate DateFormat object and adds a day to the Date object? A. 35. DateFormat df = DateFormat.getDateFormat(); 42. d.setTime( (60 * 60 * 24) + d.getTime()); B. 35. DateFormat df = DateFormat.getDateInstance(); 42. d.setTime( (1000 * 60 * 60 * 24) + d.getTime()); C. 35. DateFormat df = DateFormat.getDateFormat(); 42. d.setLocalTime( (1000*60*60*24) + d.getLocalTime()); D. 35. DateFormat df = DateFormat.getDateInstance(); 42. d.setLocalTime( (60 * 60 * 24) + d.getLocalTime()); Answer: B QUESTION 182 Given: 1. public class KungFu { 2. public static void main(String[] args) { 3. Integer x = 400; 4. Integer y = x; 5. x++; 6. StringBuilder sb1 = new StringBuilder("123"); 7. StringBuilder sb2 = sb1; 8. sb1.append("5"); 9. System. out .println((x == y) + " " + (sb1 == sb2)); 10. } 11. } What is the result? A. true true B. false true C. true false
Image of page 89
D. false false E. Compilation fails.
Image of page 90
Image of page 91

You've reached the end of your free preview.

Want to read all 144 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture