0% found this document useful (0 votes)
22 views16 pages

1_OOPconcepts (1)

The document provides an overview of object-oriented programming (OOP), emphasizing its focus on data or objects rather than functions. Key concepts discussed include objects, classes, abstraction, encapsulation, inheritance, and polymorphism, which are fundamental to OOP. Additionally, it includes activities for applying these concepts in practical programming scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views16 pages

1_OOPconcepts (1)

The document provides an overview of object-oriented programming (OOP), emphasizing its focus on data or objects rather than functions. Key concepts discussed include objects, classes, abstraction, encapsulation, inheritance, and polymorphism, which are fundamental to OOP. Additionally, it includes activities for applying these concepts in practical programming scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 16

Lecture 2 and 3: Object oriented

Concepts
19CSE201-Advanced Programming
What is object oriented
programming?
 Object-oriented programming (OOP) is a
programming language model in which programs
are organized around data, or objects, rather than
functions and logic.

 Anobject can be defined as a data field that has


unique attributes and behaviour.
Object Oriented Concepts
 Object
 Class
 Abstraction
 Encapsulation
 Inheritance
 Polymorphism
Object
 All real world entity that have state and behaviors is
known as object
 Object can also be defined as instances of class.

Example1

Example2
Class
 A class is a user defined blueprint or prototype
 Class is a group of similar objects.
 The definitions of the states and behaviors of an object are
organized into a class.
class Thus, a class is the generic definition
for a set of similar objects.
 One or more objects described by the class are instantiated
at runtime.
 The objects are called instances of the class.
Class (Contd..)
Abstraction
 An abstraction is an act of representing essential features
without including background details.
 Data Abstraction may also be defined as the process of
identifying only the required characteristics of an object and
ignoring the irrelevant details.
What is encapsulation ?
 Binding code and data together into a single unit .
 Other way to think about encapsulation is, it is a protective
shield that prevents the data from being accessed by the
code outside this shield.
 Data and code is hidden from other classes.
Inheritance
 Inheritance is an OOPS concept in which one object
acquires the properties and behaviours of the parent object.
 It’s creating a parent-child relationship between two
classes
Polymorphism
 Polymorphism refers to the ability of a variable, object or
function to take on multiple forms.
OOP Vs. POP
Activity
Objects in Real World
1. You’ve been hired by your school to create a program that keeps track of
“students at your school and the courses they are taking”. Name 2 classes
that you would create in your program. Name 2 attributes (data kept in
instance variables) for each class.
2. Think about what data you need to keep track of for students and courses and
what methods you need. Note that the instance variables in the Person class
could also work for a Student class!
3.
Say you wanted to make a computer game from a board game that you are
playing. Think about what objects are in the game.
For example, here is the description for Monopoly (trademark Hasbro games):
“Buy, sell, dream and scheme your way to riches. Players buy, sell and trade to
win. Build houses and hotels on your properties and bankrupt your opponents to
win it all. Chance and Community Chest cards can change everything.”

What classes would you need to create a computer version of this game?
(Remember to look for the nouns). Take one of the classes you listed, and try to
come up with 2 pieces of data in that class that will be the instance variables

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy