Hi Rashmi,
I just tried out the below code, which is throwing
a checked exception in the initializer block.
It does not compile. As instance initializer blocks
cannot be calling explicitly we have catch the checked
exception within the block itself.
So once i put a try-catch block the code compiles fine.
class Q28fd {
{
int i = 10;
throw new MyException(); // need to catch the exception
}
public static void main(
String args[]) {
}
}
Correct me if wrong .