SlideShare a Scribd company logo
Using Java
MINISTRY OF EDUCATION & HIGHER EDUCATION
COLLEGE OF SCIENCE AND TECHNOLOGY
KHANYOUNIS- PALESTINE
Lecture 6
Introduction to classes and objects
 What is Object-Oriented Programming ?
 What classes, objects, methods ?
 How to declare a class ?
 How to use class to create an object?
 How to declare methods in a class ?
 Emank X Mezank
2Presented & Prepared by: Mahmoud R. Alfarra
 It is a whole new way of thinking about
programming!
 It is a way of modeling software that maps
your code to the real world.
 Now please, Look in this room …
3Presented & Prepared by: Mahmoud R. Alfarra
What is Object-Oriented Programming ?
Chair
Door
Man
Window
.
.
No. of legs
Material
Color
Size
Purpose
.
.
Abstraction
Encapsulation
4Presented & Prepared by: Mahmoud R. Alfarra
What is Object-Oriented Programming ?
Any Thing
Attributes
Behavior
Each one represented
by variable in class
Each one represented
by method in class
 The terms class and object are often
confused, and it is important to understand
the distinction.
 It may help you to visualize these terms using
the earlier racecar analogy.
 Think of a class as the template for the car, or
perhaps the plans used to build the car.
 The car itself is an instance of those plans, so
it could be referred to as an object.
5Presented & Prepared by: Mahmoud R. Alfarra
What are classes, objects ?
6Presented & Prepared by: Mahmoud R. Alfarra
Classes, Objects ?
Student
Student 120090234
Student 120090236
Student 120090238
Student 120090400
car
Car-AB-201
Car-AB-323
Car-BM-291
Objectsclasses
 The behavior of the class will be represented
as a method in class.
 The method can be declared as:
