Sorry about not including the question below.
I just noticed that the class ExBase is not declared as abstract even though it's method martley is declared as abstract. If any of a classes methods are abstract that class must also be declared abstract. Therefore, this code would not compile.
Here was the question:
#34
What will happen when you attempt to compile and run the following code?
import java.io.*;
class ExBase{
abstract public void martley(){}
}
public class MyEx extends ExBase{
public static void main(
String argv[]){
DataInputStream fi = new DataInputStream(System.in);
try{
fi.readChar();
}catch(IOException e){
System.exit(0);
}
finally {System.out.println("Doing finally");}
}
}
1) Compile time error
2) It will run, wait for a key press and then exit
3) It will run, wait for a keypress, print "Doing finally" then exit
4) At run and immediately exit
The answer they give is (1) Compile time error. It produces an error like "Abstract and native method can't have body".
Thanks.