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


Please Help Members By Posting Answers For Below Questions

How do generics work in java?

506


You're given a Boolean 2D matrix, can you find the number of islands?

580


What is meant by object oriented programming – oop?

532


How is Object Oriented Programming different from Procedure Oriented Programming?

577


Why scanner is used in java?

537






What is the purpose of static methods and static variables?

528


Why to use nested classes in java?

575


What is a finally block?

544


Can you extend main method in java?

607


What is qualitative variable?

510


What is skeleton and stub? What is the purpose of those?

528


What do you mean by object?

532


Explain the features of java?

575


What methodology can be utilized to link to a database?

495


What is a substring of a string?

548