Geeks Talk

Prepare for your Next Interview




which 1 to use

This is a discussion on which 1 to use within the Java forums, part of the Software Development category; 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 ...


Go Back   Geeks Talk > Software Development > Java

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-04-2008
Junior Member
 
Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
liz29 is on a distinguished road
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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-06-2008
Junior Member
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tal.benavraham is on a distinguished road
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.
Reply With Quote
  #3 (permalink)  
Old 07-07-2008
Junior Member
 
Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Sukumar Maddineni is on a distinguished road
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
Reply With Quote
  #4 (permalink)  
Old 07-08-2008
Junior Member
 
Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
liz29 is on a distinguished road
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.
Reply With Quote
  #5 (permalink)  
Old 07-08-2008
Junior Member
 
Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
liz29 is on a distinguished road
Re: which 1 to use

pls pls reply
Reply With Quote
Reply

  Geeks Talk > Software Development > Java


Thread Tools
Display Modes



All times are GMT -4. The time now is 06:43 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved