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 the method overriding?
Define how does a try statement determine which catch clause should be used to handle an exception?
What is palindrome in java?
How many types of equations are there?
Explain the importance of finally block in java?
Explain the scope of a variable.
Which collection is best for sorting in java?
Is there any difference between nested classes and inner classes?
What is :: operator in java 8?
What is final int?
What is Java Shutdown Hook?
What is the difference in between cpp and java? Can u explain in detail?
What is sorting in java?
What is the default size of arraylist in java?
What is java util list?