5.17.Questions |
| 5.17.1. | What Java statement is used to completely abort the execution of a loop? | | |
| 5.17.2. | Answer: abort the execution of a loop | | |
| 5.17.3. | What is the output from the following code(continue and break)? | | |
| 5.17.4. | Answer: continue and break | | |
| 5.17.5. | What can be thrown by a throw statement? | | |
| 5.17.6. | Answer: throw statement | | |
| 5.17.7. | What can be caught for the following types? | | |
| 5.17.8. | Answer: caught type | | |
| 5.17.9. | finally clause of a try-catch-finally is only executed after a catch clause has executed(True/False). | | |
| 5.17.10. | Answer: try-catch-finally | | |
| 5.17.11. | finally clause of a try-catch-finally is only executed if a catch clause has not executed(True/False). | | |
| 5.17.12. | Answer: finally | | |
| 5.17.13. | finally clause of a try-catch-finally is always executed unless its thread terminates(True/False). | | |
| 5.17.14. | Answer: finally(2) | | |
| 5.17.15. | finally clause of a try-catch-finally is only executed if an exception is thrown(True/False). | | |
| 5.17.16. | Answer: finally(3) | | |
| 5.17.17. | What is the output from the following code(throw exception)? | | |
| 5.17.18. | Answer: throw exception | | |
| 5.17.19. | What is the output from the following code(nested try statement)? | | |
| 5.17.20. | Answer: nested try statement | | |
| 5.17.21. | What is the result(nested for loop and break)? | | |
| 5.17.22. | Answer: nested for loop and break | | |
| 5.17.23. | What is the result(throw exception in try block)? | | |
| 5.17.24. | Answer: throw exception in try block | | |
| 5.17.25. | What is the result(break and label)? | | |
| 5.17.26. | Answer: break and label | | |
| 5.17.27. | What is the result(try...catch)? | | |
| 5.17.28. | Answer: try...catch | | |
| 5.17.29. | Which could be used to create an appropriate catch block? | | |
| 5.17.30. | Answer: catch block | | |
| 5.17.31. | It is appropriate to use assertions to validate arguments to methods marked public(True/False) | | |
| 5.17.32. | Answer: assertion | | |
| 5.17.33. | It is appropriate to catch and handle assertion errors(True/False) | | |
| 5.17.34. | Answer: assertion and catch clause | | |
| 5.17.35. | It is NOT appropriate to use assertions to validate command-line arguments(True/False) | | |
| 5.17.36. | Answer: assertion and commandline | | |
| 5.17.37. | It is appropriate to use assertions to generate alerts when you reach code that should not be reachable(True/False) | | |
| 5.17.38. | Answer: assertion and unreachable code | | |
| 5.17.39. | Which, inserted independently at XXX, compiles? | | |
| 5.17.40. | Answer: for loop and hanced for loop | | |
| 5.17.41. | What is the result(nested try /catch blocks)? | | |
| 5.17.42. | Answer: nested try /catch blocks | | |
| 5.17.43. | What is the result(switch and fall-through)? | | |
| 5.17.44. | Answer: switch and fall-through | | |