-
Expert Member
Doubt with overloading...in Generics(Urgent)
I have confusion with below code...
which of them are valid inserts?
class Parent<E>
{
public E get() { return null;}
public void set(E e) { }
}
class Child extends Parent<Number>
{
//insert here
}
options given to insert are
a public Object get() { ... }
b public Long get() { ... }
c public void set(Object arg) { ... }
d public void set(Long arg) { ... }
e public Number get() { ... }
and ans is b,d,e.Iam fine with it.
But i have confusion with option c.Why "option c" is wrong?In option c,
we hava "Object arg" as argument, so isn't it a valid overloading example?
see here their is a statement in above code "class child extends Parent<Number> ".
Therefore
set(E e) of Parent class should be "set(Number e), "
and in child class if we have option c, which is set(Object e), then what is wrong in it?Wont it be a vaild overloading example.
Last edited by vmshenoy; 12-23-2007 at 09:16 AM.
:)
NEVER SAY DIE.
-
Junior Member
Re: Doubt with overloading...in Generics(Urgent)
Hi
I am a new member to the forum.
I think this is possible in java 1.5 but for the previous versions it is not possible.
-
Contributing Member
Re: Doubt with overloading...in Generics(Urgent)
yes, previous version is not suitable for overloading classes in the collection frame work. overloading can be done throw constructor call only. interfaces provides constructor call
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules