Difference between abstract class and interface

Answers were Sorted based on User's Feedback



Difference between abstract class and interface..

Answer / bijayalaxmi pradhan

1.In side an abstract class some of the methods are
abstract and some methods are concrete.But incase of an
Interface all methods are abstract().

2.An abstract class cannot support multiple inheritance,
but an interface can support multiple.

Is This Answer Correct ?    0 Yes 0 No

Difference between abstract class and interface..

Answer / prada

Abstract classes can inherit interfaces while
interfaces cannot inherit abstract classes
but class can implement more than one interface.
The members of the interface are public with no
implementation. Abstract classes can have protected
parts,static methods, etc.

Is This Answer Correct ?    0 Yes 0 No

Difference between abstract class and interface..

Answer / ratikant patra

1.*Abstract class may contain abstract methods,constru-
-ctors,concrete methods,fields....
*interface only contain signature of methods and
fields.

2. *All access specifiers are allowed to class members in
abstract class.By default scope is package or public
depends on programming.
*But data fields and method signatures bydefault final
and public.

****WE KNOW JVM TREATS FINAL METHODS AS INLINE. SO, DYNAMIC-
POLYMORPHISM THROUGH INTERFACE IS FASTER THAN OTHER.
************

3.Abstract class always a super class,only can beextended.
But interface only can be implimented.

4.Code reusability possible by extending abstract classes
*But code reusability not possible using interface.

5.Abstract class is used when programmer need to maintain
property of super class in sub classes i.e. programmer
may override complete methods(but bound to redefine
abstract methods.unless sub class becomes abstract).
*In case of classes implimenting interface must define
all the methods.

6.At a time we can extend only abstract class.
*But we can impliment many interfaces to a class.

RATIKANT PATRA,KIST,BBSR

Is This Answer Correct ?    0 Yes 0 No

Difference between abstract class and interface..

Answer / ashish gupta

1)Abstract class can have either declaration or definition
of any method,however an interface must declare a method
and it can not define it.

2)An interface makes some sort of contract to its
implementing classes to define all the declared methods
within those classes.

3)A class/subclass should Extend the abstract class while a
class/subclass should Implement the interface.

Is This Answer Correct ?    0 Yes 0 No

Difference between abstract class and interface..

Answer / khaleek ahmad

Abstract class is a special kind of class which can not be
instantiated while Interface is an Entity. You can define
some methods in Abstract class but can not in interface

For more detail see at
http://interview-preparation-for-you.blogspot.com/2010/10/difference-between-abstract-class-and.html

Is This Answer Correct ?    0 Yes 0 No

Difference between abstract class and interface..

Answer / karthick

Unlike interfaces, abstract classes can contain fields that
are not static and final, and they can contain implemented
methods. Such abstract classes are similar to interfaces,
except that they provide a partial implementation, leaving
it to subclasses to complete the implementation. If an
abstract class contains only abstract method declarations,
it should be declared as an interface instead.

Multiple interfaces can be implemented by classes anywhere
in the class hierarchy, whether or not they are related to
one another in any way. Think of Comparable or Cloneable,
for example.

By comparison, abstract classes are most commonly subclassed
to share pieces of implementation. A single abstract class
is subclassed by similar classes that have a lot in common
(the implemented parts of the abstract class), but also have
some differences (the abstract methods).

Is This Answer Correct ?    0 Yes 0 No

Difference between abstract class and interface..

Answer / vikas patel

A metho without body it's called abstract method and class
contain the abstract method it's called abstract class..

Interface is the collection of the inheritance..

Is This Answer Correct ?    0 Yes 0 No

Difference between abstract class and interface..

Answer / pankaj

Abstract class can have abstract methods as well as non-abstract(normal methods).
Abstract class is not instantiated.
Abstract method of abstract class always get body from it's sub class.
Abstract method's are always call by Abstract class itself not it's subclass. ex- event handler
Abstract method's must be overridden by it's subclass

Is This Answer Correct ?    0 Yes 0 No

Difference between abstract class and interface..

Answer / rama krishna

Abstract class:

*A class of only Concrete or only Abstract or both.

*Any java class can extend only one abstract class.

*It won’t force the programmer to implement/override all its methods.

*It takes less execution time than interface.

* It allows constructor.

This class can’t be instantiated directly.

A class must be abstract when it consist at least one abstract method.

It gives less scope than an Interface.

It allows both variable & constants declaration.


It allows methods definitions or declarations whenever we want.

It gives reusability hence it can’t be declared as “final”.

Interface:

only abstract methods.


A class can implements any no. of interfaces
(this gives multiple interface inheritance )

It forces the programmer to implement all its methods

Interface takes more execution time due to its complex hierarchy.
* It won’t allow any constructor.

It can’t be instantiated but it can refer to its subclass objects.



It gives more scope than an abstract class.

By default, methodspublic abstract
variablespublic static final.


It allows methods declarations whenever we want . But it involves complexity.

Since they give reusability hence they must not be declared as “final”.

Is This Answer Correct ?    0 Yes 0 No

Difference between abstract class and interface..

Answer / varaprasad

An abstract class will have non abstract methods, but an
interface will have pure abstract methods.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Dot Net AllOther Interview Questions

Explain pipelining? : .NET Architecture

0 Answers  


what is web service?

1 Answers  


Can you explain update progress control?

0 Answers  


7. Oop-Diff B/w Interfacse and abstract class.

3 Answers   PCS,


What is new in the .net 2.0 class library?

0 Answers  






What does the "EnableViewState" property do? Why would I want it on or off?

2 Answers  


How do we do authentications using atlas?

0 Answers  


Explain different pipelining hazards and how are they eliminated? : Dot net architecture

0 Answers  


what is managed code and managed data?

2 Answers   Six Sigma,


What are the different pipelining hazards? : Dot net architecture

0 Answers  


what is authentication and authorization?how do they differ?

5 Answers   Six Sigma,


What is the .net class that allows the retrieval of a data element using a unique key?

0 Answers  


Categories