Total Page Preview:   000000000361

What is encapsulation in OOPS in English and Hindi

 

 

Encapsulation in OOPS in English:

Encapsulation is one of the fundamental principles of object-oriented programming (OOP), which refers to the bundling of data and methods that operate on that data within a single unit called a class. The data is kept private and can only be accessed through the methods defined in the class, which provides better control over the class's internal state and ensures that the class's implementation details are hidden from the outside world.

Here's an example of encapsulation in C#:

In this example, the Employee class encapsulates the data fields name, age, and salary, along with the methods DisplayEmployeeDetails() and IncreaseSalary(). The name, age, and salary fields are declared as private, which means that they can only be accessed within the class. The DisplayEmployeeDetails() method provides a way to display the employee's details, while the IncreaseSalary() method allows increasing the employee's salary by a certain amount.
By encapsulating the data fields and methods within the Employee class, we can ensure that the implementation details are hidden from the outside world, and the class can be used in a more secure and controlled way.
 
 
 
Encapsulation in OOPS in Hindi:
Encapsulation ek OOPs (Object-Oriented Programming) concept hai jo data hiding ke liye use kiya jata hai. Encapsulation ka use data ko secure karne ke liye kiya jata hai, taki data ke bina program ko access karne se roka ja sake.
C# mai, encapsulation ko class ke access modifiers ke through achieve kiya jata hai. Class ke members ko public, private, protected, or internal access modifiers ke through access diya jata hai.
Example:
 

Is example mai, Employee class mai EmpName and EmpId private variables hai jo encapsulated hai. Inhein class ke bahar se access nahi kiya ja sakta hai. Inhein class ke bahar se access karne ke liye public properties ka use kiya jata hai, jo set or get methods ke through private variables ko access karte hai. Is tarah, data ko secure karne ke sath sath class ke members ko control karne ka bhi option mil jata hai.

 

 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: