Engineering Full Stack Apps with Java and JavaScript
A try statement must always have a ............. associated with it.
Select 1 option
A. catch B. throws C. finally D. catch, finally or both E. throw
D
A try without resources must have either a catch or a finally. It may have both as well. Thus, the following constructs are valid: 1. try{ } catch(Exception e){ } // no finally 2. try{ } finally{ } // no catch 3. try{ } catch(Exception e){ } finally{ } 4. A catch can catch multiple exceptions: try{ } catch(Exception1|Exception2|Exception3 e){ }
Note: try with resources (which is not on this exam) may omit catch as well as finally blocks.
Logged in users see lesser ads and get more features.
If you want to solve the questions together with the experts and understand the concepts better, please contact us using the contact form or WhatsApp numbers. Selected people get to do that without any additional charges.