Answered You can hire a professional tutor to get the answer.
Write a Java statement that throws a new exception with the String: File Not Found. Write a Java statement that throws a new exception with the...
- Write a Java statement that throws a new exception with the String: File Not Found.
- Write a Java statement that throws a new exception with the String: Disk drive not ready.
- Use a catch block to display the exception thrown in number one above.
- Use a catch block to display the exception thrown in number two above.
- Define an exception class called FileNotFoundException. The class should have a constructor with no parameters. If an exception is thrown with this zero-argument constructor, getMessage should return "File Not Found!" The class should also have a constructor with a single parameter of type String. If an exception is thrown with this constructor, then getMessage returns the value that was used as an argument to the constructor.
- Define an exception class called DiskDriveNotReady. The class should have a constructor with no parameters. If an exception is thrown with this zero-argument constructor, getMessage should return "Disk Drive Not Ready!" The class should also have a constructor with a single parameter of type String. If an exception is thrown with this constructor, then getMessage returns the value that was used as an argument to the constructor.
- What is the catch or declare rule?
- Write a complete Java program that prompts the user for two nonnegative integer numbers. Your program should handle bad input data.
- Revise the program in number 8 above to use a try/catch block to handle the IOException.
- Define an exception class called NegativeNumberException. The class should have a constructor with no parameters. If an exception is thrown with this zero-argument constructor, getMessage should return "Negative Number Not Allowed!" The class should also have a constructor with a single parameter of type String. If an exception is thrown with this constructor, then getMessage returns the value that was used as an argument to the constructor.
- Revise the program in number 9 above to throw a NegativeNumberException if the user enters a negative number.
- If you were going to catch an exception of type Exception, where should this catch block be placed within your code?
- What is the purpose of the finally block?
- Should an application catch objects of type Error?
- List five common examples of exceptions that occur.
- What is the purpose of the method getMessage() when used with exception handling?