问题:多选题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?()AThe value of b is 2.00.BThe value of a is 3.141.CThe value of a is 3.14.DThe value of b is 2.0000.EThe value of a is 3.1415.FThe value of a is 3.1416.GThe value of b is 2.
查看答案
问题:多选题Given: 10. class One { 11. void foo() { } 12. } 13. class Two extends One { 14. //insert method here 15. } Which three methods, inserted individually at line 14, will correctly complete class Two?()Apublic void foo() { /* more code here */ }Bprivate void foo() { /* more code here */ }Cprotected void foo() { /* more code here */ }Dint foo() { /* more code here */ }Evoid foo() { /* more code here */ }
问题:单选题Given: What is the result?()AAn exception is thrown at runtime.Br, e, o,CCompilation fails.Dr, t, t,
问题:单选题Given: What is the result?()AABBCCDDEE
问题:多选题Which two code fragments correctly create and initialize a static array of int elements?()AABBCCDD
问题:多选题A JavaBeans component has the following field: 11. private boolean enabled; Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()AABBCCDD
问题:单选题Given the command line java Pass2 and: What is the result? ()AdoStuff x = 6 main x = 6BCompilation fails.CdoStuff x = 6 main x = 7DAn exception is thrown at runtime.EdoStuff x = 7 main x = 6FdoStuff x = 7 main x = 7
问题:单选题Given: 11. String test = "This is a test"; 12. String[] tokens = test.split("/s"); 13. System.out.println(tokens.length); What is the result?()AAn exception is thrown at runtime.B1C4DCompilation fails.E0
问题:单选题Given: Which code, inserted at line 15, creates an instance of the Point class defined in Line?()ALine l = new Line() ; l.Point p = new l.Point();BLine.Point p = new Line.Point();CThe Point class cannot be instatiated at line 15.DPoint p = new Point();
问题:单选题Given: 11. public void genNumbers() { 12. ArrayList numbers = new ArrayList(); 13. for (int i=0; i<10; i++) { 14. int value = i * ((int) Math.random()); 15. Integer intObj = new Integer(value); 16. numbers.add(intObj); 17. } 18. System.out.println(numbers); 19. } Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()ALine 19BThe object is NOT a candidate for garbage collection.CLine 17DLine 16ELine 18
问题:单选题Click the Exhibit button. Given: ClassA a = new ClassA(); a.methodA(); What is the result?()AThe code runs with no output.BCompilation fails.CAn exception is thrown at runtime.DClassC is displayed.
问题:单选题Given: 11. public static void main(String[] args) { 12. Object obj = new int[] { 1, 2, 3 }; 13. int[] someArray = (int[])obj; 14. for (int i : someArray) System.out.print(i + " "); 15. } What is the result? ()ACompilation fails because of an error in line 13.BA ClassCastException is thrown at runtime.C1 2 3DCompilation fails because of an error in line 14.ECompilation fails because of an error in line 12.
问题:单选题Given: 11. static class A { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println("B "); } 16. } 17. public static void main(String[] args) { 18. A a = new B(); 19. a.process(); 20. } What is the result? ()ACompilation fails because of an error in line 19.BAn exception is thrown at runtime.CBDCompilation fails because of an error in line 18.ECompilation fails because of an error in line 15. FThe code runs with no output.
问题:多选题Click the Exhibit button. Given: Which two statements are true if a NullPointerException is thrown on line 3 of class C?()AThe application will crash.BThe code on line 29 will be executed.CThe code on line 5 of class A will execute.DThe exception will be propagated back to line 27.EThe code on line 5 of class B will execute.