What is Abstraction in Object Oriented Programming?

Hi friends. In this article, we will be discussing about what is Abstraction in Object Oriented Programming. Also, we will see a relevant video lecture.

 

What is Abstraction?

Abstraction, is a well-known technique in Object Oriented Programming and generally in Computer Science.

It is a way, of handling a complex problem, by removing the background details. This will allow you to focus on the problem’s core, that is the main concept and thus, easily understand how you can resolve the problem via a program that you can author.

 

Main Benefits of Abstraction

The main benefits of Abstraction in Computer Programming are:

  • It helps reducing complexity in solving problems
  • It contributes to more efficient software design
  • It helps avoiding code duplication
  • It makes it easier to maintain the program

 

Example of Abstraction in C#

The below C# source code, illustrates a simple example of implementing abstraction in C#.

As you can see, the code below, contains an abstract class named “Vehicle“, which has an abstract method that returns an integer and it is named “height()“.  This is the abstraction part of the example; that is an abstract class with an abstract method.

Now, when we want to create a class that derives its characteristics from an abstract class, we create the class along with stating (using the colon (“:”) punctuation mark) that the class is an implementation based on an abstract class and within the body of the class, we override any methods that were originally specified in the abstract class.

To this end, in the below example, after we create the abstract class “Vehicle”, we create the class “Car” which is an implementation of the abstract class. That’s why we define the “Car” class using this code: class Car : Vehicle

Please check the code below, for the full example:

What is Abstraction in Object Oriented Programming? - Article on SQLNetHub

 

Watch a Video Lecture on Abstraction

Below, you can find a video lecture on Abstraction, taken from our course on Udemy, titled “Introduction to Computer Programming for Beginners 2022“. You can enroll to the course, using the link below, which automatically provides a significant discount.

 

Learn Programming From Scratch – Enroll to our Online Course!

Check our online course “Introduction to Computer Programming for Beginners”

Throughout the course, you will learn everything you need to get started with Computer Programming!

Introduction to Computer Programming for Beginners - Online Course
(Lifetime Access/ Live Demos / Downloadable Resources and more!)

Learn More

 

Featured Online Courses:

 

Read Also:

 

Subscribe to our newsletter and stay up to date!

Subscribe to our YouTube channel (SQLNetHub TV)

Easily generate snippets with Snippets Generator!

Secure your databases using DBA Security Advisor!

Generate dynamic T-SQL scripts with Dynamic SQL Generator!

Check our latest software releases!

Check our eBooks!

 

Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

Loading...

Reference: SQLNetHub.com (https://www.sqlnethub.com)

© SQLNetHub