Object Oriented Programming Masters of Computer Science

Concept of Object Oriented PRogramming

Concept of Object Oriented PRogramming

Introduction to Object-Oriented Programming

In simple terms, an application is collection of objects which communicates each other.

Real world entities like inheritance, polymorphism are aimed to implemented in object oriented programming.

Almost every programmer have used OOP in their life. OOP is considered as the standard way to write a code.

What is the main aim of Object Oriented Programming?

It aims to bind data and function together that operate on them. It is so because no other parts of the code can access this data. Only that function can access this data.

Object Oriented Programming depends on class and objects. OOP helps to structure program into reusable pieces of blocks and make it simple.

Some commonly used and most popular Object Oriented Programming lanugae includes

  • C++
  • Java
  • Python

Object-Oriented Programming: Introduction

  • OOP i.e Object Oriented Programming is approach based ob objects and class
  • OOP lets programmer to create components that can be reused with maintaining all security

Class

  • Class is user defined data type
  • Blueprint for creating object
  • It is needed to represent data
  • Its logical representation of data and it doesn’t take any memory.
  • To create class, use “class” keyword followed by name of the ckass
  • E.g

Class Test

{

}

In Java, to create a class wih name Test with variable x

Public class Test{

Int x=30;

}

In Java, name of class always starts with uppercase letter

  • For an example, consider class of bikes. Bikes have different brands and names but they share some common properties. Examples, they have two wheels, limitations of the speed, mileage etc.

Here,

Bike is class and wheels, speed limit, mileage etc are properties of the class.

Class is blueprint of an object that contains variables for storing data

Object

  • Object is instance of a class
  • It represents real life entities
  • Class doesn’t take any memory. So to represent data, variables needs to be created for a class which is object.
  • Syntax to create object of class Test
    • Test myObj=new Test();
  • No memory is allocated when class is created. But when object is create, i.e when it is instantiated, there is memory allocation

Difference between Class and Object

ClassObject
Blueperint from which object are createdIt’s instance of a class
Group of similar objectsReal world entity like computer, table, mouse etc
Logical entityPhysical entity
Declared using class keyword. E.g class Employee{}Created through keyword new e.g Employee e1=new Employee();
Declared onceCreated as per requirement
e.g Humane.g Man, Woman
About Author

ICT Byte