public <T extends Comparable> T findLarger(T x, T y)
1.Object z = t.findLarger(123, "456"); //y is this getting compiled??? when the parameters being passed are different types
2.int m = t.findLarger(123, new Double(456)); compiler shows error
3.int y = t.findLarger(123, new Integer(456)); compiler shows error
4.int x = (int) t.findLarger(new Double(123), new Double(456)); what's wrong with this??? we are passing the same type of args to this ...y is it askin req int
1.Object z = t.findLarger(123, "456");
it will become t.findLarger(Object,Object); why?
and findLarger :
public Object findLarger(Object x, Object y){...}
2.
int m = t.findLarger(123, new Double(456)); compiler shows error
it will be called as:
int m = t.findLarger(new Object(123),new Object(new Double(456)));
and againe findLarger:
public Object findLarger(Object x, Object y){...}
3.int y = t.findLarger(123, new Integer(456)); compiler shows error
this will not show any error...
as it will become
int y = t.findLarger(new Integer(123), new Integer(456));
and findLarger:
public Integer findLarger(Integer x, Integer y){...}
4.int x = (int) t.findLarger(new Double(123), new Double(456)); what's wrong with this??? we are passing the same type of args to this ...y is it askin req int.
findLarger:
public Double findLarger(Double x, Double y){...}
SCJP 6
SCJA 96%
SCJP 6 88%
skipping SCJD to work on passing SCWCD
Regards,<br />BulletProof Monk.<br /> <br />"Nthing the Mind of man can Conceive<br />and Believe,It can achieve"
SCJP6 - 93% SCWCD5 - 97%
2.
int m = t.findLarger(123, new Double(456)); compiler shows error
it will be called as:
int m = t.findLarger(new Object(123),new Object(new Double(456)));
and againe findLarger:
public Object findLarger(Object x, Object y){...}
Regards, Sanjay Singh
SCJP-1.6, OCEWCD 6
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|