Question: Inner Class Exercises 1. Define a class named Factorial that has the following methods: a. Constructor - Factorial (int lowerLimit, int upperLimit) b. toString() -

 Inner Class Exercises 1. Define a class named Factorial that has

Inner Class Exercises 1. Define a class named Factorial that has the following methods: a. Constructor - Factorial (int lowerLimit, int upperLimit) b. toString() - returns a string wth the factorials of numbers starting at lowerLimit (inclusive) and ending at upperLimit (inclusive). For example, for lowerLimit 2 and upperLimit 4 the string returned will be: "2, 6, 24" 2. Write a Driver class with a main method to test your Factorial class. 3. Modify your Factorial class so that the following code will work: Factorial new Factorial (4, 13) for (Long y: x) t System.out.println(y); The output should be: 24 120 720 5040 40320 362880 3628800 39916800 479001600 6227020800 Hint: Make the Factorial class implement the Iterable interface Suggestion: You might want to practice doing this exercise two ways: First with a normal inner class, and then with an "anonymous" inner class. 4. Modify your Driver class to test what you did in part 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!