A: public abstract int read( ) throws IOException
B: public final void writeInt (int throws IOException
C: public void close( )throws IOException
D: public int available( )throws IOException
举一反三
- 下列方法声明部分正确的有哪些? A: public void method() throws Exception B: public void method() throw Exception C: public void method() throws IOException D: public void method() throws RuntimeException
- methodName()方法将抛出IOException异常,方法正确定义的形式是() A: public<br/>IOException methodName() B: public<br/>void methodName() throw new IOException C: public<br/>void methodName() throw IOException D: public<br/>void methodName() throws IOException
- 给出下列程序的输出结果。import java.io.IOException;public class E {public static void main(String args[]){int m =10;try {methodA();m = 100;}catch(IOException e){m = 1000;}System.out.println(m);}public static void methodA() throws IOException{throw new IOException();}}
- LoginServlet是一个Servlet类,代码如下 public class LoginServlet extends ___________ { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { … } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { … } } 在下划线处应填写()
- 有如下代码段:1) A: { if(unsafe()){//do something…} B: else if(safe()){//do the other…} C: } 其中,方法unsafe() 将抛出IOException, 请问可将以下哪项填入第1行。 D: public IOException methodName() E: public void methodName() F: public void methodName() throw IOException G: public void methodName() throws IOException
内容
- 0
请说出下列程序的输出结果_____________,_____________。import java.io.IOException;public class E {public static void main(String args[]){try { methodA();}catch(IOException e){System.out.print("你好");return;}finally {System.out.println("thanks");}}public static void methodA() throws IOException{throw new IOException();}}
- 1
给定如下所示的Java Servlet代码片段,用户在浏览器地址栏中键入正确的请求URL并回车后,在控制台上显示的结果是()。 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ System.out.println(“get”); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ System.out.println(“post”); } protected void service(HttpServletRequest req, HttpSergvletResponse resp) throws ServletException, IOException{ System.out.println(“service”); }
- 2
中国大学MOOC: 若testFails()方法返回true,选项( )是下列代码的执行结果public void method() throws IOException{ If(testFails()){ throw new IOExcetpion(); }}
- 3
类Test1、Test2定义如下: A: public class Test1 B: { public float aMethod(float a,float b) throws C: IOException { } D: } E: public class Test2 extends Test1{ F: G: } 将以下哪种方法插入行6是不合法的。 H: float aMethod(float a,float b){ } I: public int aMethod(int a,int b)throws Exception{ } J: public float aMethod(float p,float q){ } K: 都不对
- 4
中国大学MOOC: 给定某Servlet程序的片段如下,用户在浏览器地址栏中键盘键入正确的请求URL并回车后,在控制台上显示的结果是( )。 public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException ,IOException{ System.out.println(get); } public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException ,IOException { System.out.println(post); }