OOPs Stands for Object Oriented Programming System.
Methodology to Design programs using class and objects
Pillars of OOPS
Abstractions: hiding complexity and exposing only the relevant details of an entity
Encapsulation: Binding data and operations together in an entity
-Information hiding ==> Access Control modifier (public,protected,private)
-Implementation hiding====>through creation of interface for class
Inheritance: Reusability of code(parent child relationship
Polymorphism: One name , many forms
-static polymorphism - method overloading
-dynamic polymorphism - method overriding
class- Blueprint from which objects are created
A class is a template from which objects are created. A class is a blueprint, or prototype which defines and describes the member attributes and member functions.
object- instance of a class - acts as its variable . It has its own state, behavior, and identity.
software objects maintains state in variables and implements behavior with methods
Software objects are modeled after real-world objects such as a pen, keyboard, chair, table, computer, Book etc.
Just as Real-world objects have its state and behavior; Software objects too have state and behavior.
A software object maintains its state in variables and implements its behavior with methods.
What is Encapsulation?
Encapsulation is like your bag in which you can keep your pen, book etc.
Encapsulation means hiding the internal details of an object
Encapsulation is a technique used to protect the information in an object from the other object
What is Polymorphism?
Like a man at a same time is a father, a husband, a employee. So, a same person posses different behavior in different situations. This is called polymorphism.
What is Inheritance?
Constructor
initializes the state of an object
invoked at the time of object creation
Instance method with usually the same name as class
A constructor is a method used to initialize the state of an object, and it gets invoked at the time of object creation.
A constructor is an instance method that usually has the same name as the class, and can be used to set the values of the members of an object
Destructor
Automatically called at the end of lifetime of the object
frees up the acquired resources
A destructor is a method which is automatically called when the lifetime of an object ends. The purpose of the destructor is to free the resources that the object may have acquired during its lifetime
Copy Constructor
-creates an object by initializing it with another object of same class
-it creates new object is exact copy of the existing one
A parameterized constructor that contains a parameter of same class type is called as copy constructor
main purpose of copy constructor is to initialize new instance to the values of an existing instance
eg
public class EmloyeeConstr
{
public EmloyeeConstr() //constructor
{
}
public EmployeeConstr(string name) //parametrized constructor
{
}
public class EmployeeConstr(EmployeeCnstr emp) //copy constructor
{
}
}
Comments
Post a Comment