Abstract class and Interface

Difference between an abstract class and Interface is as

Methods

Interface implicitly abstract
Keyword abstract is required for abstract method, can include normal methods as well.

Variables
Interface variables are by default final
Abstract class can contain both final and non final variables

Implementation
Interface can only be Implemented where as an Abstract class need to be “extends” ed.
It is good to Design By Interface.
A Java class can implement multiple interfaces but it can extend only one abstract class.
an interface can extend another interface, but any class can extend an abstract class.
An interface cannot provide any code, just the signature.
Abstract class can provide complete, default code and/or just the details that have to be overridden.

Constructor
Abstract class can have constructor but interface can not have constructor.
Abstract class constructor run when one of its subclass constructor execute.

Coupling
Interface is loosely coupled where as abstract class is tightly coupled. 

  • ArrayList and LinkedList

    LinkedList and ArrayList are two different implementations of the List interface. LinkedList implements it with a doubly-linked list. ArrayList implements it with a dynamically resizing array. As with standard linked

  • ArrayList and Vector

    There are four factors to consider: API Synchronization Data growth Usage patterns Synchronization Vectors are synchronized. Any method that touches the Vector’s contents is thread safe. ArrayList, on the other

  • Bean, Pojo, VO and DTO

    Java Beans JavaBeans are reusable software components for Java that can be manipulated visually in a builder tool. Practically, they are classes written in the Java programming language conforming to

Leave a Reply

Your email address will not be published. Required fields are marked *


*