SlideShare a Scribd company logo
Object Oriented Programming
Chapter 1: Introduction to OOP
Prepared by: Mahmoud Rafeek Alfarra
2016
Outlines
◉ What is Object-Oriented Programming ?
◉ Procedural vs. Object-Oriented Programming
◉ OO Programming Concepts
◉ Concept of Objects and classes
◉ UML Class Diagram
◉ Visibility Modifiers and Accessor Methods
◉ Full Example
Lecture
Let’s think on concept of Class and Object
2
(‫ى‬َ‫م‬ْ‫ع‬َ‫أ‬ ِ‫ة‬َ‫م‬‫ا‬َ‫ي‬ِ‫ق‬ْ‫ل‬‫ا‬ َ‫م‬ْ‫و‬َ‫ي‬ ُ‫ه‬ُ‫ر‬ُ‫ش‬ْ‫ح‬َ‫ن‬َ‫و‬ ‫ًا‬‫ك‬‫ن‬َ‫ض‬ ً‫ة‬َ‫ش‬‫ي‬ِ‫ع‬َ‫م‬ ُ‫ه‬َ‫ل‬ ََّ‫ن‬ِ‫إ‬َ‫ف‬ ‫ي‬ِ‫ر‬ْ‫ك‬ِ‫ذ‬ ْ‫ن‬َ‫ع‬ َ‫ض‬َ‫ر‬ْ‫ع‬َ‫أ‬ ْ‫ن‬َ‫م‬َ‫و‬)
‫ه‬‫ط‬ ‫ة‬‫ر‬‫و‬‫س‬
Classes & Objects !
o Classes are constructs that define objects of the
same type.
o “Class” refers to a blueprint. It defines the variables
and methods the objects support.
What is Class ?
Class Name: Circle
Data Fields:
radius is _______
Methods:
getArea
A class template
o “Object” is an instance of a class.
o Each object has a class which defines its data and behavior.
o An object has both a state and behavior.
o The state defines the object, and the behavior defines what the
object does.
What is Object?
Class Name: Circle
Data Fields:
radius is _______
Methods:
getArea
Circle Object 1
Data Fields:
radius is 10
Circle Object 2
Data Fields:
radius is 25
Circle Object 3
Data Fields:
radius is 125
A class template
Three objects of
the Circle class
Class & Object
Class & Object
Class & Object
Class & Object
Thinking to build class …
Any Thing
Attributes
Behavior
Each one is presented as
a variable in the Class
Each one is presented as
a method in the Class
A new class will be considered
as a new data type, so you can
declare a variables (Objects) of
them and then you can set and
get data to its properties.
o A Java class uses variables to define data fields and methods to
define behaviors.
o Additionally, a class provides a special type of methods, known as
constructors, which are invoked to construct objects from the
class.
Thinking to build class …
Thinking to build class …
class Circle {
/** The radius of this circle */
double radius = 1.0;
/** Construct a circle object */
Circle() {
}
/** Construct a circle object */
Circle(double newRadius) {
radius = newRadius;
}
/** Return the area of this circle */
double getArea() {
return radius * radius * 3.14159;
}
}
Data field
Method
Constructors
How to build my class?
Access_modifiers class class_name {
// variables = attributes
Access_modifiers class_name(par1, par2, …) {
}
// behavior = methods
}
Always, the class has
a method called constructor
which gives initial values
to the attributes of class
Is a reserved word The identifier of class
Must be as any variable
o A class can have three kinds of members:
 fields: data variables which determine the status of the class
or an object
 methods: executable code of the class built from
statements. It allows us to manipulate/change the status of
an object or access the value of the data member
 nested classes and nested interfaces
Class Members
How to insatiate object?
class_name object_name = new class_name (arg1, arg2, …);
The name of class, which
you want to insatiate an
object of it.
Reserved word
Values based on the
parameters of constructor
The name
of object
UML Class Diagram
Circle
radius: double
Circle()
Circle(newRadius: double)
getArea(): double
circle1: Circle
radius = 1.0
Class name
Data fields
Constructors and
methods
circle2: Circle
radius = 25
circle3: Circle
radius = 125
UML Class Diagram
UML notation
for objects
Practices
Group 1
Compare between
constructor and
methods in class.
Group 2
Detect 3 classes from
your bedroom and 2
objects.
Group 3
Diffrenciate between
Class & Object
Group 4
Draw the UML Class
Diagram of Course
class.
Group 5
Draw the UML Class
Diagram of Student
class.
Group 6
Thinking to build Circle
class.
THANKS!
Any questions?
You can find me at:
Fb/mahmoudRAlfarra
Staff.cst.ps/mfarra
Youtube.com/mralfarra1
@mralfarra

