Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Following are three faulty programs. Each program contain a test case that trigger a failure. For each program, answer the following questions. A. Find out

Following are three faulty programs. Each program contain a test case that trigger a failure. For each program, answer the following questions. A. Find out the fault. B. Find out a test case that does not execute the fault, if possible. C. Find out a test case that executes the fault, but does not result in an error state, if possible. D. Find out a test case that results in an error, but not a failure, if possible. E. Repair the fault and prove that the given test now produces the expected output.

image text in transcribed

image text in transcribed

image text in transcribed

public static int lastZero (int[] x) { //Effects: if x==null throw NullPointerException // else return the index of the LAST O in x. // Return -1 if o does not occur in x == for (int i = i 0; i = 0) { count++; } } return count; } // test: x=(-4, 2, 0, 2] // Expected = 2 0; public static int oddorPos (int[] x) { //Effects: if x==null throw NullPointerException // else return the number of elements in x that // are either odd or positive (or both) int count = for (int i = 0; i 0) i> ) { count++; } } return count; } // test: x=(-3, -2, 0, 1, 4] // Expected = 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions