SlideShare a Scribd company logo
OBJECT-ORIENTED PROGRAMMING
WITH JAVA
Oum Saokosal, Chief of Computer Science
National Polytechnic Institute of Cambodia
Tel: (855)-12-252-752
E-mail: oum_saokosal@yahoo.com
Chapter 6 Objects and Classes
(Revision)
• OOP
• Classes
• Objects
• Constructors
• Accessing Object’s Data and Methods
Object-Oriented Programming
• Why learning OOP?
• Java is a pure OOP
• OOP provides more flexibility, modularity, clarity, reusability
• Other Programming: C++, C#, VB .NET, ActionScript 3.0, Ruby etc.
also use OOP.
• 3 concepts of OOP:
• Class Encapsulation
• Class Inheritance
• Polymorphism
Classes (1)
• What is a class?
• A class is similar to a template, blueprint or symbol (in Adobe
Flash).
• A class creates many objects.
Class
Objects
Classes (2)
• In a class, there are :
• Data Fields (Properties)
• Behavior:
• Constructors
• Methods
public class Student {
private int id, String name;
public Student(){}
public Student (int inputID,
String inputName){
this.id = inputID;
this.name = inputName;
}
public String toString(){
return id + name;
}
}
Constructors (1)
• What is constructor?
• A constructor is to construct (create) objects from a class.
public class Student {
private int id, String name;
public Student(){}
public Student (int inputID,String inputName){
this.id = inputID;
this.name = inputName;
}
public String toString(){
return id + name;
}
}
Constructors (2)
• How to construct objects?
• Usually, we have many classes in a projects. So the student class
will be created in other classes.
• To construct objects from student class:
public class TestStudent {
public static void main(String[] args){
Student stu;
//To construct an object
stu = new Student();
System.out.println(stu.toString());
}
}
Access Object’s Data and Methods
• To access method:
public class TestStudent {
public static void main(String[] args){
Student stu;
//To construct an object
stu = new Student(“123”,”Veasna”);
System.out.println(stu.toString());
}
}
• To access data:
• Usually, We don’t access the data. If you like, you can do like :
stu.id = 123 in case id is not private.
END OF REVISION
END OF REVISION

More Related Content

What's hot

Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
PawanMM
 
Lecture 01 - Basic Concept About OOP With Python
Lecture 01 - Basic Concept About OOP With PythonLecture 01 - Basic Concept About OOP With Python
Lecture 01 - Basic Concept About OOP With Python
National College of Business Administration & Economics ( NCBA&E)
 
Introduce oop in python
Introduce oop in pythonIntroduce oop in python
Introduce oop in python
tuan vo
 
Oop java
Oop javaOop java
Oop java
Minal Maniar
 
Inner Classes
Inner Classes Inner Classes
Inner Classes
Hitesh-Java
 
Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)Majid Saeed
 
Java Programming - Introduction to Abstract Class
Java Programming - Introduction to Abstract ClassJava Programming - Introduction to Abstract Class
Java Programming - Introduction to Abstract Class
Oum Saokosal
 
Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2
Mahmoud Alfarra
 
OOP with Java - Continued
OOP with Java - Continued OOP with Java - Continued
OOP with Java - Continued
Hitesh-Java
 
