when to use abstract class and when to use interface?
Answer Posted / amit
Abstract provides both methods with and without body.
Adding new methods in abstract class in middle of
development life cycle won't break existing sub classes
unless these methods are declared as mustoverride. If there
are frequent addition of new methods properties and so on.
one should use abstract..
Whereas on the other hand interface can fill gap of
multiple inheritance. One can
implement from more than one interface. Not same with
Abstract. One can inherit
from only one abstract class.
| Is This Answer Correct ? | 44 Yes | 6 No |
Post New Answer View All Answers
What is final, finally, finalize?
What are the different access modifiers available in java?
What's the access scope of protected access specifier?
What are recursive functions?
Is special character in java?
What is contract between hashcode and equal method?
What are format specifiers in java?
Is string a wrapper class?
Is this valid in java ? Can we instantiate interface in java?
When can an object reference be cast to an interface reference in java programming?
What is the purpose of an interface?
List some important characteristics on jre
What is the difference between the prefix and postfix forms of the ++ operator?
Is zero a positive integer?
Which one of the following suits the description of a string better: derived or primitive?