Difference between an abstract class and an interface? [duplicate]
Possible Duplicate:
Interface vs Base class
A class implementing an interface
has to implement all the methods of the interface, but
if that class is implementing an abstract开发者_StackOverflow class
is it necessary to implement all abstract methods
?
object
of that class which is implementing the Abstract class
???If you implement an abstract class and don't implement all the abstract methods, that class also has to be declared abstract, and therefore cannot be instantiated.
For example:
public abstract class A {
public abstract method1();
}
public abstract class B extends A {
}
In the above example you would not be able to call new B();
If a class inherits an abstract class, it either has to implement all abstract members, or it has to be abstract too.
So, if the class doesn't implement all members, you can't create an instance of it.
精彩评论