现有: 1. class Propeller2 { 2. pulolic static void main (String[]args)//add code here? 3. { new Propeller2().topGo(); } 4. 5.void topGo() //add code here? 6. { middleGo(); } 7. 8.void middleGo() //add code here? 9. { go(); System.out.println ("late middle"); } void go() //add code here? 12. {throw new Exception(); } 13. } 为使代码通过编译,需要在哪一行加入声明throws Exception?() A、只在第11行B、在第8行和第11行C、在第5行、第8行和第11行D、在第2行、第5行、第8行和第11行
现有: 1. class Propeller2 { 2. pulolic static void main (String[]args)//add code here? 3. { new Propeller2().topGo(); } 4. 5.void topGo() //add code here? 6. { middleGo(); } 7. 8.void middleGo() //add code here? 9. { go(); System.out.println ("late middle"); } void go() //add code here? 12. {throw new Exception(); } 13. } 为使代码通过编译,需要在哪一行加入声明throws Exception?()
- A、只在第11行
- B、在第8行和第11行
- C、在第5行、第8行和第11行
- D、在第2行、第5行、第8行和第11行
相关考题:
Which ensures that a JSP response is of type "text/plain"?()A、%@ page mimeType="text/plain" %B、%@ page contentType="text/plain" %C、%@ page pageEncoding="text/plain" %D、%@ page contentEncoding="text/plain" %E、% response.setEncoding("text/plain"); %
1. public class Exception Test { 2. class TestException extends Exception {} 3. public void runTest() throws TestException {} 4. public void test() /* Point X */ { 5. runTest(); 6. } 7. } At Point X on line 4, which code is necessary to make the code compile?() A、 No code is necessary.B、 throws ExceptionC、 catch ( Exception e )D、 throws RuntimeExceptionE、 catch ( TestException e)
Which statement is true if the doStartTag method returns EVAL_BODY_BUFFERED?()A、The tag handler must implement BodyTag.B、The doAfterBody method is NOT called.C、The setBodyContent method is called once.D、It is never legal to return EVAL_BODY_BUFFERED from doStartTag.
What will be the result of attempting to compile and run the following program?() public class Q28fd { public static void main(String args[]) { int counter = 0; l1: for (int i=10; i0; i--) { l2: int j = 0; while (j 10) { if (j i) break l2; if (i == j) { counter++; continue l1; } } counter--; } System.out.println(counter); } } A、The program will fail to compile.B、The program will not terminate normally.C、The program will write 10 to the standard output.D、The program will write 0 to the standard output.E、The program will write 9 to the standard output.
Given that a scoped attribute cart exist only in a user’s session, which two, taken independently, ensure the scoped attribute cart no longer exists?()A、 ${cart = null } B、 c:remove var=”cart” / C、 c:remove var=”${cart}” / D、 c:remove var=”cart” scope=”session” / E、 c:remove scope=”session”cart/c:removeF、 c:remove var=”${cart}” scope=”session” / G、 c:remove scope=”session”${cart}/c:remove
GivenafileGrizzlyBear.java: 1.package animals.mammals; 2. 3.public class GrizzlyBear extends Bear{ 4.voidhunt(){ 5.Salmons=findSalmon(); 6.s.consume(); 7.} 8.} and another file,Salmon.java: 1.packageanimals.fish; 2. 3.public class Salmon extends Fish{ 4.voidconsume(){/*dostuff*/} 5.} Assume both classes are defined in the correct directories for theft packages,and that the Mammal class correctly defines the findSalmon()method.Which two changes allow this code to compile correctly?()A、add public to the start of line 4 in Salmon.javaB、add public to the start of line 4 in GrizzlyBear.javaC、add import animals.mammals.*;at line 2 in Salmon.javaD、add import animals.fish.*at line 2 in GrizzlyBear.javaE、add import animals.fish.Salmon.*;at line 2 in GrizzlyBear.javaF、add import animals.mammals.GrizzlyBear.*;at line 2 in Salmon.java
下面有关JVM内存,说法错误的是()。A、程序计数器是一个比较小的内存区域,用于指示当前线程所执行的字节码执行到了第几行,是线程隔离的B、Java方法执行内存模型,用于存储局部变量,操作数栈,动态链接,方法出口等信息,是线程隔离的C、方法区用于存储JVM加载的类信息、常量、静态变量、即使编译器编译后的代码等数据,是线程隔离的D、原则上讲,所有的对象都在堆区上分配内存,是线程之间共享的
3. import java.util.*; 4. class ForInTest { 5. static List list = new ArrayList(); 6. 7. public static void main(String [] 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(Object o : list)B、 for(Iterator o : list)C、 for(Object o : list.iterator())D、 for(Iterator o : list.iterator(); o.hasNext (); )