Question: Create a package called mygenerics In package, mygenerics, create a generic interface MyGenericI, with methods; public T getValue(); void T setValue(); In package, mygenerics, create

Create a package called mygenerics

In package, mygenerics, create a generic interface MyGenericI, with methods;

public T getValue();

void T setValue();

In package, mygenerics, create a generic class MyGeneric that implements above interface. Let MyGeneric class have an attribute

T value;

And the above methods returns value and set value

Also let MyGeneric class have a constructor that will set its attribute value

public MyGeneric(T _value)

In MyGeneric class, create a generic static method called addValues that will take as input 2 instances of MyGeneric class, add their value attributes and return that.

In MyGeneric class create a static method called use_addValues that invokes addValues method with 2 types of inputs String and Integer. Add use_addValues be called from main() of MyGeneric class.

Make sure your MyGeneric class main runs and be ready to demo it.

Carefully study and run the code examples in example-java-generics to better understand bounding;

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!