Results 1 to 3 of 3

Thread: Doubt with overloading...in Generics(Urgent)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Expert Member
    Join Date
    Oct 2005
    Answers
    383

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact