Sale!

Remove the error by rearranging the following code

Original price was: $35.00.Current price is: $30.00.

Category:
5/5 - (2 votes)

1. Remove the error by rearranging the following code.
public class ExceptionHandling
{
public static void main(String[] args)
{
try
{
int arr[]={4,4,5};
arr[6]=90;
}

catch(IndexOutOfBoundsException ex)
{
System.out.println(“Index out of bound”);
}

catch(ArrayIndexOutOfBoundsException ex)
{
System.out.println(“Array Index out of bound”); }
}
}
2. NDVI is calculated by using red band and Infrared band reflectance. It is used to identify
different kind of vegetation.
Image A (red band) = [ 3 15 54 16
54 23 21 75
0 3 51 0
23 0 43 98]
Image B (Infrared band) = [ 15 19 66 58
13 87 11 13
0 19 86 95
3 0 57 99]
NDVI Image C (of the same size, A) is generated by calculating NDVI for each pixel using the
formula =(Infrared-Red)/ (Infrared + Red)
Use a method to calculate NDVI and catch the exception.
3. Write a method to divide two user entered numbers, Use ‘throws’ to handle the exception.
Please make two different classes.(Class 1 should contain the method and Class 2 will
contain the main method from which it will be called)
4. Take user input in a fixed size of integer array (size =5). Use ‘throw’ to generate an exception
of data type and size. Use ‘finally’ block to display the array.

Reviews

There are no reviews yet.

Be the first to review “Remove the error by rearranging the following code”

Your email address will not be published. Required fields are marked *

Scroll to Top