The main intention of object oriented concept is reusability
of existing code, providing security for data, decreasing the code complexity
i.e., basing on object requirement we coding and executing programs is main purpose of OOPS
Before OOPS there is Structure Oriented Programming
languages are used to develop programs, the limitations of structure oriented
programming languages are no reusability
concept and there is no security for
data . to retrieve the limitations OOPS concept is invited.
Data Encapsulation :
The process of binding data into a
single container is known as data encapsulation.
Here data means methods and
variables and those are binding in a container, here we called CLASS
What is Class ?
Class is a collection of objects
which contains some common features and functionalities.
Class is a combination of member
methods and member variables.
Simply in one word class is blueprint for objects.
Ex ; animal is class for dog , cat
, goat
What is Objects ?
Object is an instance of class and
it is a real world entity which exists physically in world.
Ex : car is class and
Objects are BMW, Audi, Honda etc. there
is exists in market.
Without objects there is no class
like without students there is no Class like cse class, civil class.
SYNTAX for creating a Class:
<access-modifier> class <class-name>
{
Member methods ;
Member Variables ;
}
Ex :
public class MyClass // user defined class
{
string s="DotNet " ; // member variable
public void print() // member method
{
Console.WriteLine("Hello ,"+s);
}
}
SYNTAX for creating a Object :
<class-name> <object-name> = new
<class-name>(parameters);
ex :
class EntryClass
{
static void Main()
{
MyClass object = new MyClass(); // creating an object
object.s = "ramu"; // accessing methods variable through object
object.print(); // accessing member methods through object
Console.ReadKey();
}
Data Abstraction :
Hiding of data is known as Data Abstraction. i.e., Hiding the implementation and providing user required information only.
The nature of "instance" creation is also known as "Data Abstraction".
Access modifiers :
The permissions can be given to the object to access the class members from outside of the class using "access modifiers ".
So hiding of data is data abstraction for example in ATM machine it shows how to put card , how to withdraw money , how to check balance (which is need to people)only But It doesn't display how to collect money in machine, how to edit our balance in our account. that is it shows whatever information required (which is not required for user )only.
--------------------------------------------------------------------------------------------------------------------