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 does it mean that strings are immutable?
What are the different data types in java?
Explain importance of throws keyword in java?
What is jdbc api?
How do you compare characters in java?
What is object-oriented paradigm?
Is boolean a data type in java?
Can java arraylist hold different types?
Why declare Main() method as a static in java ?
What is polymorphism and what are the types of it?
What language is pass by reference?
Can a class be private in java?
What is static data type in java?
How do you check whether the list is empty or not in java?
What is default locale java?