Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1. (20 pts.) Interface Filterable Design an interface named Filterable. This interface has only one method filter that returns true for objects that are accepted

image text in transcribed

Q1. (20 pts.) Interface Filterable Design an interface named Filterable. This interface has only one method filter that returns true for objects that are accepted (i.e., passes the filter) and false for objects that are rejected (i.e., does not pass the filter) Q2. (50 pts.) Class EncapsulatedNumber that implements Filterable Encapsulate the java.lang.Number class that is the superclass of classes BigDecimal, Biglnteger, Byte, Double, Float, Integer, Long, and Short. The name of this class will be EncapsulatedNumber. The requirements are given below: Every object of type EncapsulatedNumber contains a field named number of type Number. This field will be private Add a constructor that takes as argument a Number * Make this class implement the Filterable interface, such that method filter will return true when the number is positive (i.e., greater than 0.0 in its doubleValue) * Override the toString() method to return the String representation of the number. Q3. (30 pts.) static methods Implement the following 3 static methods public static void printArray(EncapsulatedNumberll arr) Correctness: prints all elements of the array on the console. Displayed values should be numeric. public static EncapsulatedNumberll filterEncapsulatedNumbers(EncapsulatedNumberll arr) Correctness: apply the filter on all input objects. If all fails to pass, then return null. Otherwise return an array that contains passing objects. public static void main(Stringl] args) Correctness: declare and initialize an array of EncapsulatedNumber objects. Print the array Filter the array. Then print the array again. 1. 2. 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

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

More Books

Students also viewed these Databases questions