Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Write a custom Java exception class named BadArrayException that has two constructors:

- A default constructor with no arguments.

- A constructor taking a String parameter (the exception message) that must be passed to the parent Exception(String) constructor.

Write a Java class named ArrayUtils that contains the following public methods. The class must implement all the search and copy logic for these methods. It can not use array methods from the Java API.

1. public static int minValue(int[] list)

This static method searches its parameter array to locate the minimum value, and returns it. Do not use sorting to find the minimum value in the array. The array may contain any negative, 0, and/or positive values. If the array parameter is length 0, it must throw a BadArrayException with the message "Array is empty".

2. public static int[] copyRange(int[] list, int startIndex)

This static method copies the specified range of elements from the parameter array into a new array, and returns it. The initial index of the range (startIndex) must lie between 0 and list.length, inclusive. The range is [startIndex, Index of last element in the list]. If the startIndex parameter is less than 0 or greater than list.length, it must throw an ArrayIndexOutOfBounds exception with startIndex as the exception object parameter.

3. public static int indexOf(int[] list, int searchValue)

This static method searches its parameter array to locate the first occurrence of the parameter searchValue, and returns its index position if found, or -1 if not found. If the array parameter is length 0, it must return -1.

4. public static int lastIndexOf(int[] list, int searchValue)

This static method searches its parameter array to locate the last occurrence of the parameter searchValue, and returns its index position if found, or -1 if not found. If the array parameter is length 0, it must return -1.

If the array parameter is null, methods must throw a BadArrayException with the message "Array is null". These methods should not catch the BadArrayException they throw due to a null or empty array parameter. The exception is thrown back to the calling code to handle.

Test the implementation of BadArrayException and ArrayUtils classes with the help of attached ArrayUtilsDemo class.

Attachment:- ArrayUtilsDemo.txt

Java, Programming

  • Category:- Java
  • Reference No.:- M91611640
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Java

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As