Can anyone please help me in understanding the following. This is from the K&B MasterExam.
Given that CharSequence is an interface implemented by both the
String and StringBuilder classes, and then given the following method
public <S extends CharSequence> S foo(S s){
//INSERT HERE
}
Which of teh following can be inserted here to compile and run without error? choose all that apply
A. return s
B. return(Object) s;
C. return s.toString();
D. return new StringBuilder(s);
E. return (S) new StringBuilder(s);
F. return null;
The answer is A. and F
why not D or E??
Thank you