SlideShare a Scribd company logo
Classes Revision
CST200 – Week 4: Midterm revision

Instructor: Andreea Molnar
Outline
• Classes
• Example
• Constructor
• Encapsulation
Classes
In object oriented programming classes
represent objects with different
characteristics (attributes, data) and
functionality (operations, methods).
Example
Person
Characteristics: name, social security
number
Functionality: sleeps, walks
Example
Person
Attributes: name, social security number
Operations: sleeps, walks
Example
Person
Data: name, social security number
Methods: sleeps, walks
Example
Person
Data: define the state of the object
Methods: define the behavior of the object
Example
public class Person {

private String name;

Data declaration

private String socialSecurityNo;

public void sleeps() {
}
public void walks() {
}
}

Method declaration
Example
public class Person {
private String name;

private String socialSecurityNo;

Instance variables –
variables created at the
class level

Each instance of a class
(object) has its own instance
variables/data space
public void sleeps() {
}
public void walks() {
}
}

Each instance of a class
(object) share the method
definitions
Constructor
•
•
•

Creates (and initializes) an object

Similar to a method that has:

•
•

the same name as the class

no return type

Each class has a default constructor that
accepts no parameters (this is generated
only if no explicit constructor is provided).
Constructor
public class Test {
public static void main(String[] args) {
Person p = new Person();
}
}

The default
constructor is called
Constructor
public class Person {
private String name;
private String socialSecurityNo;
public Person(String name, String socialSecurityNo) {
this.name = name;

Constructor

this.socialSecurityNo = socialSecurityNo;
}
public void sleeps() {
}
public void walks() {
}
}

this is a reference to the
current object
Constructor
public class Test {
public static void main(String[] args) {
Person p = new Person("Mary", "078-05-1120");
}
}
Constructor
public class Test {
public static void main(String[] args) {
Person p1 = new Person("Mary", "078-05-1120");

Person p2 = new Person(“John", "078-05-1121");
}
}

name

name

Mary

John

socialSecurityNo

socialSecurityNo

078-05-1120

078-05-1121

Each instance of a
class (object) has its
own instance
variables/data space.
Encapsulation
•
•

Hides the data and implementation details
of an object
Protects the data integrity by making it
difficult to have unauthorized access
Encapsulation
•

Uses visibility modifiers (e.g. private) to
deny access
private String name;
private String socialSecurityNo;

name and
socialSecurityNo can
be referenced only
within Person class

public class Test {
public static void main(String[] args) {
Person p = new Person("Mary", "078-05-1120");
p.name = "Alice";
}

}

error
Encapsulation

Allows access to instance variables through
methods: accessor method (getter) and
mutator method (setter)
Encapsulation
Accessor method (getter) – returns the
variable value.
private String name;
public String getName() {
return name;
}
Encapsulation
Accessor method (getter) – returns the
variable value.
public class Test {
public static void main(String[] args) {
Person p = new Person("Mary", "078-05-1120");
System.out.println(p.getName());
}
}

Will print Mary

p

name
Mary

socialSecurityNo
078-05-1120
Encapsulation
Mutator method (setter) – changes the
variable value
private String name;
public void setName(String name) {
this.name = name;
}
Encapsulation
Mutator method (setter) – changes the variable value
public class Test {
public static void main(String[] args) {
Person p = new Person("Mary", "078-05-1120");
System.out.println(p.getName()); //will print Mary
p
p.setName("Alice");
System.out.println(p.getName()); //will print Alice
}
}
name
Mary Alice

socialSecurityNo
078-05-1120
Summary
• Initialize instance variables in the
constructor

• Make the instance variables private
unless there is a good reason to do
otherwise

• Allow access to instance variables
through setter and getter methods
Ad

More Related Content

What's hot (20)

Adbms 15 object data management group
Adbms 15 object data management groupAdbms 15 object data management group
Adbms 15 object data management group
Vaibhav Khanna
 
Java- Nested Classes
Java- Nested ClassesJava- Nested Classes
Java- Nested Classes
Prabhdeep Singh
 
Java OO Revisited
Java OO RevisitedJava OO Revisited
Java OO Revisited
Jussi Pohjolainen
 
C++ classes
C++ classesC++ classes
C++ classes
Aayush Patel
 
Chap01
Chap01Chap01
Chap01
Jotham Gadot
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
PhD Research Scholar
 
Jscript part2
Jscript part2Jscript part2
Jscript part2
Girish Srivastava
 
class c++
class c++class c++
class c++
vinay chauhan
 
Class and object in c++
Class and object in c++Class and object in c++
Class and object in c++
NainaKhan28
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and Object
OUM SAOKOSAL
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
Govt. P.G. College Dharamshala
 
How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programming
Syed Faizan Hassan
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
rajveer_Pannu
 
Session 09 - OOPS
Session 09 - OOPSSession 09 - OOPS
Session 09 - OOPS
SiddharthSelenium
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects
Muhammad Hammad Waseem
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Saleem Thapa
 
Inner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVAInner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVA
Tech_MX
 
Write First C++ class
Write First C++ classWrite First C++ class
Write First C++ class
Learn By Watch
 
Adbms 15 object data management group
Adbms 15 object data management groupAdbms 15 object data management group
Adbms 15 object data management group
Vaibhav Khanna
 
Class and object in c++
Class and object in c++Class and object in c++
Class and object in c++
NainaKhan28
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and Object
OUM SAOKOSAL
 
How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programming
Syed Faizan Hassan
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Saleem Thapa
 
Inner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVAInner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVA
Tech_MX
 

Similar to Classes revision (20)

Simple class and object examples in java
Simple class and object examples in javaSimple class and object examples in java
Simple class and object examples in java
Harish Gyanani
 
Classes-and-Object.pptx
Classes-and-Object.pptxClasses-and-Object.pptx
Classes-and-Object.pptx
VishwanathanS5
 
Department of information technology_20250322_133114_0000.pptx
Department of information technology_20250322_133114_0000.pptxDepartment of information technology_20250322_133114_0000.pptx
Department of information technology_20250322_133114_0000.pptx
ShreeVarshini12
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
Intro C# Book
 
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
argsstring
 
Pj01 x-classes and objects
Pj01 x-classes and objectsPj01 x-classes and objects
Pj01 x-classes and objects
SasidharaRaoMarrapu
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
zand3rs
 
javaClasses.pptx
javaClasses.pptxjavaClasses.pptx
javaClasses.pptx
MattMarino13
 
Lecture 4 part 2.pdf
Lecture 4 part 2.pdfLecture 4 part 2.pdf
Lecture 4 part 2.pdf
SakhilejasonMsibi
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
mha4
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
mha4
 
Explain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).pptExplain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).ppt
ayaankim007
 
Classes, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptxClasses, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptx
DivyaKS18
 
UNIT - IIInew.pptx
UNIT - IIInew.pptxUNIT - IIInew.pptx
UNIT - IIInew.pptx
akila m
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
ilias ahmed
 
what is class in C++ and classes_objects.ppt
what is class in C++ and classes_objects.pptwhat is class in C++ and classes_objects.ppt
what is class in C++ and classes_objects.ppt
malikliyaqathusain
 
Week 3-LectureA Object Oriented Programmings.pptx
Week 3-LectureA Object Oriented Programmings.pptxWeek 3-LectureA Object Oriented Programmings.pptx
Week 3-LectureA Object Oriented Programmings.pptx
FarhanGhafoor7
 
Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
shinyduela
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
BG Java EE Course
 
Chapter iii(oop)
Chapter iii(oop)Chapter iii(oop)
Chapter iii(oop)
Chhom Karath
 
Simple class and object examples in java
Simple class and object examples in javaSimple class and object examples in java
Simple class and object examples in java
Harish Gyanani
 
Classes-and-Object.pptx
Classes-and-Object.pptxClasses-and-Object.pptx
Classes-and-Object.pptx
VishwanathanS5
 
Department of information technology_20250322_133114_0000.pptx
Department of information technology_20250322_133114_0000.pptxDepartment of information technology_20250322_133114_0000.pptx
Department of information technology_20250322_133114_0000.pptx
ShreeVarshini12
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
Intro C# Book
 
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
argsstring
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
zand3rs
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
mha4
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
mha4
 
Explain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).pptExplain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).ppt
ayaankim007
 
Classes, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptxClasses, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptx
DivyaKS18
 
UNIT - IIInew.pptx
UNIT - IIInew.pptxUNIT - IIInew.pptx
UNIT - IIInew.pptx
akila m
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
ilias ahmed
 
what is class in C++ and classes_objects.ppt
what is class in C++ and classes_objects.pptwhat is class in C++ and classes_objects.ppt
what is class in C++ and classes_objects.ppt
malikliyaqathusain
 
Week 3-LectureA Object Oriented Programmings.pptx
Week 3-LectureA Object Oriented Programmings.pptxWeek 3-LectureA Object Oriented Programmings.pptx
Week 3-LectureA Object Oriented Programmings.pptx
FarhanGhafoor7
 
Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
shinyduela
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
BG Java EE Course
 
Ad

More from ASU Online (20)

Midterm common mistakes
Midterm common mistakesMidterm common mistakes
Midterm common mistakes
ASU Online
 
Lists, queues and stacks 1
Lists, queues and stacks 1Lists, queues and stacks 1
Lists, queues and stacks 1
ASU Online
 
Lists, queues and stacks
Lists, queues and stacksLists, queues and stacks
Lists, queues and stacks
ASU Online
 
For loop java 2
For loop java 2For loop java 2
For loop java 2
ASU Online
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2
ASU Online
 
Common errors v2
Common errors v2Common errors v2
Common errors v2
ASU Online
 
Common missunderestandings
Common missunderestandingsCommon missunderestandings
Common missunderestandings
ASU Online
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
ASU Online
 
Lecture 14 tourism in europe
Lecture 14   tourism in europeLecture 14   tourism in europe
Lecture 14 tourism in europe
ASU Online
 
Lecture 13 tourism in the south pacific
Lecture 13   tourism in the south pacificLecture 13   tourism in the south pacific
Lecture 13 tourism in the south pacific
ASU Online
 
Lecture 12 tourism in australia and new zealand
Lecture 12   tourism in australia and new zealandLecture 12   tourism in australia and new zealand
Lecture 12 tourism in australia and new zealand
ASU Online
 
Lecture 11 tourism in east asia
Lecture 11   tourism in east asiaLecture 11   tourism in east asia
Lecture 11 tourism in east asia
ASU Online
 
Lecture 9 tourism in south asia
Lecture 9   tourism in south asiaLecture 9   tourism in south asia
Lecture 9 tourism in south asia
ASU Online
 
Lecture 9 tourism in south asia-1
Lecture 9   tourism in south asia-1Lecture 9   tourism in south asia-1
Lecture 9 tourism in south asia-1
ASU Online
 
Lecture 8 tourism in central asia
Lecture 8   tourism in central asiaLecture 8   tourism in central asia
Lecture 8 tourism in central asia
ASU Online
 
Lecture 7 tourism in the middle east and north africa
Lecture 7   tourism in the middle east and north africaLecture 7   tourism in the middle east and north africa
Lecture 7 tourism in the middle east and north africa
ASU Online
 
Lecture 6 tourism in sub-saharan africa
Lecture 6   tourism in sub-saharan africaLecture 6   tourism in sub-saharan africa
Lecture 6 tourism in sub-saharan africa
ASU Online
 
Lecture 5 tourism in latin america
Lecture 5   tourism in latin americaLecture 5   tourism in latin america
Lecture 5 tourism in latin america
ASU Online
 
Lecture 4 tourism in the caribbean
Lecture 4   tourism in the caribbeanLecture 4   tourism in the caribbean
Lecture 4 tourism in the caribbean
ASU Online
 
Lecture 3 political context of international tourism
Lecture 3   political context of international tourismLecture 3   political context of international tourism
Lecture 3 political context of international tourism
ASU Online
 
Midterm common mistakes
Midterm common mistakesMidterm common mistakes
Midterm common mistakes
ASU Online
 
Lists, queues and stacks 1
Lists, queues and stacks 1Lists, queues and stacks 1
Lists, queues and stacks 1
ASU Online
 
Lists, queues and stacks
Lists, queues and stacksLists, queues and stacks
Lists, queues and stacks
ASU Online
 
For loop java 2
For loop java 2For loop java 2
For loop java 2
ASU Online
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2
ASU Online
 
Common errors v2
Common errors v2Common errors v2
Common errors v2
ASU Online
 
Common missunderestandings
Common missunderestandingsCommon missunderestandings
Common missunderestandings
ASU Online
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
ASU Online
 
Lecture 14 tourism in europe
Lecture 14   tourism in europeLecture 14   tourism in europe
Lecture 14 tourism in europe
ASU Online
 
Lecture 13 tourism in the south pacific
Lecture 13   tourism in the south pacificLecture 13   tourism in the south pacific
Lecture 13 tourism in the south pacific
ASU Online
 
Lecture 12 tourism in australia and new zealand
Lecture 12   tourism in australia and new zealandLecture 12   tourism in australia and new zealand
Lecture 12 tourism in australia and new zealand
ASU Online
 
Lecture 11 tourism in east asia
Lecture 11   tourism in east asiaLecture 11   tourism in east asia
Lecture 11 tourism in east asia
ASU Online
 
Lecture 9 tourism in south asia
Lecture 9   tourism in south asiaLecture 9   tourism in south asia
Lecture 9 tourism in south asia
ASU Online
 
Lecture 9 tourism in south asia-1
Lecture 9   tourism in south asia-1Lecture 9   tourism in south asia-1
Lecture 9 tourism in south asia-1
ASU Online
 
Lecture 8 tourism in central asia
Lecture 8   tourism in central asiaLecture 8   tourism in central asia
Lecture 8 tourism in central asia
ASU Online
 
Lecture 7 tourism in the middle east and north africa
Lecture 7   tourism in the middle east and north africaLecture 7   tourism in the middle east and north africa
Lecture 7 tourism in the middle east and north africa
ASU Online
 
Lecture 6 tourism in sub-saharan africa
Lecture 6   tourism in sub-saharan africaLecture 6   tourism in sub-saharan africa
Lecture 6 tourism in sub-saharan africa
ASU Online
 
Lecture 5 tourism in latin america
Lecture 5   tourism in latin americaLecture 5   tourism in latin america
Lecture 5 tourism in latin america
ASU Online
 
Lecture 4 tourism in the caribbean
Lecture 4   tourism in the caribbeanLecture 4   tourism in the caribbean
Lecture 4 tourism in the caribbean
ASU Online
 
Lecture 3 political context of international tourism
Lecture 3   political context of international tourismLecture 3   political context of international tourism
Lecture 3 political context of international tourism
ASU Online
 
Ad

Recently uploaded (20)

AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 

Classes revision

  • 1. Classes Revision CST200 – Week 4: Midterm revision Instructor: Andreea Molnar
  • 2. Outline • Classes • Example • Constructor • Encapsulation
  • 3. Classes In object oriented programming classes represent objects with different characteristics (attributes, data) and functionality (operations, methods).
  • 4. Example Person Characteristics: name, social security number Functionality: sleeps, walks
  • 5. Example Person Attributes: name, social security number Operations: sleeps, walks
  • 6. Example Person Data: name, social security number Methods: sleeps, walks
  • 7. Example Person Data: define the state of the object Methods: define the behavior of the object
  • 8. Example public class Person { private String name; Data declaration private String socialSecurityNo; public void sleeps() { } public void walks() { } } Method declaration
  • 9. Example public class Person { private String name; private String socialSecurityNo; Instance variables – variables created at the class level Each instance of a class (object) has its own instance variables/data space public void sleeps() { } public void walks() { } } Each instance of a class (object) share the method definitions
  • 10. Constructor • • • Creates (and initializes) an object Similar to a method that has: • • the same name as the class no return type Each class has a default constructor that accepts no parameters (this is generated only if no explicit constructor is provided).
  • 11. Constructor public class Test { public static void main(String[] args) { Person p = new Person(); } } The default constructor is called
  • 12. Constructor public class Person { private String name; private String socialSecurityNo; public Person(String name, String socialSecurityNo) { this.name = name; Constructor this.socialSecurityNo = socialSecurityNo; } public void sleeps() { } public void walks() { } } this is a reference to the current object
  • 13. Constructor public class Test { public static void main(String[] args) { Person p = new Person("Mary", "078-05-1120"); } }
  • 14. Constructor public class Test { public static void main(String[] args) { Person p1 = new Person("Mary", "078-05-1120"); Person p2 = new Person(“John", "078-05-1121"); } } name name Mary John socialSecurityNo socialSecurityNo 078-05-1120 078-05-1121 Each instance of a class (object) has its own instance variables/data space.
  • 15. Encapsulation • • Hides the data and implementation details of an object Protects the data integrity by making it difficult to have unauthorized access
  • 16. Encapsulation • Uses visibility modifiers (e.g. private) to deny access private String name; private String socialSecurityNo; name and socialSecurityNo can be referenced only within Person class public class Test { public static void main(String[] args) { Person p = new Person("Mary", "078-05-1120"); p.name = "Alice"; } } error
  • 17. Encapsulation Allows access to instance variables through methods: accessor method (getter) and mutator method (setter)
  • 18. Encapsulation Accessor method (getter) – returns the variable value. private String name; public String getName() { return name; }
  • 19. Encapsulation Accessor method (getter) – returns the variable value. public class Test { public static void main(String[] args) { Person p = new Person("Mary", "078-05-1120"); System.out.println(p.getName()); } } Will print Mary p name Mary socialSecurityNo 078-05-1120
  • 20. Encapsulation Mutator method (setter) – changes the variable value private String name; public void setName(String name) { this.name = name; }
  • 21. Encapsulation Mutator method (setter) – changes the variable value public class Test { public static void main(String[] args) { Person p = new Person("Mary", "078-05-1120"); System.out.println(p.getName()); //will print Mary p p.setName("Alice"); System.out.println(p.getName()); //will print Alice } } name Mary Alice socialSecurityNo 078-05-1120
  • 22. Summary • Initialize instance variables in the constructor • Make the instance variables private unless there is a good reason to do otherwise • Allow access to instance variables through setter and getter methods
  翻译: