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

PPTX
‫Object Oriented Programming_Lecture 3
PPTX
Chapter2 array of objects
PPT
البرمجة الهدفية بلغة جافا - مفاهيم أساسية
PPTX
‫‫Chapter4 Polymorphism
PPT
البرمجة الهدفية بلغة جافا - تعدد الأشكال
PPTX
‫Chapter3 inheritance
PPT
البرمجة الهدفية بلغة جافا - مصفوفة الكائنات
PPT
البرمجة الهدفية بلغة جافا - الوراثة
‫Object Oriented Programming_Lecture 3
Chapter2 array of objects
البرمجة الهدفية بلغة جافا - مفاهيم أساسية
‫‫Chapter4 Polymorphism
البرمجة الهدفية بلغة جافا - تعدد الأشكال
‫Chapter3 inheritance
البرمجة الهدفية بلغة جافا - مصفوفة الكائنات
البرمجة الهدفية بلغة جافا - الوراثة

What's hot (20)

PDF
CLASS & OBJECT IN JAVA
PPT
Object and class
PPTX
Class or Object
PPT
Lect 1-class and object
PPT
Class and object in C++
PDF
ITFT-Classes and object in java
PDF
Lect 1-java object-classes
PPTX
Java class,object,method introduction
PPT
Class and object in c++
PDF
Class and Objects in Java
PPT
11 Using classes and objects
PPTX
Data members and member functions
PPTX
Static keyword ppt
PPTX
[OOP - Lec 09,10,11] Class Members & their Accessing
PPTX
Classes and objects
PDF
Classes and objects in java
PPTX
C++ And Object in lecture3
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPT
Data members and member functions
CLASS & OBJECT IN JAVA
Object and class
Class or Object
Lect 1-class and object
Class and object in C++
ITFT-Classes and object in java
Lect 1-java object-classes
Java class,object,method introduction
Class and object in c++
Class and Objects in Java
11 Using classes and objects
Data members and member functions
Static keyword ppt
[OOP - Lec 09,10,11] Class Members & their Accessing
Classes and objects
Classes and objects in java
C++ And Object in lecture3
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Data members and member functions
Ad

Similar to Object Oriented Programming_Lecture 2 (20)

PPT
Object & classes
PPT
Software Engineering Lec5 oop-uml-i
PPTX
Oop objects_classes
PDF
Lecture-03 _Java Classes_from FAST-NUCES
PPTX
C++ classes
PPTX
C___oop_to_Advanced zarif.pptx
PPT
UNIT I (1).ppt
PPT
UNIT I (1).ppt
PPT
Unit i
PPT
oops-1
PDF
L1-Introduction to OOPs concepts.pdf
PPT
Java Presentation.ppt
PPTX
OOP Presentation.pptx
PPTX
OOP Presentation.pptx
PPTX
CHAP1 - OBJECT ORIENTED PROGRAMMING.pptx
PPT
Oops concept in c#
PPTX
Concepts of oops
PPTX
Unit4 desiging classes
PPTX
Unit4 desiging classes
PPTX
ITSE_10(UML,OO).pptx
Object & classes
Software Engineering Lec5 oop-uml-i
Oop objects_classes
Lecture-03 _Java Classes_from FAST-NUCES
C++ classes
C___oop_to_Advanced zarif.pptx
UNIT I (1).ppt
UNIT I (1).ppt
Unit i
oops-1
L1-Introduction to OOPs concepts.pdf
Java Presentation.ppt
OOP Presentation.pptx
OOP Presentation.pptx
CHAP1 - OBJECT ORIENTED PROGRAMMING.pptx
Oops concept in c#
Concepts of oops
Unit4 desiging classes
Unit4 desiging classes
ITSE_10(UML,OO).pptx
Ad

More from Mahmoud Alfarra (20)

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

Recently uploaded (20)

PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
Software Engineering BSC DS UNIT 1 .pptx
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PPTX
Congenital Hypothyroidism pptx
PDF
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
PPTX
Onica Farming 24rsclub profitable farm business
PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
PDF
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Types of Literary Text: Poetry and Prose
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
Open Quiz Monsoon Mind Game Prelims.pptx
Software Engineering BSC DS UNIT 1 .pptx
Module 3: Health Systems Tutorial Slides S2 2025
Congenital Hypothyroidism pptx
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
Onica Farming 24rsclub profitable farm business
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
NOI Hackathon - Summer Edition - GreenThumber.pptx
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
O7-L3 Supply Chain Operations - ICLT Program
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Open Quiz Monsoon Mind Game Final Set.pptx
UPPER GASTRO INTESTINAL DISORDER.docx
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Types of Literary Text: Poetry and Prose
Renaissance Architecture: A Journey from Faith to Humanism

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