Answer Posted / mohd shakir
I think if you have basics knowledge of any OO language then you should be aware of basic definition of Interface and Abstract class.
Here I am going to explain when to use Interface and when to use Abstract class.
Abstract class:-> If you have a common functionality that is used by its subclasses then put that method in super abstract class(now you need not to define that common method in every subclass again and again) This is what you can't do with Interface(because all the methods are by default abstract).
Interface:-> If you don't have the scenario as I discussed above(in abstract class)then choose Interface.And you can also achieve multiple inheritance using Interface that is not possible in case of Abstract class.
| Is This Answer Correct ? | 21 Yes | 1 No |
Post New Answer View All Answers
We are seeing so many videos/audios as many web sited. But question is these videos or audios are stored in Databases ( Oracle, Mysql, Sybase,... ) or stored any file directory from there they will give the link for that? Pls explain and give sample code to achieve this one? Thanks, Seenu.
What are the major advantages of internal iteration over external iteration?
What is abstract class constructor called?
List the different types of classloaders in java.
What is exception propagation?
What are the restrictions imposed by a Security Manager on Applets?.
What is procedure writing?
Will the jvm load the package twice at runtime?
How do you get length in java?
do I need to use synchronized on setvalue(int)? : Java thread
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????
Can we use string in switch case in java?
What exceptions occur during serialization?
What is return keyword in java?
What are the differences between wait() and sleep()?