GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 149 of 502    Print  
if interface & abstract class have same methods & abstract class also not contain any implementation for those methods which one you prefer ?
use abstract class because we implement only requried methods of abstract class but for interface we must implement all methods whether or requried or not


  
Total Answers and Comments: 6 Last Update: August 24, 2006     Asked by: tulasi 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: srikanthboddu
 
implementing an interface for a class is very much effective ratherthan extending an abstract class bcause we can extend some other useful class for this subclass

Above answer was rated as good by the following members:
sandeep_14185
October 31, 2005 13:10:45   #1  
Mujeeb        

RE: if interface & abstract class have same methods & ...
Obviously one should ideally go for an interface.Coz as we all know one can only extend just 1 class where as one can implement as many interfaces as one can.And in case the class under contention has got some threads to invoke or if it is some JFrame kind of class then obviously it would make sense to use the interface.
 
Is this answer useful? Yes | No
November 06, 2005 14:48:46   #2  
srikanthboddu        

RE: if interface & abstract class have same methods & ...
implementing an interface for a class is very much effective ratherthan extending an abstract class bcause we can extend some other useful class for this subclass
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
November 06, 2005 22:31:02   #3  
Prabakar.Bolla        

RE: if interface & abstract class have same methods & ...
5. how can you load DLL files when your java class is loading first time ?
 
Is this answer useful? Yes | No
November 11, 2005 12:47:48   #4  
mandyjoshi Member Since: November 2005   Contribution: 20    

RE: if interface & abstract class have same methods & ...
It depends on your design. But if your basic question is if you want to declare method without implimenation (which must be implemented by child) where you will prefer to put. Then answer in Interface.
 
Is this answer useful? Yes | No
November 14, 2005 07:29:02   #5  
katam Member Since: November 2005   Contribution: 7    

RE: if interface & abstract class have same methods & ...
abstract class
 
Is this answer useful? Yes | No
August 24, 2006 04:12:08   #6  
msarada Member Since: August 2006   Contribution: 3    

RE: if interface & abstract class have same methods & ...

if we want to have all the other properties of the abstract class along with the unimplemented methods then we prefer an abstract class otherwise we go for an interface(in order to have multiple inheritance).


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape