When should one use an abstract class and when an interface in java ?

asked 08 Jan '16, 04:45

Foysal's gravatar image


Choosing abstract class or interface is totally upon the design pattern of the project. There are also so many design issues that may derive the developer to invoke abstract class or interface.

Some of them are:
- To use one common single base class for single inheritance use abstract class. For enabling multiple inheritance use interface.
- Abstract class enables declaring non-public members. In contrary, all methods of an interface is public.
- If the base class is going to change in the future an abstract class is a better choice. Adding new method signatures to an interface, all of the classes that have already implemented that interface will have to be changed to implement the new methods.

permanent link

answered 08 Jan '16, 12:30

arsho's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 08 Jan '16, 04:45

question was seen: 1,036 times

last updated: 08 Jan '16, 12:30