This question was asked to me on an interview. In the below snippet the exception occur in the third line of the try block. The question was how to make the 4th line execute. The third line should be in the catch block itself. They gave me an hint 'using throw and throws'.
public void testCase() throws NullPointerException{
try{
System.out.println("Start");
String out = null;
out.toString();
System.out.println("Stop");
}catch(NullPointerException e){
System.out.println("Exception");
}
}
Can any one help. Thanks in advance.