what is the difference between abstract class and
Interface?where we can use it in realtime projects?
Answer Posted / arvind
1.interface contains methods that must be abstract;
abstract class may contain concrete methods.
2.interface contains variables that must be static and
final; abstract class may contain non-final and final
variables.
3.members in an interface are public by default, abstract
class may contain non-public members.
4.interface is used to "implements"; whereas abstract class
is used to "extends".
5.interface can be used to achieve multiple inheritance;
abstract class can be used as a single inheritance.
6.interface can "extends" another interface, abstract class
can "extends" another class and "implements" multiple
interfaces.
7.interface is absolutely abstract; abstract class can be
invoked if a main() exists.
8.interface is more flexible than abstract class because
one class can only "extends" one super class,
but "implements" multiple interfaces.
9.If given a choice, use interface instead of abstract
class.
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
What is an example of declaration?
What is keyset in java?
What is Java Package and which package is imported by default?
What about features of local inner class?
does java support pointers?
Similarity and difference between static block and static method ?
Why are arrays useful in java?
What is variable argument in java?
Why is java so popular?
What are the main differences between notify and notifyAll in Java?
How do you use spaces in java?
How do you write methodology?
What is nan in java?
What are some characteristics of interference class?
Explain the importance of finalize() method.