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

Should a main method be compulsorily declared in all java classes?

538


Is it possible for yielded thread to get chance for its execution again ?

555


How do you start a new line in java?

523


What do you mean by aggregation?

574


What is finally block?

570






How many functional interfaces does java 8 have?

608


How do you override a method in java?

542


What is the difference between a method and a procedure?

552


Outline the major features of java.

569


What is floating data type?

541


What is supplier in java?

565


How to make object serializable in java?

555


What is use of static in java?

536


Explain about class in java?

614


Difference between Linked list and Queue?

613