[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP
Muhammad Hammad Waseem
 
Oops in Java
Oops in JavaOops in Java
Oops in Java
malathip12
 
[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing
Muhammad Hammad Waseem
 
Object and class
Object and classObject and class
Object and class
mohit tripathi
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
Atul Sehdev
 
Session 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with JavaSession 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with Java
PawanMM
 
Session 05 - Strings in Java
Session 05 - Strings in JavaSession 05 - Strings in Java
Session 05 - Strings in Java
PawanMM
 
Introduction to OOP(in java) BY Govind Singh
Introduction to OOP(in java)  BY Govind SinghIntroduction to OOP(in java)  BY Govind Singh
Introduction to OOP(in java) BY Govind Singh
prabhat engineering college
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
foreverredpb
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 

What's hot (20)

Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
 
Oops Concept Java
Oops Concept JavaOops Concept Java
Oops Concept Java
 
Lecture 01 - Basic Concept About OOP With Python
Lecture 01 - Basic Concept About OOP With PythonLecture 01 - Basic Concept About OOP With Python
Lecture 01 - Basic Concept About OOP With Python
 
Introduce oop in python
Introduce oop in pythonIntroduce oop in python
Introduce oop in python
 
Oop java
Oop javaOop java
Oop java
 
Inner Classes
Inner Classes Inner Classes
Inner Classes
 
Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)
 
Java Programming - Introduction to Abstract Class
Java Programming - Introduction to Abstract ClassJava Programming - Introduction to Abstract Class
Java Programming - Introduction to Abstract Class
 
Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2Object Oriented Programming_Lecture 2
Object Oriented Programming_Lecture 2
 
OOP with Java - Continued
OOP with Java - Continued OOP with Java - Continued
OOP with Java - Continued
 
[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP
 
Oops in Java
Oops in JavaOops in Java
Oops in Java
 
[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing
 
Object and class
Object and classObject and class
Object and class
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
 
Session 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with JavaSession 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with Java
 
Session 05 - Strings in Java
Session 05 - Strings in JavaSession 05 - Strings in Java
Session 05 - Strings in Java
 
Introduction to OOP(in java) BY Govind Singh
Introduction to OOP(in java)  BY Govind SinghIntroduction to OOP(in java)  BY Govind Singh
Introduction to OOP(in java) BY Govind Singh
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 

Viewers also liked

Java Programming - Inheritance
Java Programming - InheritanceJava Programming - Inheritance
Java Programming - Inheritance
Oum Saokosal
 
11.1 Android with HTML
11.1 Android with HTML11.1 Android with HTML
11.1 Android with HTML
Oum Saokosal
 
10.3 Android Video
10.3 Android Video10.3 Android Video
10.3 Android Video
Oum Saokosal
 
Database Concept - ERD Mapping to MS Access
Database Concept - ERD Mapping to MS AccessDatabase Concept - ERD Mapping to MS Access
Database Concept - ERD Mapping to MS Access
Oum Saokosal
 
09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
Oum Saokosal
 
Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)
Oum Saokosal
 
Java Programming - Abstract Class and Interface
Java Programming - Abstract Class and InterfaceJava Programming - Abstract Class and Interface
Java Programming - Abstract Class and Interface
Oum Saokosal
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Oum Saokosal
 
Android - Introduction
Android - IntroductionAndroid - Introduction
Android - Introduction
Oum Saokosal
 
Object Oriended Programming with Java
Object Oriended Programming with JavaObject Oriended Programming with Java
Object Oriended Programming with JavaJakir Hossain
 
07.4. Android Basic Simple Browser (WebView)
07.4. Android Basic Simple Browser (WebView)07.4. Android Basic Simple Browser (WebView)
07.4. Android Basic Simple Browser (WebView)
Oum Saokosal
 
10.1. Android Audio
10.1. Android Audio10.1. Android Audio
10.1. Android Audio
Oum Saokosal
 
06. Android Basic Widget and Container
06. Android Basic Widget and Container06. Android Basic Widget and Container
06. Android Basic Widget and Container
Oum Saokosal
 
07.3. Android Alert message, List, Dropdown, and Auto Complete
07.3. Android Alert message, List, Dropdown, and Auto Complete07.3. Android Alert message, List, Dropdown, and Auto Complete
07.3. Android Alert message, List, Dropdown, and Auto Complete
Oum Saokosal
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in android
Oum Saokosal
 
08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)
Oum Saokosal
 
10.2 Android Audio with SD Card
10.2 Android Audio with SD Card10.2 Android Audio with SD Card
10.2 Android Audio with SD Card
Oum Saokosal
 
07.1. Android Even Handling
07.1. Android Even Handling07.1. Android Even Handling
07.1. Android Even Handling
Oum Saokosal
 
12. Android Basic Google Map
12. Android Basic Google Map12. Android Basic Google Map
12. Android Basic Google Map
Oum Saokosal
 
College Management System project
College Management System projectCollege Management System project
College Management System project
Manish Kushwaha
 

Viewers also liked (20)

Java Programming - Inheritance
Java Programming - InheritanceJava Programming - Inheritance
Java Programming - Inheritance
 
11.1 Android with HTML
11.1 Android with HTML11.1 Android with HTML
11.1 Android with HTML
 
10.3 Android Video
10.3 Android Video10.3 Android Video
10.3 Android Video
 
Database Concept - ERD Mapping to MS Access
Database Concept - ERD Mapping to MS AccessDatabase Concept - ERD Mapping to MS Access
Database Concept - ERD Mapping to MS Access
 
09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
 
Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)
 
Java Programming - Abstract Class and Interface
Java Programming - Abstract Class and InterfaceJava Programming - Abstract Class and Interface
Java Programming - Abstract Class and Interface
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
 
Android - Introduction
Android - IntroductionAndroid - Introduction
Android - Introduction
 
Object Oriended Programming with Java
Object Oriended Programming with JavaObject Oriended Programming with Java
Object Oriended Programming with Java
 
07.4. Android Basic Simple Browser (WebView)
07.4. Android Basic Simple Browser (WebView)07.4. Android Basic Simple Browser (WebView)
07.4. Android Basic Simple Browser (WebView)
 
10.1. Android Audio
10.1. Android Audio10.1. Android Audio
10.1. Android Audio
 
06. Android Basic Widget and Container
06. Android Basic Widget and Container06. Android Basic Widget and Container
06. Android Basic Widget and Container
 
07.3. Android Alert message, List, Dropdown, and Auto Complete
07.3. Android Alert message, List, Dropdown, and Auto Complete07.3. Android Alert message, List, Dropdown, and Auto Complete
07.3. Android Alert message, List, Dropdown, and Auto Complete
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in android
 
08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)
 
10.2 Android Audio with SD Card
10.2 Android Audio with SD Card10.2 Android Audio with SD Card
10.2 Android Audio with SD Card
 
