Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Below are four faulty programs. Each includes a test case that results in fail- ure. Answer the following questions about each program public static

image text in transcribedimage text in transcribed

3. Below are four faulty programs. Each includes a test case that results in fail- ure. Answer the following questions about each program public static int lastzero (int[] x f public int findLast (int[] x, int y) Effects: If x null throw NullPointerException Effects: if x null throw NullPointerException else return the index of the last element else return the index of the LAST 0 in x. in x that equals y Return -1 if 0 does not occur in x If no such element exists, return -1 for (int i x length-1; i 0; i--) for (int i 0; i x.length; i++) if (x[i] 2- y) if (x 0) return i return i -1 return -1; return. test: x 2, 3, 51; y 2 test: x 10, 1, 01 Expected 0 Expected 2 public int countPositive (int[J x) public static int oddorPos(int[] x) H /Effects: If x null throw NullPointerException Effects: if x null throw NullPointerException. else return the number of else return the number of elements in x that positive elements in x are either odd or positive (or both) int count 0 int count 0 for (int i 0; i

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

Step: 3

blur-text-image

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

1. Signs and symbols of the map Briefly by box ?

Answered: 1 week ago

Question

Types of physical Maps?

Answered: 1 week ago

Question

Explain Intermediate term financing in detail.

Answered: 1 week ago