what is the difference between abstract class and
Interface?where we can use it in realtime projects?
Answer Posted / priyanjan
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 ? | 84 Yes | 8 No |
Post New Answer View All Answers
What is an accessor?
What is linked hashset and its features?
What does flag mean in java?
How many characters is 2 bytes?
How is abstraction implemented in java ?
What are actual parameters?
Enlist diffrent types of inheritance supported by java?
Can we override private method in java?
What is floor in java?
What is the purpose of the runtime class in java programming?
How do you create a first line indent?
Why charat is used in java?
What is an example of a conditional statement?
Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?
explain the difference between jdk and jvm?