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
Explain the difference between map and flatmap stream operation?
What is the purpose of java?
Discuss about garbage collector in Java.
What is java lang object?
What are the differences between string, stringbuffer and stringbuilder?
Why do we declare a class static?
What is field name?
Why are parameters used in functions?
Can we increase size of array?
What is the synchronized method modifier?
Tell me the latest versions in java related areas?
What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?
How can you make a class serializable in java?
What is stringbuffer in java?
What is arrays fill in java?