Question: This exercise asks you to write a generic countMatches method. Your method will take two parameters. The first parameter is an array of int. The

This exercise asks you to write a generic countMatches method. Your method will take two parameters. The first parameter is an array of int. The second parameter is a function object that returns a Boolean.

a. Give a declaration for an interface that expresses the requisite function object.

b. countMatches returns the number of array items for which the function object returns true. Implement countMatches.

c. Test countMatches by writing a function object. EqualsZero that implements your interface to accept one parameter and returns true if the parameter is equal to zero. Use an EqualsZero function object to test countMatches.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets solve this exercise by addressing each part step by step a Declaration for an interface that expresses the requisite function object To define an ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

609704162eef8_27408.pdf

180 KBs PDF File

Word file Icon

609704162eef8_27408.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!