sangeetha raj wrote:
[code = java]
A a=new A(){ //line 5
public void start() throws ArithmeticException{
System.out.print(1);
try{
System.out.print(2);
throw new ArithmeticException();
System.out.print(3);//line 9 unreachable
}catch(Exception e){
System.out.print(4);
}finally{
System.out.print(5);
}
}
};
[/code]
Thanks,
SR
[HENRY: Added Code tags]
Line 5 is not incorrect because abstract class A is not instantiated here.
Anonymous inner class, which is unnamed, and inherits from A and overrides start().
Since anonymous inner class has overridden the abstract start() method of class A, its no longer abstract and can thus be instantiated.
So option 2 is the correct answer.
Read K&B chapter 8 on Inner classes for more insight.