TestForNulls (30) Write a class TestFor Nulls. The method hasNoNulls that accepts an ArrayList with a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
• TestForNulls (30) Write a class TestFor Nulls. The method hasNoNulls that accepts an ArrayList with a wildcard type that returns a value of true if the ArrayList contains no null elements. Write a main program that tests with two ArrayLists. Create a Random object called randy with a seed of 2 The first ArrayList is of type Integer. It will be populated with 7 random integer values from 6 to 10 inclusive using randy. Then test for a null value using hasNoNulls, printing the result as shown below. Then add a null value at the end of the ArrayList, and retest using hasNoNulls, printing the result as shown below. Then print out the ArrayList as shown The second ArrayList is of type String. It will be populated with a 8 String values that are the concatenation of "XXX" and a random integer from to 17 to 25 inclusive using randy. Test for a null value using hasNoNulls, printing the result as shown below. Then add a null value at index 4 of the ArrayList, and retest using hasNoNulls, printing the result as shown below. Then print out the ArrayList as shown It is true that intArrayL has no null value It is false that intArrayL has no null value [9, 5, 7, 6, 8, 5, 5, null] It is true that stringArrayL has no null value It is false that stringArrayL has no null value [xxx17, xxx24, xxx23, xxx19, null, xxx19, xxx24, xxx20, xxx22] • TestForNulls (30) Write a class TestFor Nulls. The method hasNoNulls that accepts an ArrayList with a wildcard type that returns a value of true if the ArrayList contains no null elements. Write a main program that tests with two ArrayLists. Create a Random object called randy with a seed of 2 The first ArrayList is of type Integer. It will be populated with 7 random integer values from 6 to 10 inclusive using randy. Then test for a null value using hasNoNulls, printing the result as shown below. Then add a null value at the end of the ArrayList, and retest using hasNoNulls, printing the result as shown below. Then print out the ArrayList as shown The second ArrayList is of type String. It will be populated with a 8 String values that are the concatenation of "XXX" and a random integer from to 17 to 25 inclusive using randy. Test for a null value using hasNoNulls, printing the result as shown below. Then add a null value at index 4 of the ArrayList, and retest using hasNoNulls, printing the result as shown below. Then print out the ArrayList as shown It is true that intArrayL has no null value It is false that intArrayL has no null value [9, 5, 7, 6, 8, 5, 5, null] It is true that stringArrayL has no null value It is false that stringArrayL has no null value [xxx17, xxx24, xxx23, xxx19, null, xxx19, xxx24, xxx20, xxx22]
Expert Answer:
Answer rating: 100% (QA)
To complete this task we need to create a TestForNulls class with a method hasNoNulls that works with an ArrayList of a wildcard type Then well write ... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Omega Companys accountants have just completed the income statement and balance sheet for the year and have provided the following information (dollars in thousands): Other Data: The company issued...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Refer to the table below. Of the 36 possible outcomes, determine the number for which the sum Die 1 1 2 3 4 5 56 6 1 (1,1) (2,1) (3,1) (4,1) (5,1) (6,1) One can roll a sum of 9 in Die 2 2 3 4 5 (1,2)...
-
How does pressure relate to force?
-
(a) Write by Eulers formula, expand, and equate real and imaginary parts to derive the identities (b) Use the result of part (a) to find a general solution of cos 3x + i sin 3x = e3ix = (cos x + i...
-
Among 100 purification filters used in an experiment, 46 had a service life of less than 20 hours, 19 had a service life of 20 or more but less than 40 hours, 17 had a service life of 40 or more but...
-
(Deferred Tax Liability, Change in Tax Rate, Prepare Section of Income Statement) Sharer Inc.s only temporary difference at the beginning and end of 2010 is caused by a $2 million deferred gain for...
-
Jim Carrie Company shows a balance of $221,140 in the Accounts Receivable account on December 31, 2025. The balance consists of the following. Installment accounts due in 2026 $23,000 Installment...
-
Q4. Review the accounts receivable lead sheet memo and related workpapers (AR.3.1 to AR.3.4). Evaluate the auditors' tickmarks, comments, and explanations in the memo and on the lead sheet. Identify...
-
Functions x(t) and y(t) are given by a system of differential equations: dx dt dy dt = x-3xy + 8x; a) Linearize the system for the neighborhoods of the equilibrium points. Determine the types of the...
-
Absolute Valuation 1. INV Design Ltd just paid a dividend of $4, and its earnings per share was $6. The Net Income margin is 15%, Asset Turnover is 1.25 and Debt-to-Equity is 0.6. The appropriate...
-
4) A diatomic ideal gas (C-5R/2) is compressed to half of its initial volume through the path PV-1 = C, where C is a positive constant. Calculate the heat flow out of the gas in terms of initial...
-
James pulled together the following annual revenue and cost information for his small business: total variable costs $8,800, total COGS $6,500, total revenues $23,400, total fixed costs $3,700, and...
-
a) Why is inventory management important? How does mismanaged inventory leads to costs to any organisation? (10 marks) Give examples to justify your answers. (Please answer in 200-300 words). b) Reem...
-
Rational functions can model key economic information for businesses. In manufacturing, start-up costs can be high because of the equipment required to make a product. Rational functions can model...
-
In the Audit of the LOL Financial Statement, the auditor wanted to inspect the least transaction of the client. You ascertained that there are 4 Financial Lease Contracts acquired by the client the...
-
The words without recourse on an indorsement means the indorser is: a. not liable for any problems associated with the instrument. b. not liable if the instrument is dishonored. c. liable personally...
-
What is the purpose of the checkCapacity method? Where is it called in the list class? Describe a way that the client can utilize an ArrayIntList that will be caught by checkCapacity.
-
The following piece of code incorrectly attempts to declare a queue of integers. What is wrong with the code, and how would you fix it? Queue q = new Queue ();
-
Describe how to arrange an ArrayList into sorted order. What must be true about the type of elements in the list in order to sort it?
-
Speeds of bullet trains. Determine whether the data are qualitative or quantitative. Explain your reasoning.
-
Widths of veins in different species of leaves. Determine whether the data are qualitative or quantitative. Explain your reasoning.
-
American Standard Code for Information Interchange (ASCII) codes. Determine whether the data are qualitative or quantitative. Explain your reasoning.
Study smarter with the SolutionInn App