1、指出下列Java程序中的错误,并修改使之能够正确运行
abstract class Student{
abstract void isPass( ) { };
}
class UnderGraduate extends Student {
public void isPass( ) {System.out.println("Pass!");}
}
public class AbstarctTest{
public static void main(String args[]) {
Student s;
s=new Student();
}
2.请在下面Java程序的划线处填上适当语句,使程序能够正常运行
public class MyClass {
public static void main(String args[]) {
try{ myMethod( );
}catch(MyException e) {
System.out.println(e.getMessage( ));
}
}
public----------------void MyMethod(
) ---------------- { //方法中声明抛弃用户自定义异常
throw ---------------- ;
}
}
class MyException extends---------------- { //用户自定义异常类
public String toString( ){
return "用户自定义异常";
}
}
考试过后自己要去调试一下
1.s=new Student();
改成
s=new UnderGraduate();
static
MyException
new MyException();
Exception