(a) Explain what is wrong with the given code. Describe the fault precisely by proposing a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(a) Explain what is wrong with the given code. Describe the fault precisely by proposing a modification to the code. (b) If possible, give a test case that does not execute the fault. If not, briefly explain why not. If possible, give a test case that executes the fault, but does not result in an error state. If not, briefly explain why not. (c) (d) If possible give a test case that results in an error, but not a failure. If not, briefly explain why not. Hint: Don't forget about the program counter. (e) For the given test case, describe the first error state. Be sure to describe the complete state. (f) Implement your repair and verify that the given test now produces the expected output. Submit a screen printout or other evidence that your new program works. Find last index of element @param x array to search @param y value to look for @return last index of y in x; -1 if absent @throws NullPointerException if x is null public int findLast (int[] x, int y) { for (int i-x.length-1; i > 0; i--) { if (x[i]-y) { return i; } } } retum -1; // test: x [2, 3, 5]; y-2; Expected - 0 // Book website: FindLast.java // Book website: FindLastTest.java (a) Explain what is wrong with the given code. Describe the fault precisely by proposing a modification to the code. (b) If possible, give a test case that does not execute the fault. If not, briefly explain why not. If possible, give a test case that executes the fault, but does not result in an error state. If not, briefly explain why not. (c) (d) If possible give a test case that results in an error, but not a failure. If not, briefly explain why not. Hint: Don't forget about the program counter. (e) For the given test case, describe the first error state. Be sure to describe the complete state. (f) Implement your repair and verify that the given test now produces the expected output. Submit a screen printout or other evidence that your new program works. Find last index of element @param x array to search @param y value to look for @return last index of y in x; -1 if absent @throws NullPointerException if x is null public int findLast (int[] x, int y) { for (int i-x.length-1; i > 0; i--) { if (x[i]-y) { return i; } } } retum -1; // test: x [2, 3, 5]; y-2; Expected - 0 // Book website: FindLast.java // Book website: FindLastTest.java
Expert Answer:
Related Book For
Introduction to Operations Research
ISBN: 978-1259162985
10th edition
Authors: Frederick S. Hillier, Gerald J. Lieberman
Posted Date:
Students also viewed these programming questions
-
do the following,..... Write program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. Create program that takes in user input...
-
Represent multisets using binary trees. Compare the representations (a), (b) and (c), stating the advantages and drawbacks of each. [Answers need not contain ML code. You may refer to algorithms and...
-
What is the common name for the following structure? CH3 CH3 -C-Br 1 CH3 Isobutyl bromide Osec-Butyl bromide O Neobutyl bromide O Isopropyl methyl bromide t-Butyl bromide
-
The population size can be thought of as twice a binomial random variable, because we are counting pairs. Use this idea, and the continuity correction, to estimate the probability that the results...
-
How do the intricate interplays of genotype, epigenetic modifications, and environmental factors shape the phenotypic outcomes observed in complex genetic disorders, and what implications does this...
-
For each of the following situations, calculate the degrees of freedom \((d f)\), identify the critical values (assume \(\mathrm{a}=.05\) [two-tailed]), calculate the \(t\)-statistic \((t)\), make a...
-
Stockman Company began 2010 with three jobs in progress: During 2010, the following transactions occurred: a. The firm purchased and paid for $542,000 of raw material. b. Factory payroll records...
-
What is the purpose of the Management, Dynamic and Virtual Interfaces of WLC2504? What is PoE? How many PoE ports does the controller WLC2504 have? How many APs does wireless controller type Cisco...
-
In its first year, "Abol Buna Co" had the following experience Sales = 25,000 units Selling price = br. 100 TVC = br. 1,500,000 TFC = br. 350,000 Required: a/ Develop Revenue, cost & profit...
-
A world-class sprinter running a 100 m dash was clocked at 5.4 m/s 1.0 s after starting running and at 9.8 m/s 1.5 s later. In which of these time intervals, 0 to 1.0 s or 1.0 s to 2.5 s, was his...
-
Write a program that displays the following menu: If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the following formula to calculate the...
-
Let \(f\) be a scalar function and \(\mathbf{F}\) be a vector field. Prove the following Product Rule for Divergence: \[ \operatorname{div}(f \mathbf{F})=f \operatorname{div}(\mathbf{F})+abla f \cdot...
-
Thin Co. is a private hospital offering three types of surgical procedure known as A, B and C. Each of them uses a pre-operative injection given by a nurse before the surgery. Thin Co. currently rent...
-
Calculate the stock price of OSE Water Co. if the difference between the required rate of return on this investment and the expected growth rate of dividends is 3.6% and dividends per share are...
-
Identify how a biblical steward deals with risk.
-
In a system with light damping (c < cc), the period of vibration is commonly defined as the time interval d = 2/d corresponding to two successive points where the displacement-time curve touches one...
-
A food processor claims that at most \(10 \%\) of her jars of instant coffee contain less coffee than claimed on the label. To test this claim, 16 jars of her instant coffee are randomly selected and...
-
Refer to Exercise 4.2. (a) Determine the cumulative probability distribution \(F(x)\). (b) Graph the probability distribution of \(f(x)\) as a bar chart and below it graph \(F(x)\). Data From...
-
Four emergency radios are available for rescue workers but one does not work properly. Two randomly selected radios are taken on a rescue mission. Let \(X\) be the number that work properly between...
Study smarter with the SolutionInn App