Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Auditing A Practical Approach

Authors: Robyn Moroney

1st Canadian Edition

978-1118472972, 1118472977, 978-1742165943

More Books

Students also viewed these Programming questions