Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Regarding to exception handling and multithreading programming, answer the following questions. (a) Explain the difference between a checked exception and an unchecked exception. (2
Regarding to exception handling and multithreading programming, answer the following questions. (a) Explain the difference between a checked exception and an unchecked exception. (2 marks) (b) State the used of the keywords throw and throws. (2 marks) (c) Suppose that method causes an exception in the following try-catch block: public void method03 () throws Exception { try ( methodY (0.5); } } catch (Exception ex) ( ) System.out.println(ex); throw ex; finally ( } System.out.println("Finally block executed"); System.out.println("Program continue"); (i) Provide the code for methodY (double d), in which it should throw an Exception object with error message "Input argument must >=1" when the input argument d is smaller than 1.0. (4 marks) (ii) What is the output when methodQ3 is executed? (2 marks) (d) Explain how to create a thread pool with THREE (3) fixed threads in Java and how a task is submitted to a thread pool. (2 marks) (e) Explain race condition in a multithreaded program and how it can be avoided. (3 marks)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started