what is the difference between abstract class and
Interface?where we can use it in realtime projects?
Answer Posted / vinod
We use Abstract class and interface to enforce some rules to the classes which extends/implements. For example we can define a class say "Bird" and we can declare methods say "Fly()", "Walk()". This means whatever the class that is derived from Bird has to override or give definition for Fly() and Walk() and therefore we are making sure that all the derived classes follows or has the common functionalities. In other way the classes derived from superclass should have common properties. In addition to this the derive class can have its own methods like "Swim()"...
In case of Abstract class we can define COMMON functionalities in super class and those can be used in the derived class where as in Interface we cant do that. ( this i would say as advantage of abstract class)
In case of Interface the derived class can implement any number of interface but restricted to extend only one abstract class (this i would say as advantage of Interface)
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Variable of the boolean type is automatically initialized as?
What is difference between jdk,jre and jvm?
Why can we not override static method?
What are the types of collections in java?
What is an interoperable application in java ?
What is difference between string and stringbuffer?
What is a databasemetadata?
What does a method signature consist of?
what is meant by encapsulation?
Is main is a keyword?
Can two objects have same hashcode?
What are design patterns and please explain?
What is command line argument
EDS (Electronic Data Systems India Pvt Ltd) at Chennai on 16-12-2006.
What's the purpose of using break in each case of switch statement?