07.1. Android Even Handling
07.1. Android Even Handling07.1. Android Even Handling
07.1. Android Even Handling
 
12. Android Basic Google Map
12. Android Basic Google Map12. Android Basic Google Map
12. Android Basic Google Map
 
College Management System project
College Management System projectCollege Management System project
College Management System project
 

Similar to Objected-Oriented Programming with Java

COMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptxCOMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptx
FarooqTariq8
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
madan r
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Sandeep Karthikeyan
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
LakshyaChauhan21
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
MaruMengesha
 
Introduction to oops
Introduction to oopsIntroduction to oops
Introduction to oops
Umamaheshwariv1
 
12_oop templa.pptx
12_oop templa.pptx12_oop templa.pptx
12_oop templa.pptx
RokaKaram
 
C++ in object oriented programming
C++ in object oriented programmingC++ in object oriented programming
C++ in object oriented programming
Saket Khopkar
 
Java_notes.ppt
Java_notes.pptJava_notes.ppt
Java_notes.ppt
tuyambazejeanclaude
 
Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)
OUM SAOKOSAL
 
The View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptThe View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptBill Buchan
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
AnsgarMary
 
Evolving systems and the link to service orientation
Evolving systems and the link to service orientationEvolving systems and the link to service orientation
Evolving systems and the link to service orientation
Angelo van der Sijpt
 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
DurgaPrasadVasantati
 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
DurgaPrasadVasantati
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
RiturajJain8
 
Features of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptxFeatures of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptx
SwagatoBiswas
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Saiful Islam Sany
 
lecture-1111111111111111111111111111.pdf
lecture-1111111111111111111111111111.pdflecture-1111111111111111111111111111.pdf
lecture-1111111111111111111111111111.pdf
harey68956
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design Principles
Michael Redlich
 

Similar to Objected-Oriented Programming with Java (20)

COMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptxCOMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptx
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
 
Introduction to oops
Introduction to oopsIntroduction to oops
Introduction to oops
 
12_oop templa.pptx
12_oop templa.pptx12_oop templa.pptx
12_oop templa.pptx
 
C++ in object oriented programming
C++ in object oriented programmingC++ in object oriented programming
C++ in object oriented programming
 
Java_notes.ppt
Java_notes.pptJava_notes.ppt
Java_notes.ppt
 
Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)Chapter 6 OOP (Revision)
Chapter 6 OOP (Revision)
 
The View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptThe View object orientated programming in Lotuscript
The View object orientated programming in Lotuscript
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
 
Evolving systems and the link to service orientation
Evolving systems and the link to service orientationEvolving systems and the link to service orientation
Evolving systems and the link to service orientation
 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
Features of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptxFeatures of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
lecture-1111111111111111111111111111.pdf
lecture-1111111111111111111111111111.pdflecture-1111111111111111111111111111.pdf
lecture-1111111111111111111111111111.pdf
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design Principles
 

Recently uploaded

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 

Objected-Oriented Programming with Java

  • 1. OBJECT-ORIENTED PROGRAMMING WITH JAVA Oum Saokosal, Chief of Computer Science National Polytechnic Institute of Cambodia Tel: (855)-12-252-752 E-mail: oum_saokosal@yahoo.com
  • 2. Chapter 6 Objects and Classes (Revision) • OOP • Classes • Objects • Constructors • Accessing Object’s Data and Methods
  • 3. Object-Oriented Programming • Why learning OOP? • Java is a pure OOP • OOP provides more flexibility, modularity, clarity, reusability • Other Programming: C++, C#, VB .NET, ActionScript 3.0, Ruby etc. also use OOP. • 3 concepts of OOP: • Class Encapsulation • Class Inheritance • Polymorphism
  • 4. Classes (1) • What is a class? • A class is similar to a template, blueprint or symbol (in Adobe Flash). • A class creates many objects. Class Objects
  • 5. Classes (2) • In a class, there are : • Data Fields (Properties) • Behavior: • Constructors • Methods public class Student { private int id, String name; public Student(){} public Student (int inputID, String inputName){ this.id = inputID; this.name = inputName; } public String toString(){ return id + name; } }
  • 6. Constructors (1) • What is constructor? • A constructor is to construct (create) objects from a class. public class Student { private int id, String name; public Student(){} public Student (int inputID,String inputName){ this.id = inputID; this.name = inputName; } public String toString(){ return id + name; } }
  • 7. Constructors (2) • How to construct objects? • Usually, we have many classes in a projects. So the student class will be created in other classes. • To construct objects from student class: public class TestStudent { public static void main(String[] args){ Student stu; //To construct an object stu = new Student(); System.out.println(stu.toString()); } }
  • 8. Access Object’s Data and Methods • To access method: public class TestStudent { public static void main(String[] args){ Student stu; //To construct an object stu = new Student(“123”,”Veasna”); System.out.println(stu.toString()); } } • To access data: • Usually, We don’t access the data. If you like, you can do like : stu.id = 123 in case id is not private.