What is the difference between Abstract Class and Interface
Answer Posted / vikrant
Nothing stops you using interfaces and abstract classes
interchangeably. The difference is in the ideology where to
use it.
An abstract class is to be used when one needs to create a
hierarchy. e.g. Poodle, Pointer and Chihuahua are all breeds
breeds of dogs, they have some common characteristics as
dogs and some special characteristics of its breed. so all
breeds (Poodle, Pointer and Chihuahua classes) will inherit
from the Dog class.
Interface on the other hand is just a contract. The
implementing classes need not be related. Say a 3-D figure.
Sphere, Cone, Cylinder are all 3-D shapes they have nothing
in common apart from being 3-D figures. Each will have their
own equation for calculating area, perimeter, volume. All
need to specify in Shapes interface is that the implementing
class must be able to calculate area, perimeter, volume.
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What are voids?
What is map java?
What is parsing in java?
How do you identify if jvm is 32-bit or 64-bit from java program?
Is java a software?
What is a function easy definition?
why an outer class cannot be declared as private?
How do you reverse sort in java?
What is return type in java?
What is the size of int?
What is a generic code?
What is meant by memory leak?
What are the advantages of java over cpp?
Explain serialization and deserialization in java?
How do you sing an Applet ?