GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 230 of 928    Print  
What is the difference between Abstract class and Interface

Answered by Scott on 2005-05-12 10:03:06: An abstract class can contain non-abstract methods which do not have to be overridden in the subclass. 
 
There is no difference between a fully abstract class (all methods declared as abstract and all fields are public static final) and an interface.



  
Total Answers and Comments: 25 Last Update: September 25, 2009   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Nandesh
 
what do you mean by marker?

Above answer was rated as good by the following members:
neeraj maurya
  Sorting Options  
  Page 2 of 3   « First    1    2    3    >     Last »  
November 06, 2006 04:39:59   #11  
sonal watane        

RE: What is the difference between Abstract class and ...

encapsulation the wrapping up of data into a single unit.

whereas abstraction refers to the act of representing essential features

without including the background details.


 
Is this answer useful? Yes | No
April 05, 2007 13:40:59   #12  
Palanisami        

RE: What is the difference between Abstract class and ...
1. Abstract Class may contains constructor but interface does not contain constructor.

2.By default all variables in interfaces are static and final then we can't declare method as final.

3.In Interface all methods shuld be public but mot in abstract class.

4.interface supportes multiple inheritance but abstract class does not support.

5.we should initialise variables in interface but not necessory in abstract class.

 
Is this answer useful? Yes | No
June 30, 2007 21:05:07   #13  
sripal reddy        

RE: What is the difference between Abstract class and ...
An abstract class is class with zero or more abstract methods. An interface is a specification of method prototype.
 
Is this answer useful? Yes | No
July 24, 2007 04:49:20   #14  
Akanksha Rakesh        

RE: What is the difference between Abstract class and ...

In design you want the base class to present only an interface for its derived classes. This means you don t want anyone to actually instantiate an object of the base class. You only want to upcast to it so that its interface can be used. This is accomplished by making that class abstract using the abstract keyword. If anyone tries to make an object of an abstract class the compiler prevents it. The interface keyword takes this concept of an abstract class a step further by preventing any method or function implementation at all. You can only declare a method or function but not provide the implementation. The class which is implementing the interface should provide the actual implementation.


 
Is this answer useful? Yes | No
August 22, 2007 10:48:49   #15  
Raja Pachamuthu        

RE: What is the difference between Abstract class and ...
Absraction: The process of extracting essential information and hiding irrelevent details

Encapsulation: The process of binding the code and data together in a single unit

 
Is this answer useful? Yes | No
August 29, 2007 09:06:53   #16  
ajan        

RE: What is the difference between Abstract class and ...
You have given difference for the above question such as Abstract class does not support Multiple Inheritance. Interface supports Multiple Inheriatnce . Can you provide me an example for this difference. If possible give me an real time example
 
Is this answer useful? Yes | No
September 09, 2007 15:22:57   #17  
Sandip mple:        

Abtraction and Encapsulation
The main differece is
Abstraction: In this we can identify the specific properties and attributes of a pertricular class.
and exposing the data to the user ..........
example: A car we can know or see that what it look lies in color in the restpect to body of car but we can not know the fearchers they are using into the car


Encapsulation:
Binding the data and functions into the single unit.
i.e in the other way u can say that hiding the details from the others..

example :
same Car
in which we can see how the car is but when it is not working in that case i can not repaire it b'coz all the details of repairing are hidden from me ...

 
Is this answer useful? Yes | No
September 11, 2007 02:57:06   #18  
madhavi        

RE: What is the difference between Abstract class and ...
We are marking the class so that JVM recognize that class and perform certain action for that. ex: ref clone
 
Is this answer useful? Yes | No
January 04, 2008 13:29:04   #19  
harikrishna Member Since: November 2005   Contribution: 1    

RE: What is the difference between Abstract class and Interface
the abstract class have both abstract methods and concrete methods

in case of interface have only abstract methods.

we can not create instance for abstract class and an interface

 
Is this answer useful? Yes | No
January 06, 2008 13:48:06   #20  
Mithun Challa Member Since: January 2008   Contribution: 6    

RE: What is the difference between Abstract class and Interface
Ok this is one of the common interview questions. Let me put this in simple words

when you use Interface :
There can be different classes which show different behaviour. Like consider a case I want to put all animals in a tree structure. I have top most defination as Animal then we have birds reptiles mammals etc.. Now all these have different features from each other yet they show some common features like they move they eat food ... so i will use Animal as interface and define those features in the class that implements it.

when you use abstract class:
when i want to show a is-a type of realtion. now lets go further with the same example now I want to further classify my birds as those which can fly and those that cann't fly.. now this is specific to the birds in here i will go with abstract class.



 
Is this answer useful? Yes | No
  Page 2 of 3   « First    1    2    3    >     Last »  


 
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