Due Date 6/29 11:59 pm

HW 3: Generics

Task 1: Generic Add Method with Upper Bound

Write a generic method named add with an upper bound (extends). The method should take two generic arguments and return the sum of the given two numbers.

Task 2: Lower Bound Method

Write a method named printOnlyIntegerClassorSuperClass that takes a list as a lower bound (super) Number argument.

Task 3: Upper Bound Method

Write a method named printwithextend that takes a list as an upper bound (extends) Number argument.

Task 4: Unbounded Wildcard Method

Write a method named printlist that takes a list with an unknown bound (?) as an argument.

Task 5: Sum Method with Upper Bound

Write a method named sum that takes a list as an upper bound (extends) argument.

Sample Output

Sum of two integers: 30
Sum of two doubles: 13.5
Printing Integer or SuperClass list: [10, 20, 30]
Printing with Upper Bound list: [1.5, 2.5, 3.5]
Printing Unbounded list: [A, B, C]
Sum of Upper Bound list: 7.5