Question: GenIFTester ( 3 0 ) Create two files for this exercise, one for the functional interface GenericInterface and one to test it called GenIFTester. GenericInterface
GenIFTester
Create two files for this exercise, one for the functional interface GenericInterface and one to test it called GenIFTester.
GenericInterface
This is a generic class of type T
It has one abstract method called func that has a parameter of type T and returns a value of type T
GenIFTester
This program can all be done in main
Create a Scanner to read from the keyboard.
Create a lambda function called reverse that implements GenericInterface This lambda accepts a variable of type String and reverses all the characters of the parameter. It returns the reversed String.
Then do three times
Request an input String.
Use reverse to reverse the String and print out the original String and the reversed String see Sample IO below
Create a lambda function called factorial that implements GenericInterface This lambda accepts a variable of type int and calculates its factorial value. It returns the int value. Note: Autoboxing will take place automatically or you can use Integer in place of int if you like
Then do three times
Request an input integer.
Use factorial to calculate the factorial value and print out the original number and factorial see Sample IO below
Sample InputOutput
Enter a string to be reversed:
abcde
The entry abcde reversed is edcba
Enter a string to be reversed:
My Day Is Great
The entry My Day Is Great reversed is taerG sI yaD yM
Enter a string to be reversed:
Grand
The entry Grand reversed is dnarG
Enter an integer to be factorialised:
factorial of
Enter an integer to be factorialised:
factorial of
Enter an integer to be factorialised:
factorial of
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
