By: Karthik Emailed: 1768 times Printed: 2515 times
- interface contains methods that must be abstract; abstract class may contain concrete methods.
- interface contains variables that must be static and final; abstract class may contain non-final and final variables.
- members in an interface are public by default, abstract class may contain non-public members.
- interface is used to "implements"; whereas abstract class is used to "extends".
- interface can be used to achieve multiple inheritance; abstract class can be used as a single inheritance.
- interface can "extends" another interface, abstract class can "extends" another class and "implements" multiple interfaces.
- interface is absolutely abstract; abstract class can be invoked if a main() exists.
- interface is more flexible than abstract class because one class can only "extends" one super class, but "implements" multiple interfaces.
- If given a choice, use interface instead of abstract class.
|1. ||View Comment|
What is the difference between an Interface and an Abstract Class?
A. 1.An abstract class can have instance methods that implement a default behavior
B. 2. An Interface can only declare constants and Interface methods, but cannot implement default behavior and and all methods are implicitly abstract...
C. 1. An abstract class is a class which may have the use all flavors of class members (private, of protected, et) but has some abstract methods.
2. An Interface has all public members and no implementation.
C. both A and B
D. none of these
View Tutorial By: RAJA at 2015-06-26 17:28:31
More Latest News
More Tutorials by Karthik
More Tutorials in Interview
Most Viewed Articles (in Interview )
Most Emailed Articles (in Interview)