what is the difference between abstract class and
Interface?where we can use it in realtime projects?
Answer Posted / anshul verma
* Major diffrence :- Interfaces are fully implementation of
abstraction
Abstract classes are Partially implementation of abstraction
that's a very important diffrence....
and
The core diffrence between abstract class and interface is
that interface does not allow implementation of method but
abstract class allows.
Interface is a bunch of declaration of relevant functions.
In real time projects, interface can used if we have to
implement any framework.for eg, if want to implement the
framework of stack,we can do it by defining the prototypes
of push(),pop(),peek() methods in an interface and then
implementing it by any class.
Abstract classes is useful when we are not
required to implement all methods in our class.for eg,we
have Vehicle class, we want to implement classes for two
wheelars in which hand brake is given and in some vehicles
foot brake are given, then Vehicle class abstract class can
be defined as abstract class and implemention of brake()
can be done in applicable classes.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the difference between inner class and nested class?
Is alive method in java?
What are the advantages of defining packages in java?
Differentiate between nested and inner class in java.
What are thread priorities and importance of thread priorities in java?
how many types of Inheritance?
What is an object in java and how is it created?
What is the difference between equals() and?
What is tochararray in java?
What is tree in java?
What is difference between string and stringbuffer?
Why convert an applet to an application?
Differentiate between == and equals().
Why Set interface contains unique elements, what internally implemented for this so that it contains unique elements?
Can we declare the static variables and methods in an abstract class?