OOPS – Object
Oriented Programming Structure
- Object
- Class
- Inheritance
- Polymorphism
- Encapsulation
- Abstraction
Object
Object is a real
time entity; every object has its own behavior. Object is instance of a
Particular class. We can instance more than one object for the class, using
this object we can access class methods
Object is a collection of data members (variables) and
member functions (methods).
Without creating
an object we can’t access the member functions, methods in a class.
In real time
examples for the objects are Car, Bike, Mobile, Bicycle and etc. Car can have
accessories like wheels, lights, glasses, seats etc .we can call directly it
has car instead of all the accessories names and its own behavior.
Object can be physical and logical.
Note: - Object may be same but Places (Address) are
different. For example Two same company, same model cars but placing location
is different.
Class
Class is collection of data members, member functions,
properties and etc grouped into a single unit.
To create a class we
will use class key word with name and access modifier.
By using class we can access all methods, variables and properties
in that class. we can create more than one object for one class.
We have above object car different models alto, Suzuki, Benz
all comes under Car Class,
Mobile objects Nokia, Samsung etc all comes under Cell Phone
Class.
Inheritance
Inheritance is the process of deriving the
features form Base/Parent class to Derived/Child class. In real time example is
human being, like children’s has some of the qualities of their Parents.
By default every class will be
inherited from System.Object class having default methods
- Equals()
- GetHashCode()
- GetType()
- ToString()
Advantages:-
1)
Reducing the size of the program
2)
Code Re-usability we are using parent class
methods and properties
3)
Will save the time too.
Inheritance Types:-
- Single level inheritance
- Multilevel inheritance
- Hybrid inheritance
- Hierarchical inheritance
- Multiple inheritance
- Single level inheritance: -
One parent class will inherited to one child class called single level inheritance.By using Child class object we can access all Parent class fields, properties, methods, variables and etc
Multi level inheritanceBase class is derived to child class and child class is derived to another child class called multi level inheritance.By using child class object we can access all Parent class fields, properties, methods, variables.
Polymorphism
The word polymorphism means Many forms, For Example A Person can act as Stundent in the school, act as Son at home and etc.
Polymorphism can be Run time or Compile time we also called as Static Binding(Compile time or early binding) and Dynamic Binding(Run Time or Late binding).
1) Static Polymorphism:
i) Method overloading
ii) Operator Overloading
i) Method overloading:
Same method name and return type with diffent types or number of Parameters called method overloading
1) Run Time Polymorphism:
1 Comments:
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
Regards,
Asp.Net Training in Chennai | Best Dot Net Training in Chennai
Selenium Coaching Institute in Chennai | Selenium Training in Chennai
Best Software Testing Training Institute in Chennai With Placement | Software Testing Training Institute in Chennai
Java Training Institute in Chennai | Core Java Training in Chennai | Java Course and Certification
PHP Course in Chennai | PHP Training Institute in Chennai | PHP certification in Chennai