More Related Content

What's hot (20)

PDF
CLASS & OBJECT IN JAVA
Riaj Uddin Mahi
 
PPT
Object and class
mohit tripathi
 
PPTX
Class or Object
Rahul Bathri
 
PPT
Lect 1-class and object
Fajar Baskoro
 
PPT
Class and object in C++
rprajat007
 
PDF
ITFT-Classes and object in java
Atul Sehdev
 
PDF
Lect 1-java object-classes
Fajar Baskoro
 
PPTX
Java class,object,method introduction
Sohanur63
 
PPT
Class and object in c++
NainaKhan28
 
PDF
Class and Objects in Java
Spotle.ai
 
PPT
11 Using classes and objects
maznabili
 
PPTX
Data members and member functions
Marlom46
 
PPTX
Static keyword ppt
Vinod Kumar
 
PPTX
[OOP - Lec 09,10,11] Class Members & their Accessing
Muhammad Hammad Waseem
 
PPTX
Classes and objects
rajveer_Pannu
 
PDF
Classes and objects in java
Muthukumaran Subramanian
 
PPTX
C++ And Object in lecture3
UniSoftCorner Pvt Ltd India.
 
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
PPT
Data members and member functions
Harsh Patel
 
CLASS & OBJECT IN JAVA
Riaj Uddin Mahi
 
Object and class
mohit tripathi
 
Class or Object
Rahul Bathri
 
Lect 1-class and object
Fajar Baskoro
 
Class and object in C++
rprajat007
 
ITFT-Classes and object in java
Atul Sehdev
 
Lect 1-java object-classes
Fajar Baskoro
 
Java class,object,method introduction
Sohanur63
 
Class and object in c++
NainaKhan28
 
Class and Objects in Java
Spotle.ai
 
11 Using classes and objects
maznabili
 
Data members and member functions
Marlom46
 
Static keyword ppt
Vinod Kumar
 
[OOP - Lec 09,10,11] Class Members & their Accessing
Muhammad Hammad Waseem
 
Classes and objects
rajveer_Pannu
 
Classes and objects in java
Muthukumaran Subramanian
 
C++ And Object in lecture3
UniSoftCorner Pvt Ltd India.
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Data members and member functions
Harsh Patel
 

Similar to Object Oriented Programming_Lecture 2 (20)

PPTX
IPP-M5-C1-Classes _ Objects python -S2.pptx
DhavalaShreeBJain
 
PPT
packages and interfaces
madhavi patil
 
PPT
Java sem i
priyankabarhate1
 
PPT
classandobjectunit2-150824133722-lva1-app6891.ppt
manomkpsg
 
PPTX
UNIT - IIInew.pptx
akila m
 
PPTX
OOSD1-unit1_1_16_09.pptx
ShobhitSrivastava15887
 
PPT
Java Presentation.ppt
Morgan309846
 
PDF
Class in Java, Declaring a Class, Declaring a Member in a Class.pdf
nandiaditi2010
 
PPT
Lecture 2 classes i
the_wumberlog
 
PPT
Module 3 Class and Object.ppt
RanjithKumar742256
 
PPTX
Class and Object.pptx
Hailsh
 
PPTX
03 object-classes-pbl-4-slots
mha4
 
PPTX
03 object-classes-pbl-4-slots
mha4
 
PPTX
Oops
Jaya Kumari
 
PDF
Python - object oriented
Learnbay Datascience
 
PPT
L5 classes, objects, nested and inner class
teach4uin
 
PPTX
classes-objects in oops java-201023154255.pptx
janetvidyaanancys
 
PPT
06slide
DEEPIKA KAMBOJ
 
PPTX
Object Oriented Programming Class and Objects
rubini8582
 
PPT
Core Java unit no. 1 object and class ppt
Mochi263119
 
IPP-M5-C1-Classes _ Objects python -S2.pptx
DhavalaShreeBJain
 
packages and interfaces
madhavi patil
 
Java sem i
priyankabarhate1
 
classandobjectunit2-150824133722-lva1-app6891.ppt
manomkpsg
 
UNIT - IIInew.pptx
akila m
 
OOSD1-unit1_1_16_09.pptx
ShobhitSrivastava15887
 
Java Presentation.ppt
Morgan309846
 
Class in Java, Declaring a Class, Declaring a Member in a Class.pdf
nandiaditi2010
 
Lecture 2 classes i
the_wumberlog
 
Module 3 Class and Object.ppt
RanjithKumar742256
 
Class and Object.pptx
Hailsh
 
03 object-classes-pbl-4-slots
mha4
 
03 object-classes-pbl-4-slots
mha4
 
Python - object oriented
Learnbay Datascience
 
L5 classes, objects, nested and inner class
teach4uin
 
classes-objects in oops java-201023154255.pptx
janetvidyaanancys
 
Object Oriented Programming Class and Objects
rubini8582
 
Core Java unit no. 1 object and class ppt
Mochi263119
 
Ad

More from Mahmoud Alfarra (20)

PPT
Computer Programming, Loops using Java - part 2
Mahmoud Alfarra
 
PPT
Computer Programming, Loops using Java
Mahmoud Alfarra
 
PPT
Chapter 10: hashing data structure
Mahmoud Alfarra
 
PPT
Chapter9 graph data structure
Mahmoud Alfarra
 
PPT
Chapter 8: tree data structure
Mahmoud Alfarra
 
PPT
Chapter 7: Queue data structure
Mahmoud Alfarra
 
PPT
Chapter 6: stack data structure
Mahmoud Alfarra
 
PPT
Chapter 5: linked list data structure
Mahmoud Alfarra
 
PPT
Chapter 4: basic search algorithms data structure
Mahmoud Alfarra
 
PPT
Chapter 3: basic sorting algorithms data structure
Mahmoud Alfarra
 
PPT
Chapter 2: array and array list data structure
Mahmoud Alfarra
 
PPT
Chapter1 intro toprincipleofc#_datastructure_b_cs
Mahmoud Alfarra
 
PPT
Chapter 0: introduction to data structure
Mahmoud Alfarra
 
PPTX
3 classification
Mahmoud Alfarra
 
PPT
8 programming-using-java decision-making practices 20102011
Mahmoud Alfarra
 
PPT
7 programming-using-java decision-making220102011
Mahmoud Alfarra
 
PPT
6 programming-using-java decision-making20102011-
Mahmoud Alfarra
 
PPT
5 programming-using-java intro-tooop20102011
Mahmoud Alfarra
 
PPT
4 programming-using-java intro-tojava20102011
Mahmoud Alfarra
 
PPT
3 programming-using-java introduction-to computer
Mahmoud Alfarra
 
Computer Programming, Loops using Java - part 2
Mahmoud Alfarra
 
Computer Programming, Loops using Java
Mahmoud Alfarra
 
Chapter 10: hashing data structure
Mahmoud Alfarra
 
Chapter9 graph data structure
Mahmoud Alfarra
 
Chapter 8: tree data structure
Mahmoud Alfarra
 
Chapter 7: Queue data structure
Mahmoud Alfarra
 
Chapter 6: stack data structure
Mahmoud Alfarra
 
Chapter 5: linked list data structure
Mahmoud Alfarra
 
Chapter 4: basic search algorithms data structure
Mahmoud Alfarra
 
Chapter 3: basic sorting algorithms data structure
Mahmoud Alfarra
 
Chapter 2: array and array list data structure
Mahmoud Alfarra
 
Chapter1 intro toprincipleofc#_datastructure_b_cs
Mahmoud Alfarra
 
Chapter 0: introduction to data structure
Mahmoud Alfarra
 
3 classification
Mahmoud Alfarra
 
8 programming-using-java decision-making practices 20102011
Mahmoud Alfarra
 
7 programming-using-java decision-making220102011
Mahmoud Alfarra
 
6 programming-using-java decision-making20102011-
Mahmoud Alfarra
 
5 programming-using-java intro-tooop20102011
Mahmoud Alfarra
 
4 programming-using-java intro-tojava20102011
Mahmoud Alfarra
 
3 programming-using-java introduction-to computer
Mahmoud Alfarra
 
Ad

Recently uploaded (20)

PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 

Object Oriented Programming_Lecture 2

  • 1. Object Oriented Programming Chapter 1: Introduction to OOP Prepared by: Mahmoud Rafeek Alfarra 2016
  • 2. Outlines ◉ What is Object-Oriented Programming ? ◉ Procedural vs. Object-Oriented Programming ◉ OO Programming Concepts ◉ Concept of Objects and classes ◉ UML Class Diagram ◉ Visibility Modifiers and Accessor Methods ◉ Full Example
  • 3. Lecture Let’s think on concept of Class and Object 2
  • 4. (‫ى‬َ‫م‬ْ‫ع‬َ‫أ‬ ِ‫ة‬َ‫م‬‫ا‬َ‫ي‬ِ‫ق‬ْ‫ل‬‫ا‬ َ‫م‬ْ‫و‬َ‫ي‬ ُ‫ه‬ُ‫ر‬ُ‫ش‬ْ‫ح‬َ‫ن‬َ‫و‬ ‫ًا‬‫ك‬‫ن‬َ‫ض‬ ً‫ة‬َ‫ش‬‫ي‬ِ‫ع‬َ‫م‬ ُ‫ه‬َ‫ل‬ ََّ‫ن‬ِ‫إ‬َ‫ف‬ ‫ي‬ِ‫ر‬ْ‫ك‬ِ‫ذ‬ ْ‫ن‬َ‫ع‬ َ‫ض‬َ‫ر‬ْ‫ع‬َ‫أ‬ ْ‫ن‬َ‫م‬َ‫و‬) ‫ه‬‫ط‬ ‫ة‬‫ر‬‫و‬‫س‬
  • 6. o Classes are constructs that define objects of the same type. o “Class” refers to a blueprint. It defines the variables and methods the objects support. What is Class ? Class Name: Circle Data Fields: radius is _______ Methods: getArea A class template
  • 7. o “Object” is an instance of a class. o Each object has a class which defines its data and behavior. o An object has both a state and behavior. o The state defines the object, and the behavior defines what the object does. What is Object? Class Name: Circle Data Fields: radius is _______ Methods: getArea Circle Object 1 Data Fields: radius is 10 Circle Object 2 Data Fields: radius is 25 Circle Object 3 Data Fields: radius is 125 A class template Three objects of the Circle class
  • 12. Thinking to build class … Any Thing Attributes Behavior Each one is presented as a variable in the Class Each one is presented as a method in the Class A new class will be considered as a new data type, so you can declare a variables (Objects) of them and then you can set and get data to its properties.
  • 13. o A Java class uses variables to define data fields and methods to define behaviors. o Additionally, a class provides a special type of methods, known as constructors, which are invoked to construct objects from the class. Thinking to build class …
  • 14. Thinking to build class … class Circle { /** The radius of this circle */ double radius = 1.0; /** Construct a circle object */ Circle() { } /** Construct a circle object */ Circle(double newRadius) { radius = newRadius; } /** Return the area of this circle */ double getArea() { return radius * radius * 3.14159; } } Data field Method Constructors
  • 15. How to build my class? Access_modifiers class class_name { // variables = attributes Access_modifiers class_name(par1, par2, …) { } // behavior = methods } Always, the class has a method called constructor which gives initial values to the attributes of class Is a reserved word The identifier of class Must be as any variable
  • 16. o A class can have three kinds of members:  fields: data variables which determine the status of the class or an object  methods: executable code of the class built from statements. It allows us to manipulate/change the status of an object or access the value of the data member  nested classes and nested interfaces Class Members
  • 17. How to insatiate object? class_name object_name = new class_name (arg1, arg2, …); The name of class, which you want to insatiate an object of it. Reserved word Values based on the parameters of constructor The name of object
  • 18. UML Class Diagram Circle radius: double Circle() Circle(newRadius: double) getArea(): double circle1: Circle radius = 1.0 Class name Data fields Constructors and methods circle2: Circle radius = 25 circle3: Circle radius = 125 UML Class Diagram UML notation for objects
  • 19. Practices Group 1 Compare between constructor and methods in class. Group 2 Detect 3 classes from your bedroom and 2 objects. Group 3 Diffrenciate between Class & Object Group 4 Draw the UML Class Diagram of Course class. Group 5 Draw the UML Class Diagram of Student class. Group 6 Thinking to build Circle class.
  • 20. THANKS! Any questions? You can find me at: Fb/mahmoudRAlfarra Staff.cst.ps/mfarra Youtube.com/mralfarra1 @mralfarra