Java中,自定义异常代码( )。
A: public class MyException implents Exception{ }
B: class MyException extends Throwable{ }
C: class MyException { }
D: class MyException extends Exception{ }
A: public class MyException implents Exception{ }
B: class MyException extends Throwable{ }
C: class MyException { }
D: class MyException extends Exception{ }
举一反三
- class MyException extends (1) { } public class Demo { public static void main(String[] args) { try { show(); } catch ( (2) e) { e.printStackTrace(); } } public static void show() (3) MyException { throw new MyException(); } 以上程序,创建了一个自定义异常(编译异常),请补全空白处代码
- 检查下面的代码:class E1 extends Exception{ }class E2 extends E1 { } public class Quiz6_5{ public static void main(String[] args){ try{ throw new E1(); } // --X-- }}下列语句,哪一个可以放到--X--位置,而且保证编译成功。 A: catch(El x){} B: catch(Exception x){} C: catch(MyException x){ } D: catch(E2 x){}
- 下列哪些是合法的类定义语句 A: public class A {} B: class A extends Exception,I0Exception {} C: public class 1A extends Object D: public class String {}
- 中国大学MOOC:"如下程序的输出是什么____#include #include using namespace std;struct MyException : public exception{ const char * what () const throw () { return "C++ Exception"; }};int main(){ try { throw MyException(); } catch(MyException& e) { std::cout << "MyException" << std::endl; } catch(std::exception& e) { std::cout<<"exception" << std::endl; }}";
- 下列各种java类的定义,那种是错误的 A: class Animal{}class Dog extends Animal {} B: final class Animal{}class Dog extends Animal{} C: abstract class Animal{}class Dog extends Animal{} D: public class Animal{}class Dog extends Animal{}