Spotle.ai Study Material
Spotle.ai/Learn
Introduction To
OOPS
- Class and Object
Spotle.ai Study Material
Spotle.ai/Learn
Mousum Dutta
Chief Data Scientist, Spotle.ai
IIT Kharagpur
Instructors
Sk Mamtajuddin
Head of Technology,
Spotle.ai
2
Spotle.ai Study Material
Spotle.ai/Learn
In Computer
Science,
OOPS = Object
Oriented
Programming
In a parallel world, it is also part of the
Britney Spears song.
What Is OOPS?
OOPS! 

I did it again
OOPS! 

I did it again
OOPS! 

I did it again
Spotle.ai Study Material
Spotle.ai/Learn
Why OOPS?
OOPS was
introduced to
overcome
limitations in
procedural
languages (C,
COBOL etc) such
as reusability and
maintainability.
4
Spotle.ai Study Material
Spotle.ai/Learn
Java, C++, Python,
Ruby are examples of
Object Oriented
Programming (OOP)
Languages .
OOP and POP - Examples
The OOP Family The POP Family
C, COBOL, FORTRAN
Are Procedural
Oriented
Programming (POP)
Languages.
5
Spotle.ai Study Material
Spotle.ai/Learn
OOPS – The Central Idea
The world can be
described as a
collection of objects
that interact.
6
Spotle.ai Study Material
Spotle.ai/Learn
What Is An Object?
An object is a self-
contained component with
methods and properties
or attributes.
Timmy is an object with
properties such as breed,
colour and methods such
as bark. His owner Jimmy
has properties like height,
annual income, marital
status etc and methods
such as earn_a_living.
7
Spotle.ai Study Material
Spotle.ai/Learn
An object has
attributes defining its
characteristics and
methods defining
what it can do.
Objects – Illustrating With The Car Example
Img Src: Wikipedia
8
Spotle.ai Study Material
Spotle.ai/Learn
An object is of a
particular type. For
example: The Hitch
Hikers Guide To The
Galaxy is a type of book.
The word ‘class’ is used
to refer to the category or
type of objects. An object
is an instance of a class.
What Is A Class?
9
Spotle.ai Study Material
Spotle.ai/Learn
Cricketer is a
class. Sachin
Tendulkar is
an object – an
instance of
class
cricketer. He
has attributes
like total runs
and methods
like score
runs.
Examples
10
Spotle.ai Study Material
Spotle.ai/Learn
Each object
from a
particular
class is
called an
instance of
the class.
The process
of creating
an object is
called
instantiation.
Instantiating A Class
11
Spotle.ai Study Material
Spotle.ai/Learn
Class Object
A class is a data type.
It defines a template
or blueprint for an
object.
Object is an instance
of a class.
Does not occupy
memory location.
Occupies memory
location at run time.
Does not really exist
as it only provides a
template. You can
therefore not perform
operations on a class.
You perform
operations on objects
Class Vs Object
Think of the class like the Mercedes blue-print and the
object like your brand new Mercedes.
12

Introduction To OOPS - Class And Object

  • 1.
  • 2.
    Spotle.ai Study Material Spotle.ai/Learn MousumDutta Chief Data Scientist, Spotle.ai IIT Kharagpur Instructors Sk Mamtajuddin Head of Technology, Spotle.ai 2
  • 3.
    Spotle.ai Study Material Spotle.ai/Learn InComputer Science, OOPS = Object Oriented Programming In a parallel world, it is also part of the Britney Spears song. What Is OOPS? OOPS! I did it again OOPS! I did it again OOPS! I did it again
  • 4.
    Spotle.ai Study Material Spotle.ai/Learn WhyOOPS? OOPS was introduced to overcome limitations in procedural languages (C, COBOL etc) such as reusability and maintainability. 4
  • 5.
    Spotle.ai Study Material Spotle.ai/Learn Java,C++, Python, Ruby are examples of Object Oriented Programming (OOP) Languages . OOP and POP - Examples The OOP Family The POP Family C, COBOL, FORTRAN Are Procedural Oriented Programming (POP) Languages. 5
  • 6.
    Spotle.ai Study Material Spotle.ai/Learn OOPS– The Central Idea The world can be described as a collection of objects that interact. 6
  • 7.
    Spotle.ai Study Material Spotle.ai/Learn WhatIs An Object? An object is a self- contained component with methods and properties or attributes. Timmy is an object with properties such as breed, colour and methods such as bark. His owner Jimmy has properties like height, annual income, marital status etc and methods such as earn_a_living. 7
  • 8.
    Spotle.ai Study Material Spotle.ai/Learn Anobject has attributes defining its characteristics and methods defining what it can do. Objects – Illustrating With The Car Example Img Src: Wikipedia 8
  • 9.
    Spotle.ai Study Material Spotle.ai/Learn Anobject is of a particular type. For example: The Hitch Hikers Guide To The Galaxy is a type of book. The word ‘class’ is used to refer to the category or type of objects. An object is an instance of a class. What Is A Class? 9
  • 10.
    Spotle.ai Study Material Spotle.ai/Learn Cricketeris a class. Sachin Tendulkar is an object – an instance of class cricketer. He has attributes like total runs and methods like score runs. Examples 10
  • 11.
    Spotle.ai Study Material Spotle.ai/Learn Eachobject from a particular class is called an instance of the class. The process of creating an object is called instantiation. Instantiating A Class 11
  • 12.
    Spotle.ai Study Material Spotle.ai/Learn ClassObject A class is a data type. It defines a template or blueprint for an object. Object is an instance of a class. Does not occupy memory location. Occupies memory location at run time. Does not really exist as it only provides a template. You can therefore not perform operations on a class. You perform operations on objects Class Vs Object Think of the class like the Mercedes blue-print and the object like your brand new Mercedes. 12