The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
University
| Teaching Since: | Apr 2017 |
| Last Sign in: | 438 Weeks Ago, 1 Day Ago |
| Questions Answered: | 9562 |
| Tutorials Posted: | 9559 |
bachelor in business administration
Polytechnic State University Sanluis
Jan-2006 - Nov-2010
CPA
Polytechnic State University
Jan-2012 - Nov-2016
Professor
Harvard Square Academy (HS2)
Mar-2012 - Present
Write a class Ar r a y that encapsulates an array and provides bounds-checked access. The private instance variables should be i nt i nde x and i nt a r r a y[ 10] . The public members should be a default constructor and methods (signatures shown below) to provide read and write access to the array.
![]()
If the l oc a t i on is within the correct range for the array, the i ns e r t method should set that location of the array to the value. Likewise, if the l oc a t i on is within the correct range for the array, the r e t r i e ve method should return the value at that location—the approach taken by the library before Java 5.0. In either case, if l oc a t i on is not within the correct range, the method should throw an exception of class Ar r a yOut Of Bounds Exc e pt i on. Write an application that helps you test your implementation. Your application should assign values to the array by using the i ns e r t method, then use the r e t r i e ve method to read these values back from the array. It should also try calling both methods with illegal location values. Catch any exceptions thrown by placing the “illegal” calls in a t r y block with an appropriate c a t c h.
-----------