programming logic and design

Computer Science
Tutor: None Selected Time limit: 1 Day

design an application in which you declare an array of three strings and store three values in the array. write a try block in which you loop to display each successive element of the array, increasing a subscript by one on each pass through the loop. assume that an arrayindexoutofboundsexception is created automatically when a subscript is not correct for an array. create a catch block that catches any exception and displays the message now you've gone too far.

Apr 26th, 2015

public class ArrayBoundExceptionTest
public static void main()
//Declarations
num count = 0;  // count variable is used for subscript
string arr[3] = “Hello”, “Exception”, “World” // 3 string values stored in array i.e. arr

try

  // this loop used to  display each element of the array
  while count<=3

// display the value of each element of array

 output "The value of element of array is ", arr[count] 

// increment in subscript by 1

 count = count  + 1; 

endwhile

endtry

catch(ArrayIndexOutOfBoundsException aioobe)
  output “Now you've gone too far "  // display Exception Message
  output aioobe.getMessage() 

endcatch

  return

endClass


Apr 26th, 2015

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Apr 26th, 2015
...
Apr 26th, 2015
Feb 25th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer