Monday 22 January 2018

OOPS Concepts In C++

   What is OOPS?
   OOPS stands for Object Oriented Programming system
   In  OOPS the programs are considered as a collection of objects. 
   Each object is nothing but an instance of a class.

  Write basic concepts of OOPS?

   Following are the concepts of OOPS and are as follows:
   Abstraction.
   Encapsulation.
   Inheritance.
   Polymorphism.

  What is a class?

A class is a collection of objects.
A class is a collection of data membersmember functions, properties and object.
It is the blueprint that describes the details of an object.

Declaration of class
Class classname
{
//variables or data members
//properties
//methods or member functions
};

Where class is a keyword and class name is userdefined that means you can give any name to class

Example:
Class A
{
//

};

    What is an object?

Object is an instance of a class, and it has its own state, behavior and identity.
Example: if computer is a class then keyboard, mouse are the objects.

Declaration of object:

classname referencename;

Example:

 A a1; //A is class name, a1 is reference name

 a1.show ();

 // call or invoke the member functions to execute the program (a1 is the reference   name  and show () is member function)

a1.x=5;
// used to initialize the variable (a1 is the reference name and x is the data member )

Uses of object:

It is used to call or invoke the member functions to execute the program.
It is used to initialize the data members.

What is Encapsulation?

Encapsulation means wrapping or hiding of data in a class and controlling its access.
Encapsulation is implemented using private, package-private and protected access modifier.

For Example: Mobiles and owners...
all the functions of mobiles are encapsulated with the owners.
No one else can access it.

Advantages: Security

    What is Polymorphism?

Polymorphism is nothing but assigning behavior or value in a child class to something that was already declared in the parent class.

Polymorphism takes more than one form.
 
What is Inheritance?

Inheritance is a concept where one class shares the structure and behavior defined in another class.

If inheritance applied on one class is called Single Inheritance, and if it depends on multiple classes, then it is called multiple Inheritance.

Advantages: reusability, extensibility.

What is abstraction in java?

Abstraction means providing important or necessary features without giving internal or background details.
For Example: - When user is using Mobile application he doesn't know internal working of all functions like calling, send Sms but he can call or send sms without knowing internal details. His main aim is using the mobile phone not to know about internal structure

What are the advantages of OOPS concepts?
    Simplicity: OOPS programming objects model real world objects, so the complexity is reduced (you know that object is real time entity so it’s very simple to use).

    Extensibility: Adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones (Inheritance).

    Security: it supports encapsulation so security level is very high

    Reusability: Objects can be reused in different programs using inheritance


No comments:

Post a Comment

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...