Abstraction is one of the principle of object oriented programming. It is used to display only necessary and essential features of an object to ouside the world (mechanism to show only relevant data to the user.)
Example:
Necessary things means compulsary to know before starting a car
1. Name of Car
2. Color of Car
3. Steering
4. Rear View Mirror
5. Brakes
6. Gear
Unnecessary things means not that compulsary to know for a Car rider
1. Internal Details of a Car
2. Car Engine
3. Diesal Engine
4. Exhaust System
5. Silencer
Example : Whenever you buy a mobile phone, you see their different types of functionalities as camera, mp3 player, calling function, recording function, multimedia etc. It is abstraction, because you are seeing only relevant information instead of their internal engineering.
Abstraction is a process of hiding the implementation details and displaying the essential features.
How to abstract: - By using Access Specifiers
.Net has five access Specifiers
Public -- Accessible outside the class through object reference.
Private -- Accessible inside the class only through member functions.
Protected -- Just like private but Accessible in derived classes also through member
functions.
Internal -- Visible inside the assembly. Accessible through objects.
Protected Internal -- Visible inside the assembly through objects and in derived classes outside the assembly through member functions.
Example1: A Laptop consists of many things such as processor, motherboard, RAM, keyboard, LCD screen, wireless antenna, web camera, usb ports, battery, speakers etc. To use it, you don't need to know how internally LCD screens, keyboard, web camera, battery, wireless antenna, speaker’s works. You just need to know how to operate the laptop by switching it on. Think about if you would have to call to the engineer who knows all internal details of the laptop before operating it. This would have highly expensive as well as not easy to use everywhere by everyone.
So here the Laptop is an object that is designed to hide its complexity.
Supreeth JRank #2,205 · 639 reputationPosted Sep 22, 2015, 10:11 PM EDT
Munesh SharmaRank #174 · 13.9K reputationPosted Sep 22, 2015, 10:46 PM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 22, 2015, 10:11 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts