Question: Hello, I need help with this: OODP in java a. Implement a generic class Pair that stores pairs of (key, value) pairs. Usage example: Pair

Hello, I need help with this: OODP in java

Hello, I need help with this: OODP in java a. Implement a

a. Implement a generic class Pair that stores pairs of (key, value) pairs. Usage example: Pair pnew Pair(, "one") System . out.println("The string value of " + .k() + " is " + .y()); A pair object has a constructor public Pair (K k, V v) t...) has accessors: public K k) t...) public V v) and overrides these methods inherited from class Obiect: public boolean equals (Object ob f...1 public int hashCode ) I.. . 1 public String tostring) f...) public Object clone ) I.. . 1 Your class must be immutable, serializable, and cloneable. It is OK to return a shallow clone Follow the quidelines from the textbook when implementing the above functions. b. Write a PairTest class with method main) where you test: -equality with equals () cloning make a clone and compare with the original -serialization. Serialize to an ObjectStream backed by a file and then load the object back to memory and compare it to the original with equals - hashCode) Must be compatible with equals i.e equal hashCode) for equal objects, and different values (with high probability) for different key or/and value objects a. Implement a generic class Pair that stores pairs of (key, value) pairs. Usage example: Pair pnew Pair(, "one") System . out.println("The string value of " + .k() + " is " + .y()); A pair object has a constructor public Pair (K k, V v) t...) has accessors: public K k) t...) public V v) and overrides these methods inherited from class Obiect: public boolean equals (Object ob f...1 public int hashCode ) I.. . 1 public String tostring) f...) public Object clone ) I.. . 1 Your class must be immutable, serializable, and cloneable. It is OK to return a shallow clone Follow the quidelines from the textbook when implementing the above functions. b. Write a PairTest class with method main) where you test: -equality with equals () cloning make a clone and compare with the original -serialization. Serialize to an ObjectStream backed by a file and then load the object back to memory and compare it to the original with equals - hashCode) Must be compatible with equals i.e equal hashCode) for equal objects, and different values (with high probability) for different key or/and value objects

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!