Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a. Declare an interface Filter that has a method accept() which accepts as parameter an Object, and retur b. ns a Boolean. [3] c. Provide
a. Declare an interface "Filter" that has a method accept()" which accepts as parameter an Object, and retur b. ns a Boolean. [3] c. Provide an abstract class ShortWordFilter that implements the interface Filter". [3] d. Extend two concrete classes Less ThanFive and LessThanTen from ShortWordFilter class, such that both have an ArrayList of type String to store the words. [3] e. Define a static method "collectAll" that accepts as parameters two arguments, an arraylist of type String and a reference of type Filter. The method returns an arraylist of type Filter containing two polymorphic references to objects of the sub dasses containing ArrayList filled with words that are accepted by the given filter. [7] f. Then write a testclass that reads all words from System in, puts them into an ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started