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 501 of 502    Print  
Abstract vs Interface Class
Which is faster at class loading - interface or abstract class? Why?


  
Total Answers and Comments: 7 Last Update: November 17, 2009     Asked by: murali.25 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 21, 2009 05:46:28   #1  
poonamjava Member Since: December 2006   Contribution: 20    

RE: Abstract vs Interface Class
Abstrat class is a super class that only define a generalized form that will be shared by all of its subclasses leaving it to each subclass to fill in the details.

Interface is a keyword to make a class fully abstract.

Poonam

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 5Overall Rating: -5    
October 26, 2009 12:49:05   #2  
DKD_Java Member Since: October 2009   Contribution: 1    

RE: Abstract vs Interface Class

In any case the difference would be too small to be noticeable. The choice between choosing an Abstract class or an Interface is a design decision not a performance one.


 
Is this answer useful? Yes | No
October 28, 2009 08:32:17   #3  
komara_2000 Member Since: October 2009   Contribution: 1    

RE: Abstract vs Interface Class
1. Abstract class for tight coupling and interface for loose coupling.
2. Abstract classes does not support multiple inheritance but interfaces supports.
3. Abstract classes may have concrete methods and constructors but interfaces not.
4. Abstract classes take all the access specifiers but interfaces takes only public.
5. For design issues avoid to use abstract classes like
ArrrayList al new arrayList();//avoid to write
List l new arrayList();//preferable

Note: Program to interfaces only not to implementations




 
Is this answer useful? Yes | No
October 31, 2009 12:56:31   #4  
thimothyarani Member Since: October 2009   Contribution: 1    

RE: Abstract vs Interface Class
Abstract class:

Abstract class must have at least one abstract method.
Abstract keyword must be used for all the methods.
Abstract class must have subclass.

Interface:
Inheritance is possible in interface.
Variables value must be defined in interface.
Many interface can be implemented by a single class.
Methods can be defined in interface and used in class.

 
Is this answer useful? Yes | No
November 04, 2009 08:28:05   #5  
ari.patidar Member Since: November 2009   Contribution: 1    

RE: Abstract vs Interface Class
Abstract class has both defined and undefined behaviour where as interface are used when any sub system of our application are frequently changed.
 
Is this answer useful? Yes | No
November 08, 2009 12:08:39   #6  
ansh89 Member Since: March 2009   Contribution: 1    

RE: Abstract vs Interface Class
Interface class will load faster.
 
Is this answer useful? Yes | No
November 17, 2009 13:54:06   #7  
Mathewpjose Member Since: November 2009   Contribution: 2    

RE: Abstract vs Interface Class

Abstract classes are used when they have some sharable implementations and some specific methods left to subclasses to implement. Interface is used when there are no sharable implementation and the implementation changes frequently.

Abstract class can have methods which are abstract or not abstract. All methods of interface should be implemented unless the implementation is an abstract class.

Abstract class can be subclassed interface class can be implemented.

Thanks
Mathew

 
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