Search
  • +44-7459919437 (UK- WhatsApp & Direct Call) | +91-6383544892 (India - WhatsApp Only) | Email Id : vinothrwins@gmail.com
Vinoth Q.A Academy
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I

Java

  • What is Java?
  • Why to Learn Java?
  • History of Java
  • Types of Java Applications
  • Naming Conventions
  • Hello World Program
  • Internal Details of Java program
  • What is Java JDK, JRE and JVM ?
  • What is Java Comments ?
  • What is Java Variable?
  • Variable Naming convention
  • Primitive Data Types
  • Non Primitive Data Types
  • Type Casting
  • Java Arithmetic Operators
  • Relational Operators
  • What is logical operators in Java? 
  • What is Assignment Operators in Java? 
  • What is Unary Operators in Java? 
  • What is Ternary Operators in Java?
  • What is Java Control Statements?
  • What are Decision Making statements?
  • What are looping statements?
  • What are Jump statements?
  • What is OOPS concept in Java?
  • Advantages of Java OOPs
  • What is Java Inheritance?
  • What is Java Constructor?
  • What is this keyword?
  • What is Polymorphism?
  • What is super keyword ?
  • What is final keyword? 
  • What are access modifiers?
  • What is Encapsulation? 
  • What is Abstraction? 
View Categories
  • Home
  • Tutorials
  • Java
  • Java
  • What is Abstraction? 

What is Abstraction? 

What is Abstraction? 

Abstraction is a core concept in Object-Oriented Programming (OOP) that focuses on hiding the complex implementation details of a system and exposing only the essential features to the user. It helps in managing complexity by providing a simplified view of complex systems, allowing developers to work with a higher level of understanding.

Key Aspects of Abstraction #

Hiding Implementation Details: Abstraction hides the internal workings of a system or class from the user, providing only the necessary interfaces or functionalities. Users interact with an object through its public methods, without needing to understand its internal implementation.

Simplifying Complexity: By focusing on what an object does rather than how it does it, abstraction simplifies the design and usage of complex systems. This makes it easier for developers to use and understand objects without being overwhelmed by details.

Abstract Classes and Methods: In Java, abstraction is achieved through abstract classes and methods. An abstract class cannot be instantiated and may contain abstract methods, which must be implemented by subclasses. Abstract methods define the interface without specifying the implementation.

Interfaces: Interfaces provide a way to achieve abstraction by defining a contract (set of methods) that implementing classes must fulfill. Interfaces do not provide method implementations, only method signatures.

Examples of Abstraction #

1. Abstract Classes:

// Abstract class

abstract class Shape {

    // Abstract method (does not have a body)

    abstract void draw();

    // Regular method

    void description() {

        System.out.println("This is a shape.");

    }

}

// Concrete subclass

class Circle extends Shape {

    // Providing implementation of the abstract method

    @Override

    void draw() {

        System.out.println("Drawing a circle.");

    }

}

public class Main {

    public static void main(String[] args) {

        Shape shape = new Circle(); // Cannot instantiate abstract class

        shape.draw(); // Outputs: Drawing a circle.

        shape.description(); // Outputs: This is a shape.

    }

}

In this example, Shape is an abstract class with an abstract method draw() and a regular method description(). The Circle class extends Shape and provides an implementation for the draw() method.

2. Interfaces:

// Interface

interface Drawable {

    void draw();

}

// Concrete class implementing the interface

class Rectangle implements Drawable {

    @Override

    public void draw() {

        System.out.println("Drawing a rectangle.");

    }

}

public class Main {

    public static void main(String[] args) {

        Drawable drawable = new Rectangle();

        drawable.draw(); // Outputs: Drawing a rectangle.

    }

}

In this example, Drawable is an interface with an abstract method draw(). The Rectangle class implements the Drawable interface and provides an implementation for the draw() method.

Summary #

  • Abstraction: Hides the complex implementation details and exposes only the essential features or functionalities.
  • Abstract Classes: Cannot be instantiated and may contain abstract methods (methods without implementation) and regular methods.
  • Interfaces: Define a contract of methods that implementing classes must provide, without providing method implementations.

Abstraction helps in managing complexity, promoting code reuse, and improving maintainability by allowing developers to work with high-level concepts and ignoring the intricate details of how those concepts are implemented.

Java
What are your Feelings
Share This Article :
  • Facebook
  • X
  • LinkedIn
What is Encapsulation? 
Table of Contents
  • Key Aspects of Abstraction
  • Examples of Abstraction
  • Summary
© Copyright [2018-2025]. All Rights Reserved.