Handling Exceptions in Maritime Systems
This program demonstrates handling exceptions in maritime systems.
Problem Statement
Write a Java program that simulates maritime system failure and handles exceptions.
Source Code
| 1 | public class MaritimeExceptionExample { |
| 2 | public static void main(String[] args) { |
| 3 | System.out.println("Eduinq Maritime Exception Example"); |
| 4 | try { |
| 5 | navigateShip("storm"); |
| 6 | } catch(Exception e) { |
| 7 | System.out.println("Eduinq Exception: Maritime Error - "+e.getMessage()); |
| 8 | } |
| 9 | } |
| 10 | static void navigateShip(String status) throws Exception { |
| 11 | if("storm".equals(status)) throw new Exception("Navigation Disrupted"); |
| 12 | System.out.println("Eduinq Ship Navigated Successfully"); |
| 13 | } |
| 14 | } |
Program Output
Eduinq Maritime Exception Example Eduinq Exception: Maritime Error - Navigation Disrupted
Explanation
Maritime systems may fail due to storms or navigation errors. - Exception handling ensures safe and reliable operations. - Provides meaningful feedback for debugging. - In enterprise systems, maritime exception handling ensures transport safety. Conclusion: Shows handling exceptions in maritime systems.