问题: 10. public class Bar { 11.static void foo(int...x) { 12. // insert code here 13. } 14. } Which two code fragments, inserted independently at line 12, will allow the class to compile?()A、 foreach(x) System.out.println(z);B、 for(int z : x) System.out.println(z);C、 while( x.hasNext()) System.out.println( x.next());D、 for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
查看答案
问题:下列哪项是String的字面量?() A、“Hello”B、‘world’C、/u2345D、new String(“good”)
问题: 现有: 1. import java.util.*; 2. class ForInTest { 3.static List list - new ArrayList(): 4. 5.static List getList() { return list; } 6. 7.public static void main (Strincj[] args) { 8.list.add("a"); list.add("b"); list.add("c"); 9. //insert code here 10. System.out.print (o); 11. } 12. } 第9行插入哪一项将输出abc?() A、 for(char o: list)B、 for (Object o: o.getList())C、 for(Object o: getList();)D、 for(Object o: getList())E、 for(Object o: o.getList();)
问题:Java中方法绑定有哪些形式?()A、编译时刻绑定B、运行时刻绑定C、静态绑定D、私有绑定
问题: Given: 11.<% 12.request.setAttribute("vals", new String[]{"1","2","3","4"}); 13.request.setAttribute("index", "2"); 14.%> 15.<%-- insert code here --%> Which three EL expressions, inserted at line 15,are valid and evaluate to "3"?()A、${vals.2}B、${vals["2"]}C、${vals.index}D、${vals[index]}E、${vals}[index]F、${vals[vals[index-1]]}
问题:Which of the following statements about variables and their scopes are true? () A、 Instance variables are member variables of a class.B、 Instance variables are declared with the static keyword.C、 Local variables defined inside a method are created when the method is executed.D、 Local variables must be initialized before they are used.
问题:Which expressions are correct to declare an array of 10 String objects? () A、 char str[];B、 char str[][];C、 String str[];D、 String str[10];
问题: 1. public class GC { 2. private Object o; 3. private void doSomethingElse(Object obj) { o = obj; } 4. public void doSomething() { 5. Object o = new Object(); 6. doSomethingElse(o); 7. o = new Object(); 8. doSomethingElse(null); 9.o=null; 10. } 11. } When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?() A、 Line 5B、 Line 6C、 Line 7D、 Line 8E、 Line 9F、 Line 10
问题:HTTP中的POST和GET在下列哪些方面有区别()。A、数据位置B、明文密文C、数据安全D、长度限度E、应用场景
问题: public class Test { public static void main(String[] args) { int x = 0; assert (x > 0): “assertion failed”; System.out.println(“finished”); } } What is the result?() A、 finishedB、 Compilation fails.C、 An AssertionError is thrown.D、 An AssertionError is thrown and finished is output.
问题:能够遍历泛型List〈Integer〉 al中的所有元素的语句是哪项?() A、for(Integer i : al)B、for(i : al)C、for(al)D、forEach(Integer i : al)
问题: public static void parse(String str) { try { float f= Float.parseFloat(str); } catch (NumberFormatException nfe) { f= 0; } finally { System.out.println(f); } } public static void main(String[] args) { parse(”invalid”); } What is the result?() A、 0.0B、 Compilation fails.C、 A ParseException is thrown by the parse method at runtime.D、 A NumberFormatException is thrown by the parse method at runtime.
问题:以下有关接口的叙述错误的是哪项?() A、 一个类可以实现多个接口B、 接口不能被继承C、 类实现接口时必须实现其中的方法D、 接口中只能包含抽象方法和常量
问题: public class ForBar { public static void main(String args) { int i = 0, j = 5; tp: for (;;) { i ++; for(;;) if(i > --j) break tp; } system.out.printIn(“i = ” + i + “, j = “+ j); } } What is the result? () A、 The program runs and prints “i=1, j=0”B、 The program runs and prints “i=1, j=4”C、 The program runs and prints “i=3, j=4”D、 The program runs and prints “i=3, j=0”E、 An error at line 4 causes compilation to fail.F、 An error at line 7 causes compilation to fail.
问题: 现有: public class Tester { public static void main (String[] args) { intx-5; Integer xl=x; Integer x2=x; int x3=new Integer(5); system..ut.print(x1.equals(x)); system..ut.print(xl==x); system..ut.print(x2.equals(xl)); system..ut.print(x2==xl); system..ut.print(x2==x3); system..ut.print(x2.equals(x3)); } } 结果为:() A、编译失败B、falsefalsetruetruetruetrueC、truetruetruetruetruetrueD、falsefalsetruetruetruefalseE、truefalsetruefalsefalsetrueF、运行时异常被抛出
问题:Which statement is true about assertion in the Java programming language?() A、 Assertion expressions should not contain side effects.B、 Assertion expression values can be any primitive type.C、 Assertion should be used for enforcing preconditions on public methods.D、 An AssertionError thrown as a result of a failed assertion should always be handled by the enclosing method.
问题: 现有: 1. class Book { 2. private final void read() { System.out.print("book "); } 3. } 4. class Page extends Book { 5. public static void main(String [] args) { 6. // insert code here 7. } 8. private final void read() { System.out.print("page "); } 9. } 和如下三个代码片段 ( x, y, z ): x. // just a comment y. new Page().read(); z. new Book().read(); 分别插入到第6行,有几个允许代码通过编译并可以运行且无异常?() A、 0B、 1C、 2D、 3
问题: A developer is designing a multi-tier web application and discovers a need to hide the details of establishingand maintaining remote communications from the client. In addition, the application needs to find,in a transparent manner,the heterogeneous business components used to service the client’s requests. Which design patterns, working together, address these issues?()A、Business Delegate and Transfer ObjectB、Business Delegate and Service LocatorC、Front Controller and Business DelegateD、Intercepting Filter and Transfer Object
问题:Which statements concerning the event model of the AWT are true?() A、At most one listener of each type can be registered with a component.B、Mouse motion listeners can be registered on a List instance.C、There exists a class named ContainerEvent in package java.awt.event.D、There exists a class named MouseMotionEvent in package java.awt.event.E、There exists a class named ActionAdapter in package java.awt.event.
问题:不可见组件如何起到调整间距的作用?()A、 刚性区域就是一种面板,组件在其中会有相同的间距B、 刚性区域是一块宽度或者高度固定的区域,它可以分隔两个组件C、 胶状区域就像胶水一样,将两边的组件尽量索靠D、 胶状区域的宽度或高度不固定,它会尽量将组件向两边顶,从而扩大两个组件的间隔E、 自定义区域的最大,最小尺寸有一定的限制,从而将两个组件的间距设到指定的范围以内