Results 1 to 5 of 5

Thread: which 1 to use

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Answers
    3

    Question which 1 to use

    if i have a class that can extend abs class n implement interface...and it doesnt have to achieve inheritance ,doesnt hav to extend any other class then which 1 should i use between extending a abs class with abs method or implementing interface with abs method.?/
    pls ans


  2. #2
    Junior Member
    Join Date
    May 2008
    Answers
    2

    Re: which 1 to use

    not sure if the question is clear enough... but i will try:
    if you implement the interface - you will have to rewrite the method/s.
    if you exted - u can call existing code without writing anything.
    If I understand the question correctly - "doesnt have to achieve inheritance " -
    you probably mean that we dont have to use any existing method of the original class.
    therefore - I would go with implementing the interface.


  3. #3

    Smile Re: which 1 to use

    I am not sure whether I understood your question or not!!.

    But I want to share with you something.

    If you want to make a class or method that can not be extended by other
    classes. then declare that class or method as final. then that class
    or method cannot be extended by other class


  4. #4
    Junior Member
    Join Date
    Jul 2008
    Answers
    3

    Re: which 1 to use

    sorry frens.i think u didnt get my question.I am explaining again..

    I got this question in an interview.

    Which 1 i will choose if given a choice between extending an abstract class and implementing a interface ..which 1 I should opt.

    NB:Class which ll either extnd or implement doesnt have any other requirements.

    Pls ans i hope its now clear...
    Thanks 4 ur replies.


  5. #5
    Junior Member
    Join Date
    Jul 2008
    Answers
    3

    Re: which 1 to use

    pls pls reply


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