Lab Task 05.Docx
Lab Task 05.Docx
Write a program that takes two integers as input and performs division. Use a try-catch block to handle
the ArithmeticException that occurs when dividing by zero. Display an appropriate message if the
exception is caught.
Expected Behavior:
Problem 2
Create a program that initializes an array of integers. Take an index as input from the user and use a
try-catch block to catch ArrayIndexOutOfBoundsException if the user tries to access an invalid index.
Print the value at the index if valid, or an error message if the index is out of bounds.
Expected Behavior:
Problem 3
Write a program that performs multiple operations inside a try block. These operations include:
Expected Behavior:
● Input: Division by zero, out-of-bound index, or invalid string → Catches and handles each
exception appropriately.