What is an Abstract Class? Features of Abstract Classes Rules to declare Abstract Classes Procedure to achieve Abstraction in Java The Syntax for Abstract Classes Examples for Abstract Classes Advantages of Abstract Classes Disadvantages of Abstract Classes Interface v/s Abstract Class Interface Agenda
What Is an Abstract Class?
Click here to watch the video
What Is an Abstract Class? Abstract class in Java is considered as a template of methods and variables used in a program. Abstract classes cannot be instantiated directly.
Features of Abstract Classes
Features of Abstract class Template Loose Coupling Code Reusability Abstraction Dynamic Resolution
Rules to Declare an Abstract Class
Rules to Declare an Abstract Class • The keyword “abstract” is mandatory. • Abstract classes cannot be instantiated. • An abstract class must have at least one abstract method. • An abstract class includes final methods. • An abstract class may also include non-abstract methods. • Abstract class can include constructors and static methods.
Procedure to Achieve Abstraction Procedure
Procedure to Achieve Abstraction Abstraction is one of the fundamentals of Object-oriented programming. Abstraction can be achieved by following either of the two below mentioned procedures. • Using an Interface • Using an Abstract Class Procedure
The Syntax for Abstract Classes
Syntax of Abstract Class Abstraction can be achieved by following the syntax mentioned below. abstract class Simplilearn{} abstract void Simplilearn();
Interface
Interface Interface can be defined as a boundary between the method and the class implementing it. In Java, we use interface to achieve abstraction
Syntax of Interface Abstraction can be achieved by following the syntax mentioned below. interface Simplilearn{}
Examples for Abstract Classes
Interface V/S Abstract ClassI
Interface V/S Abstract Class I Interface Abstract Keyword: interface Keyword: abstract Subclasses extend it Subclasses implement it Only one abstract class can be extended Multiple interfaces can be implemented Supports multiple inheritance Does not support multiple inheritance
Advantages of Abstract Classes
Advantages of Abstract Class • Highly beneficial in writing shorter codes • Avoids code duplication • Enables code Reusability • Changes to Internal code implementation is done without affecting classes
Disadvantages of Abstract Classes
Disadvantages of Abstract Class • Abstraction is expensive as sometimes you need to handle cases and situation which are not necessary sometimes. • Object relational impedance mismatch in case of RDBMS • Object relational Mapping in case of Frameworks like hibernate
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beginners | Simplilearn

Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beginners | Simplilearn

  • 2.
    What is anAbstract Class? Features of Abstract Classes Rules to declare Abstract Classes Procedure to achieve Abstraction in Java The Syntax for Abstract Classes Examples for Abstract Classes Advantages of Abstract Classes Disadvantages of Abstract Classes Interface v/s Abstract Class Interface Agenda
  • 3.
    What Is anAbstract Class?
  • 4.
    Click here towatch the video
  • 5.
    What Is anAbstract Class? Abstract class in Java is considered as a template of methods and variables used in a program. Abstract classes cannot be instantiated directly.
  • 6.
  • 7.
    Features of Abstractclass Template Loose Coupling Code Reusability Abstraction Dynamic Resolution
  • 8.
    Rules to Declarean Abstract Class
  • 9.
    Rules to Declarean Abstract Class • The keyword “abstract” is mandatory. • Abstract classes cannot be instantiated. • An abstract class must have at least one abstract method. • An abstract class includes final methods. • An abstract class may also include non-abstract methods. • Abstract class can include constructors and static methods.
  • 10.
    Procedure to AchieveAbstraction Procedure
  • 11.
    Procedure to AchieveAbstraction Abstraction is one of the fundamentals of Object-oriented programming. Abstraction can be achieved by following either of the two below mentioned procedures. • Using an Interface • Using an Abstract Class Procedure
  • 12.
    The Syntax forAbstract Classes
  • 13.
    Syntax of AbstractClass Abstraction can be achieved by following the syntax mentioned below. abstract class Simplilearn{} abstract void Simplilearn();
  • 14.
  • 15.
    Interface Interface can bedefined as a boundary between the method and the class implementing it. In Java, we use interface to achieve abstraction
  • 16.
    Syntax of Interface Abstractioncan be achieved by following the syntax mentioned below. interface Simplilearn{}
  • 17.
  • 18.
  • 19.
    Interface V/S AbstractClass I Interface Abstract Keyword: interface Keyword: abstract Subclasses extend it Subclasses implement it Only one abstract class can be extended Multiple interfaces can be implemented Supports multiple inheritance Does not support multiple inheritance
  • 20.
  • 21.
    Advantages of AbstractClass • Highly beneficial in writing shorter codes • Avoids code duplication • Enables code Reusability • Changes to Internal code implementation is done without affecting classes
  • 22.
  • 23.
    Disadvantages of AbstractClass • Abstraction is expensive as sometimes you need to handle cases and situation which are not necessary sometimes. • Object relational impedance mismatch in case of RDBMS • Object relational Mapping in case of Frameworks like hibernate