Homework 3 1. [5pts] What are some (at least two) similarities between Java Generics and C++ Templates? 2. [5pts] What are some (at least two) differences between Java Generics and C++ Templates? 3. [5pts] Write a generalized function in a static-typed language that given any three arguments will add them together. For example: - add(1, 2, 3) should return 6 - add(1.5, 2.5, -1) could return 3.0 - add("hello", 1, 2) could return "hello12" (could also be "lo") 4. [5pts] Java gives us three abstractions for generalizing code: - Generics (Type parameters) - Wildcards - Type inferencing with var Of these three, which one do you feel is the most critical for writing generic programs? Which one do you feel is the least critical? 5. [5pts] Why are destructors rarely used in Java but essential in C++? 6. [5pts] How do we define an abstract class in Java? What makes a class "abstract" in C++? 7. [10 pts] Write an abstract data type for rational numbers (a numerator and a denominator). Include a constructor and methods for getting the numerator, getting the denominator, addition, subtraction, multiplication, division, equality testing, and display. 8. [5pts] How can an exception handler be written in Java so that it handles any exception? 9. [5pts] Write a program in any language that creates a GUI with a single button that, when clicked, changes the text of itself to something else.