Which of the following statements DOES NOTcome fromthe Art of War?
A. If you know the enemy and know yourself, you can fight a hundred battles with no danger of defeat.
B. A whole army may be robbed of its spirit, a commander-in-chief may be robbed of his presence of mind.
C. Out of thirty-six plans, the best is to get away at once.
D. All warfare is based on deception
查看答案
在异常处理中,如果要释放资源、关闭连接,关闭文件,关闭数据库,则由下列哪种代码块处理?
A. try
B. catch
C. finally
D. throws
对于catch子句的排列,下列说法正确的是对于catch子句的排列,下列哪种是正确的( )A、父类在先,子类在后B、子类在先,父类在后C、有继承关系的异常不能在同一个try程序段内
A. 父类在前,子类在后
B. 子类在前,父类在后
C. 谁在前谁在前都无所谓
D. 具有继承关系的异常不能在同一个try中出现
自定义异常类都必须继承自下列哪个类?
A. Error
B. Throwable
C. Exception
D. NullPointerException
定义一个司机类,司机的年龄必须在18到70之间否则抛出异常public class Driver{int age;Driver(){}Driver(int age){this.age=age;}public int getAge() __________ IllegalAge{if(this.age<18||this.age>70)__________ new IllegalAge();elsereturn age;}public void setAge(int age){this.age=age;}}定义异常类public class IllegalAge extends _____________{Driver d;public String toString(){return "年龄必须在18到70岁之间";}}public class TestIllegalAge{public static void main(String[] args){Driver d1=new ________(40);Driver d2=new Driver(16);________//下面代码中有抛出异常的方法getAge(){int age1=d1.getAge(); //getAge()会抛出异常,要进行异常处理System.out.println("d1的年龄是"+age1);int age2=d2.getAge();System.out.println("d2的年龄是"+age2);}catch(_____________ e){e.printStackTrace();e.toString();e.getMessage();}}}