Answer:
Java Code given below with appropriate comments for better understanding
Step-by-step explanation:
1.
public String whatAmI(E e) {
//.getClass() returns the runtime class of an object
//.equals() determines whether two objects are equivalent
//by calling a new static instance of a wrapper object we can analyze
//it's class type and compare it to the variable passed in
if(e.getClass().equals(new Integer(1).getClass())) {
return "Integer";
}
else if(e.getClass().equals(new String("1").getClass())) {
return "String";
}
else if(e.getClass().equals(new Double(1.0).getClass())) {
return "Double";
}
else {
return "Who knows!";
}
}
2.
public String reverseWord(String word) {
Stack<Character> stack = new Stack<Character>();
for (int i = 0; i < word.length(); i++) {
stack.push(word.charAt(i));
}
String result = "";
while (!stack.isEmpty()) {
result += stack.pop();
}
return result;
}