InputStream in new FileInputStream try SystemoutprintA catc

InputStream in = new FileInputStream(.. try {System.out.print(\"A\");} catch (IOException e) {System.out.print(\"B\");} finally {in.close(); System.out.p ri nt(\"C\");} System.out.println(\"D\"); What will be the string print in output if the try and finally blocks throw no exception? ACD ABCD AC ABD

Solution

Answer is ACD

try{
System.out.println(\"A\");
}
catch(IOException e)
{
System.out.println(\"B\");
}
finally{
in.close();
System.out.println(\"C\");
}
System.out.println(\"D\");

It executes the try block and next execute finally block then prints D

 InputStream in = new FileInputStream(.. try {System.out.print(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site