Java | Abstract Class vs Interface :


              ~~ CORE-JAVA ~~


     1.1 Java Intorduction
     1.2 Java history
     1.3 Java features
     1.4 Diff b/w Java & C++
     1.5 Java Variables
     1.6 Java Data Types
     1.7 Typecasting
     1.8 Arrays

 2. OOPS

     2.1 Introduction
     2.2 Class
     2.3 Object
     2.4 Static Keywords
     2.5 Constructors
     2.6 This KeyWord


     3.1 Inheritance (IS-A) 
     3.2 Aggregation (HAS-A)


     4.1 Polymorphism & Its Type
     4.2 Method Overloading
     4.3 Method Overriding
     4.4 Super Keyword
     4.5 Final Keyword
     4.6 Dynamic Binding


     5.1 Abstract Classes & Methods
     5.2 Interfaces
     5.3 Abstract vs Interface


     6.1 Encapsulation


     7.1 String
     7.2 String Buffer
     7.3 String Tokenizer


     8.1 Predefined packages
     8.2 Userdefined Packages
     8.3 Access Specifiers


     9.1 Introduction
     9.2 Pre Defined Exceptions
     9.3 Try-Catch-Finally
     9.4 Throws, throw
     9.5 User Defined Exception


     10.1 Introduction
     10.2 Thread Creations
     10.3 Thread Life Cycle
     10.4 Life Cycle Methods
     10.5 Synchronization
     10.6 Wait() notify() notify all()


     11.1 Introduction
     11.2 Wrapper Classes


     12.1 Introduction
     12.2 List interface
     12.3 Set interface                                 12.4 Map interface                           


     13.1 Introduction
     13.2 Member inner class
     13.3 Static inner class
     13.4 Local inner class
     13.5 Anonymous inner class

 14. CoreJava Interview Questions

As we know Abstract Class and Interface both are using to achieve Abstraction in Java. For both instantiation is not possible, but still lots of differences are there, we will see most of them.

Abstract ClassInterface
If we are talking about partially Implementation, not complete implementation, then we should go for Abstract Class only.If we don’t know anything about implementation, but we have requirement only, then we should go for Interface only.
We need to use Abstract Keyword, to declare Abstract ClassFor Interface, we need to use interface keyword to declare.
We can extend Abstract Class using extends keywordFor Interface, we need to use implements keyword to implement interface.
An Abstract Class can extend another Java Class and implement multiple Java Interfaces.An Interface can extend another Java Interface only.
For Abstract Class, it supports abstract and non-abstract both methods.For Interface, it supports abstract methods only.
Abstract Class doesn’t support multiple Inheritance.Interface supports multiple Inheritance.
There is no restrictions for Abstract Class method modifiers. We can use any modifiersFor Interface, below modifiers are not allowed for Interface methods. Strictfp, protected, static, native, private, final, synechronized
Abstract Class variables need not be public, final, static.Every variable present in Interface is public, static, final by-default whether we declare or not.
For Abstract Class Variable, there is not such type of restrictions like performing initialization at the time of declaration only.For Interface variable, Compulsory we have to initialize at the time of declaration only.
In Abstract Class we can take instance and static block also.In Interface, we can’t take instance and static blocks.
Inside Abstract Class we can take Constructor also.Inside Interface we can’t take Constructor.

Help Others, Please Share