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
Should a main method be compulsorily declared in all java classes?
Is it possible for yielded thread to get chance for its execution again ?
How do you start a new line in java?
What do you mean by aggregation?
What is finally block?
How many functional interfaces does java 8 have?
How do you override a method in java?
What is the difference between a method and a procedure?
Outline the major features of java.
What is floating data type?
What is supplier in java?
How to make object serializable in java?
What is use of static in java?
Explain about class in java?
Difference between Linked list and Queue?