Skip to main content

Object Oriented Programming (OOP)

Object Oriented Programming:

Object Oriented Programming (OOP) is a programming concept which used in the modern programming world. Languages like Java, C++,  and Python support Object Oriented Programming (OOP). It works on the principle that objects are the most important part of a program. In OOP we think in terms of objects and every object has its attributes (properties) and a state (behavior/functions).
Object Oriented Programming (OOP) is a technique of system modeling and its main purpose is to understand the product before developing it and manipulating these objects to achieve a specific task.

 

Pillars of Object Oriented Language (OOP):

There are four basic principles of Object Oriented Language (OOP).
  • Inheritance
  • Polymorphism
  • Data Encapsulation
  • Abstraction



WHY is Object Oriented Language (OOP) NEEDED?

Problems with Procedural Languages:

  • Functions have unrestricted access to global data
  • Unrelated Functions and data.

Before Object Oriented Programming programs were viewed as procedures that accepted data and produced an output. There was little emphasis given to the data that went into those programs.

 

Advantages of Object Oriented Language (OOP):

  • Data Secure: data is hidden from outside world.
  • Code Reusability: Reusability is one of its main features.
  • Flexibility: code can be easily changed.

Difference Between Procedure and Object Oriented Programming Language:

Procedure Oriented Programming
Object Oriented Programming
 Programs are divided into small parts called functions.Program is divided into parts called objects.
Functions are given more importance than data. Importance is given to the data rather than procedures or functions because it works as a real world.
Data can move freely from function to function in the system. Objects can interact with each other through member functions to achieve a specific task.
To add new data and function is not so easy. Most function uses Global data for sharing that can be accessed freely from function to function in the system. OOP provides an easy way to add new data and function. In OOP, we can keep data public or private to control the access of data.
Procedure language does not have any way to hide data. OOP provides Data Hiding so provides more security.
 Examples are C, VB, FORTRAN, Pascal.Examples are C++, JAVA, VB.NET, C#.NET.

Class:

Class is a blueprint of an object. A class can be anything that can be unique on any base. In Object Oriented world main goal is to identify the classes and make them interact with each other to achieve a specific task.

What is a Class?

Basically class is a collection of data and behavior (code) under one roof. Class name is usually a noun and function are verbs?

Comments

Popular posts from this blog

Data Types

DATA TYPES in C/C++: Since C and C++ are strongly type languages, therefore every thing must be defined. Variables are classified according to their data type, which determines the kind of information that may be stored in them. Data Types Description C-Keyword Format Specifier integer Integers are whole numbers that can have both positive and negative values but no decimal values.   int   %d or %i Float Floating type variables can hold real numbers precision of 6 digits. float %f Double can hold real numbers with the precision of 14 digits. double %f Character data type allows a variable to store only one character. char %c Implementation in C: #include<stdio.h> int main() { printf(“%d n”,18); //this will print integer printf(“%fn”,32.56); //this will print decimal number printf(“%d %d %dn”,32,56,89); // %d is a place holder for integer and it provide place for one integer printf(“%ld...

Tic-Tac-Toe Implementation in Cpp (C++) Step by Step

Conditional Statement

Conditional Statement: A conditional statement is an if-then statement which means that if some statement is true then it follows the if-block of code and if the condition is false then it follows the else-block of code. In the programming world, there are two types of conditional statement namely if-else and switch. if-else Statement: Syntax: if (condition 1) { } else if (condition 2) { } else { }   Implementation of If-else statement in C: Q: Write a program to find the greatest of three numbers. #include<stdio.h> int main() { int a,b,c; printf(“Please Enter First Number “); scanf(“%d”,&a); printf(“Please Enter Second Number “); scanf(“%d”,&b); printf(“Please Enter Third Number “); scanf(“%d”,&c); if (a>b && a>c) { printf(“The Greatest Number is %d”,a); } else if (b>c) { printf(“The Greatest Number is %d”,b); } else { pr...