7Presented & Prepared by: Mahmoud R. Alfarra
What are methods ?
Access_modifiers return_type method_name (arguments)
{
// instructions
return value;
}
8Presented & Prepared by: Mahmoud R. Alfarra
What are methods ? (Example)
Public void add (int x, int y)
{
int sum = x + y;
}
Public int even (int x)
{
if (x%2 ==0)
return x;
else
{JOptionPane.showMessageDialog(null, "The value is not even ");
Return -1; }
}
9Presented & Prepared by: Mahmoud R. Alfarra
How to declare Class?
Access_modifiers class class_name{
//variables declaration
// constructor
// methods
}
Public class Car{
public String model;
public String ID;
public int price;
public Car (){
model = “Cevic”;
ID = “20023456”;
price= 12,000;
// methods
}
10Presented & Prepared by: Mahmoud R. Alfarra
How to use class to create an object?
class_name obj_name = new constructor_name ();
Car c1 = new Car ();
Car c2 = new Car ();
Car c2 = new Car ();
c2.model = “Honda”;
c2.ID = “987435”;
c2.price = 4000;
‫تعاىل‬ ‫هللا‬ ‫قال‬:
(‫املنفوش‬ ‫كالعهن‬‫اجلبال‬ ‫تكون‬ ‫يوم‬)
11Presented & Prepared by: Mahmoud R. Alfarra
Equality and
Relational
Operators 12Presented & Prepared by: Mahmoud R. Alfarra

More Related Content

Similar to 5 programming-using-java intro-tooop20102011 (20)

PPT
java
jent46
 
PPT
Java is an Object-Oriented Language
ale8819
 
PPTX
Oops concept in Java
Ducat India
 
PPT
Md02 - Getting Started part-2
Rakesh Madugula
 
PDF
Lecture2.pdf
SakhilejasonMsibi
 
PPTX
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
PDF
01 Introduction to OOP codinggggggggggggggggggggggggggggggggg
lokesh437798
 
DOCX
javaopps concepts
Nikhil Agrawal
 
PDF
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
KaviShetty
 
PPTX
Object Oriended Programming with Java
Jakir Hossain
 
PDF
O6u CS-315A OOP Lecture (1).pdf
MohamedRamadan454985
 
PPT
Object-oriented concepts
BG Java EE Course
 
PPTX
Nitish Chaulagai Java1.pptx
NitishChaulagai
 
PPT
Unidad o informatica en ingles
Marisa Torrecillas
 
PPT
10slide.ppt
MohammedNouh7
 
PPTX
Android Training (Java Review)
Khaled Anaqwa
 
PPTX
Ch-2ppt.pptx
ssuser8347a1
 
PDF
Classes and Object Concept Object Oriented Programming in Java
gedeios
 
PDF
A350103
aijbm
 
PDF
Core Java Introduction | Basics
Hùng Nguyễn Huy
 
java
jent46
 
Java is an Object-Oriented Language
ale8819
 
Oops concept in Java
Ducat India
 
Md02 - Getting Started part-2
Rakesh Madugula
 
Lecture2.pdf
SakhilejasonMsibi
 
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
01 Introduction to OOP codinggggggggggggggggggggggggggggggggg
lokesh437798
 
javaopps concepts
Nikhil Agrawal
 
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
KaviShetty
 
Object Oriended Programming with Java
Jakir Hossain
 
O6u CS-315A OOP Lecture (1).pdf
MohamedRamadan454985
 
Object-oriented concepts
BG Java EE Course
 
Nitish Chaulagai Java1.pptx
NitishChaulagai
 
Unidad o informatica en ingles
Marisa Torrecillas
 
10slide.ppt
MohammedNouh7
 
Android Training (Java Review)
Khaled Anaqwa
 
Ch-2ppt.pptx
ssuser8347a1
 
Classes and Object Concept Object Oriented Programming in Java
gedeios
 
A350103
aijbm
 
Core Java Introduction | Basics
Hùng Nguyễn Huy
 

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
4 programming-using-java intro-tojava20102011
Mahmoud Alfarra
 
PPT
3 programming-using-java introduction-to computer
Mahmoud Alfarra
 
PPT
2 programming-using-java how to built application
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
 
4 programming-using-java intro-tojava20102011
Mahmoud Alfarra
 
3 programming-using-java introduction-to computer
Mahmoud Alfarra
 
2 programming-using-java how to built application
Mahmoud Alfarra
 
Ad

Recently uploaded (20)

PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
infertility, types,causes, impact, and management
Ritu480198
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Horarios de distribución de agua en julio
pegazohn1978
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Introduction presentation of the patentbutler tool
MIPLM
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Ad

5 programming-using-java intro-tooop20102011

  • 1. Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 6 Introduction to classes and objects
  • 2.  What is Object-Oriented Programming ?  What classes, objects, methods ?  How to declare a class ?  How to use class to create an object?  How to declare methods in a class ?  Emank X Mezank 2Presented & Prepared by: Mahmoud R. Alfarra
  • 3.  It is a whole new way of thinking about programming!  It is a way of modeling software that maps your code to the real world.  Now please, Look in this room … 3Presented & Prepared by: Mahmoud R. Alfarra What is Object-Oriented Programming ? Chair Door Man Window . . No. of legs Material Color Size Purpose . . Abstraction Encapsulation
  • 4. 4Presented & Prepared by: Mahmoud R. Alfarra What is Object-Oriented Programming ? Any Thing Attributes Behavior Each one represented by variable in class Each one represented by method in class
  • 5.  The terms class and object are often confused, and it is important to understand the distinction.  It may help you to visualize these terms using the earlier racecar analogy.  Think of a class as the template for the car, or perhaps the plans used to build the car.  The car itself is an instance of those plans, so it could be referred to as an object. 5Presented & Prepared by: Mahmoud R. Alfarra What are classes, objects ?
  • 6. 6Presented & Prepared by: Mahmoud R. Alfarra Classes, Objects ? Student Student 120090234 Student 120090236 Student 120090238 Student 120090400 car Car-AB-201 Car-AB-323 Car-BM-291 Objectsclasses
  • 7.  The behavior of the class will be represented as a method in class.  The method can be declared as: 7Presented & Prepared by: Mahmoud R. Alfarra What are methods ? Access_modifiers return_type method_name (arguments) { // instructions return value; }
  • 8. 8Presented & Prepared by: Mahmoud R. Alfarra What are methods ? (Example) Public void add (int x, int y) { int sum = x + y; } Public int even (int x) { if (x%2 ==0) return x; else {JOptionPane.showMessageDialog(null, "The value is not even "); Return -1; } }
  • 9. 9Presented & Prepared by: Mahmoud R. Alfarra How to declare Class? Access_modifiers class class_name{ //variables declaration // constructor // methods } Public class Car{ public String model; public String ID; public int price; public Car (){ model = “Cevic”; ID = “20023456”; price= 12,000; // methods }
  • 10. 10Presented & Prepared by: Mahmoud R. Alfarra How to use class to create an object? class_name obj_name = new constructor_name (); Car c1 = new Car (); Car c2 = new Car (); Car c2 = new Car (); c2.model = “Honda”; c2.ID = “987435”; c2.price = 4000;
  • 11. ‫تعاىل‬ ‫هللا‬ ‫قال‬: (‫املنفوش‬ ‫كالعهن‬‫اجلبال‬ ‫تكون‬ ‫يوم‬) 11Presented & Prepared by: Mahmoud R. Alfarra
  • 12. Equality and Relational Operators 12Presented & Prepared by: Mahmoud R. Alfarra