下列代码中给出正确的在方法体内抛出异常的是( )。
A: new throw Exception(" ");
B: throw new Exception(" ");
C: throws IOException();
D: throws IOException;
A: new throw Exception(" ");
B: throw new Exception(" ");
C: throws IOException();
D: throws IOException;
举一反三
- 能在方法体内正确抛出异常的语句是: A: new throw Exception(",,,,,,"); B: throw newException(",,,,,,"); C: throws newException(",,,,,,"); D: thrownewException;
- 下面语句中不存在语法错误的选项是( )。 A: throw new NullPointerException(); B: throw “Exception”; C: throw new Exception(); D: throw new IOException();
- 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
- 下列方法声明部分正确的有哪些? A: public void method() throws Exception B: public void method() throw Exception C: public void method() throws IOException D: public void method() throws RuntimeException
- 若testFails()方法返回true,选项( )是下列代码的执行结果public void method() throws IOException{ If(testFails()){ throw new IOExcetpion(); }} A: method()方法处理IOException异常 B: method()方法将IOException抛出,由调用它的方法处理该异常 C: 由系统处理异常 D: 不做任何处理