Question
Question 1: a.Declare an interface Filter that has a method accept() which accepts as parameter an Object, and return b. as a Boolean. c.Provide an
Question 1:
a.Declare an interface "Filter" that has a method "accept()" which accepts as parameter an Object, and return
b. as a Boolean.
c.Provide an abstract class ShortWordFilter that implements the interface "Filter".
d.Extend two concrete classes LessThanFive and LessThanTen from ShortWordFilter class, such that both have an ArrayList of type String to store the words.
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 subclasses containing ArrayList filled with words that are accepted by the given filter.
f.Then write testclass that reads all words from System.in, puts them into an ArrayList
Question 2:
Can we implement more than on interfaces in java? If yes, then demonstrate the concept with help of java code example?
Creating two interfaces with at least one method in each.
Implementing these interfaces in class with a main function to test function feedback of the interfaces.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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