This code if from K&B and page no:242.
class TestEx {
public static void main(
String args[]){
doStuff();
}
static void doStuff() {
doMoreStuff();
}
static void doMoreStuff(){
int x = 5/0;
}
}
If i compile this code, i am getting compilation error. Bec. the arithmetic divison is hard coded. But the expected ans. is exception. It will happens only if i use the var. like int x = a/b; (a is some val & b is zero).
For such type of questions , what we have to answer.. like compilation error or runtime exception ??!?!.