---
title: "Abstraction in Java"  
description: "In this article I am telling about Abstraction in Java"  
author: "Manoj Pandey"  
published: 2015-03-30  
updated: 2024-08-01  
canonical: https://www.mindstick.com/articles/1707/abstraction-in-java  
category: "java"  
tags: ["java"]  
reading_time: 2 minutes  

---

# Abstraction in Java

Abstraction is a process of hiding the [implementation](https://answers.mindstick.com/qa/44913/who-is-the-minister-of-statistics-and-programme-implementation) details and showing only [functionality](https://www.mindstick.com/blog/136/using-watermark-functionality-in-textbox-by-jquery) to the user. Abstraction in java is achieved by using [interface and abstract](https://www.mindstick.com/forum/157791/explain-the-difference-between-interface-and-abstract-class-with-examples) class. Interface give 100% abstraction and [abstract class](https://www.mindstick.com/articles/1430/abstract-class) give 0-100% abstraction.\

For example you are using [mobile phone](https://yourviews.mindstick.com/view/84695/coca-cola-to-launch-it-s-mobile-phone-trending-2023) for calling. You don’t know how it’s work and what its process but you know how to call, here process is abstraction. Simply process is hide and external details is visible.

##### What is Abstract class in Java?

A class that is [declared as](https://answers.mindstick.com/qa/37821/which-word-was-declared-as-2017-s-word-of-the-year-by-oxford-dictionary) abstract is [known as](https://answers.mindstick.com/qa/38482/name-the-world-s-lightest-material-which-was-manufactured-by-isro-scientists-at-the-vikram-sarabhai-space-centre-thiruvananthapuram-and-is-also-known-as-blue-air) abstract class. An abstract class may have [abstract methods](https://www.mindstick.com/forum/159550/how-to-implement-an-interface-with-two-abstract-methods-by-a-lambda-expression) and not-[abstract method](https://www.mindstick.com/articles/23305/abstract-methods-and-class-in-c-sharp). It cannot be instantiated.

##### Syntax

```
abstract class className{             -----}
```

What is Abstract method in Java?

A method that is declare as abstract and does not have implementation is known as abstract method. If you define abstract method than class must be abstract.

If you are extending abstract class then you have compulsory to override its methods.

Syntax

abstract return_type method_name();

##### Here I am creating a sample of abstraction

1. My Abstraction class

```
public abstract class Data {          // abstraction method     protected abstract int StudentId();      // abstraction method     public abstract String getStudnetCollegeInfo();      // non abstraction method     public String getStudentPersonalInfo() {           return "\n Studnet Address-:     10B mg road Mumbai India \n Student Contact No-:  00000000\n Student Father Name-: Zack Anderson";     } }}
```

2. Main class

```
public class Student extends Data {      //Override Abstraction methods     @Override     public String getStudnetCollegeInfo() {            return "\n Student Name-:        Carry Anderson";     }      // Override Abstraction methods     @Override     protected int StudentId() {           return 101;     }      public static void main(String args[]) {           Student student = new Student();      System.out.print(" Student Id-:\t       " + student.StudentId());           System.out.print(student.getStudnetCollegeInfo());           System.out.print(student.getStudentPersonalInfo());      } }
```

After run [your application](https://answers.mindstick.com/qa/95487/how-do-you-troubleshoot-when-your-application-link-is-not-responding) output

![Abstraction in Java](https://www.mindstick.com/mindstickarticle/d6e6afb5-0b07-4f26-9aae-5745d95ad185/images/0ec38aa8-7257-4f10-bd51-1a31a3432258.png)

---

Original Source: https://www.mindstick.com/articles/1707/abstraction-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
