VB.NET Abstraction

  • Abstraction is the process of providing the essential features of an object without providing its background details or explanation.
  • Classes use the concept of abstraction that is why classes are known as abstract data type. .
  • Abstraction is the process of just highlighting the set of services what we are offering and hiding the internal details.
  • For example, when we use ATM machine to withdraw money then there is only screen is displayed in-front of us. Here we have to enter the detail about pin and we enter into the account to get money; but here there is no internal details are shown to user such as which languages are used to develop the ATM system, how machine gets the input etc.
  • When we hide the data then it is called as data abstraction.
  • Abstraction provides the view which we want to use and does not display the internal functionality.
  • The following image shows the data abstraction:
  • abstraction

Module Module1

Class Sum
Private a, b As Integer
Public Sub addition()
Console.WriteLine("enter a and b :")
a = Console.ReadLine()
b = Console.ReadLine()
Console.WriteLine("Sum : {0}", (a + b))
End Sub
End Class

Sub Main()
Dim s As Sum = New Sum()
End Sub

End Module

In the above example, all the data members and functions are declared and defined or bind inside the class. Here we cannot access the class members directly. Here we can only access the elements of class using the object of the class. Here we get only the addition but how it is performed not displayed to user.
The output is as follows: