Difference between abstract class and interface

Answers were Sorted based on User's Feedback



Difference between abstract class and interface..

Answer / rajneesh hajela

ABSTRACT CLASS:
1) we can't create object of abstract class.
2) we can declare a variable.
3) we can make normal method and abstract method.
4) we can't make method body with abstract method.
5) in derived class we can use abstract method by override
keyword.
6) we can't use multiple inheritance in abstract class.
7) Absrtact class can be extended by only one class;
Interface can be implemented by more than one class;
ie. class can inherit only one abstract class


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

10)An abstract class can contain fields,
constructors, or destructors and implement properties. An
interface can not contain fields, constructors, or
destructors and it has abstractmethod,property's signature
but no implementation etc.

Rajneesh Hajela
Gwalior(M.P.)

Is This Answer Correct ?    52 Yes 11 No

Difference between abstract class and interface..

Answer / aninda bhattacharyya

Abstract class defined with methods. Interface will declare
only the methods. Abstract classes are very much useful
when there is a some functionality across various classes.
Interfaces are well suited for the classes which varies in
functionality but with the same method signatures.

Is This Answer Correct ?    52 Yes 13 No

Difference between abstract class and interface..

Answer / mahendra pratap singh

An Abstract Class can contain default Implementation, where
as an Interface should not contain any implementation at
all. An Interface should contain only definitions but no
implementation. where as an abstract class can contain
abstract and non-abstract methods. When a class inherits
from an abstract, the derived class must implement all the
abstract methods declared in the base class. an abstract
class can inherit from another non-abstract class.

Is This Answer Correct ?    42 Yes 13 No

Difference between abstract class and interface..

Answer / amit sinha

a) Interface force class to implement all methods and
function for implement while as Abstarct class does not
force class , you can override method and fuction of base
class .
b) Interface contains method and function without
implemention with signature only while as Abstract class
contains method , function with implemention and signature
c) By default , method ,function and members is public in
nature within interface , while as In Abstract class ,
memebers can be protected as well private etc..
d) Interface supports Multiple inheritance while as
Abstract class does not support Multiple Inheritance
e)Abstract classes are faster than interfaces
f)you can prevent not required method to override in
Abstract class , but not in Interface

Is This Answer Correct ?    38 Yes 11 No

Difference between abstract class and interface..

Answer / rajesh

1.)when a class is said to be Abstract if it contain both
implementation & unimplementation details ie,method with
body(implementation),method with out body(un-implementation).
in a class if any method with out body is said to be
abstract method.then before the class name we should keep
abstract to the class.
2.)An interface is a one which is having un-implementation
details(method with out body),multiple inheritence can be
achieved in java by using interfaces.

Is This Answer Correct ?    32 Yes 14 No

Difference between abstract class and interface..

Answer / thakur laxmikant

1. Abstract class can have implemented methds
but interface contains only final varibles and
method declaration(signature);

2. In Abstract class there is "IS A " Kind of relationship
between abstract class and its implemented method class
but in interface it can be between any non-relative
classes.

3. Absrtact class can be extended by only one class;
Interface can be implemented by more than one class;
ie. class can inherit only one abstract class
but class can implement more than one interface.

4.A class implementing an interface has to
implement all the methods of the interface,
but the same is
not required in the case of an abstract Class.

5.Access modifiers (protected, abstract, public, etc. )are
useful in abstract Classes but not in interfaces.

Is This Answer Correct ?    20 Yes 7 No

Difference between abstract class and interface..

Answer / shaveen kaushal

1)We define an Interface in the Java application with a
set of abstract methods without any implementation. Which
means all the methods of an interface are by default
abstract methods and public methods.
2)Once an Interface is defined in the application then any
class can implement that interface, in such case the class
must be implemented with all the mehtods of the respective
Interface otherwise the class will become as abstract class.
3)A class can implement any no. of interfaces, in such case
the class must be implimented with all the methods of those
interfaces otherwise the class will become as abstract class

Is This Answer Correct ?    17 Yes 9 No

Difference between abstract class and interface..

Answer / subru

a.Abstract classes can inherit interfaces while interfaces
cannot inherit abstract classes
b.Abstract classes can have implementation within them
while interfaces cannot contain any code

Is This Answer Correct ?    18 Yes 10 No

Difference between abstract class and interface..

Answer / niraj kumar

)We define an Interface in the Java application with a
set of abstract methods without any implementation. Which
means all the methods of an interface are by default
abstract methods and public methods.
2)Once an Interface is defined in the application then any
class can implement that interface, in such case the class
must be implemented with all the mehtods of the respective
Interface otherwise the class will become as abstract class.
3)A class can implement any no. of interfaces, in such case
the class must be implimented with all the methods of those
interfaces otherwise the class will become as abstract class

Is This Answer Correct ?    17 Yes 9 No

Difference between abstract class and interface..

Answer / max

* An abstract class can have abstract members as well
non abstract members. But in an interface all the members
are implicitly abstract and all the members of the interface
must override to its derived class

* The members of the interface are public with no
implementation. Abstract classes can have protected parts,
static methods, etc.

for more detailed main five difference visit this link

http://codesforprogrammers.blogspot.com/search/label/Abstract%20class%20vs%20Interface

Is This Answer Correct ?    18 Yes 11 No

Post New Answer

More Dot Net AllOther Interview Questions

Explain the race around condition? : .NET Architecture

0 Answers  


how do create a repeater

3 Answers  


how do u achieve multilevel inheritance in .NET ?

9 Answers   Accenture, Ness Technologies, SteelWedge,


how to manage session in webgarden ?

3 Answers   Binary Logics, Ness Technologies,


Define pipelining? : Dot net architecture

0 Answers  






What is Object Caching in Visual Studio 2010?

0 Answers   Arigo Infotech,


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

0 Answers  


Explain dma? : Dot net architecture

0 Answers  


Explain pipelining? : Dot net architecture

0 Answers  


what does dot in .net means

1 Answers  


What is .net mobile utility controls. Explain with an example? : Microsoft dot net mobile

0 Answers  


Session State and can i store desirialized object in state server, if yes how and if not why.

0 Answers   PCS,


Categories