SlideShare uma empresa Scribd logo
1 de 16
YourFirst Java
Application
Chapter 2
2
ProgramConcepts
Modern object-oriented programs
help us build models to manage the
complexity found in a problem
domain.
The problem domain describes real-world
objects and concepts that a computer
program is trying to solve.
2
Models
A model is a simplification of a
complex system. A good model:
Helps to identify the most important
aspects of a problem.
Helps a programmer to focus on the
problem he or she is trying to solve
instead of on the complexity of the
problem’s data.
2
What is a metaphor?
A metaphor is a word or phrase used
in place of another word or phrase to
denote a likeness.
Computer programs use “metaphors” to
represent real objects.
2
Objects
Objects represent real-world things:
Ship
Rudder
Wheel
Instruments
Objects have:
properties (characteristics)
methods (behaviors)
2
Classes and Objects
A class is a definition of a type:
Like a template, a class defines the
characteristics and behaviors of the type.
An object is an instance of a class:
Can be instantiated and manipulated
An object’s characteristics are defined by
the class that was used to create the
object.
2
Fields
Fields define the properties of a class.
Can be intrinsic types (int, boolean…)
Can be user-defined objects
State is the current value of a field in
an object.
2
Methods
Methods describe the capabilities of
the class.
Every method must be called from
another method. The only exception is
main(), which is called by the OS.
Methods can accept parameters.
2
Object Relationships
Association
A method of one object calls the method
of another object.
Composition
Some objects are composed of other
objects.
2
Specialization
Hierarchies of classes
move from a
generalized class to a
more specific class.
2
Creating Programs
Syntax and Semantics
A language’s exact keywords,
punctuation, and order of terms are called
its syntax.
Semantics refers to the meaning of one’s
instructions; what the program is trying to
accomplish.
2
Writing a Java Program
Writing a Java program requires five
steps:
Analyze
Design
Write
Compile
Test
2
Compiling the Code
Programs must be compiled in order
for the CPU to understand and execute
the instructions.
Java byte code is run through the Java
Virtual Machine (JVM), which translates
the code for the CPU.
.java files are compiled by the javac (java
compiler) program into .class files.
2
Types of Java Programs
Applet
Requires an .HTML file with the <applet> tag to
reference the .class file
Can also be run using the appletviewer.exe
program file
Application
Run by the java.exe program file
Run without a browser interface, often using the
console window
2
HelloWorld.java Analysis
The keyword import allows existing
class libraries to be reused.
The keyword public signifies that a
class is visible to other classes.
Braces {} indicate the beginning and end
of a block of code.
Braces must always be “balanced”
Align opening and closing braces
2
More HelloWorld.java Analysis
The keyword void signifies that a
method does not return a value.
Identifiers are the names given to classes,
fields, and methods.
Identifiers are case sensitive.
Identifiers often use camel case notation.

Mais conteúdo relacionado

Destaque (9)

Chapter 04
Chapter 04Chapter 04
Chapter 04
 
Challenges
ChallengesChallenges
Challenges
 
Idea's1 only
Idea's1 onlyIdea's1 only
Idea's1 only
 
Chapter 09
Chapter 09Chapter 09
Chapter 09
 
Chapter 06
Chapter 06Chapter 06
Chapter 06
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
House in order
House in orderHouse in order
House in order
 
Managing A Start Up And Ethics M5
Managing A Start Up And Ethics M5Managing A Start Up And Ethics M5
Managing A Start Up And Ethics M5
 

Semelhante a Chapter 02

Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialscesarmendez78
 
Java chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsJava chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsMukesh Tekwani
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basicsvamshimahi
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming pptNitesh Dubey
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...AnkurSingh340457
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to JavaDevaKumari Vijay
 
Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1javatrainingonline
 
Reverse Engineering: Protecting and Breaking the Software (Workshop)
Reverse Engineering: Protecting and Breaking the Software (Workshop)Reverse Engineering: Protecting and Breaking the Software (Workshop)
Reverse Engineering: Protecting and Breaking the Software (Workshop)Satria Ady Pradana
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.pptTigistTilahun1
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 

Semelhante a Chapter 02 (20)

Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
 
Java chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsJava chapter 3 - OOPs concepts
Java chapter 3 - OOPs concepts
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basics
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming ppt
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
What is design pattern
What is design patternWhat is design pattern
What is design pattern
 
Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1
 
Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1
 
Reverse Engineering: Protecting and Breaking the Software (Workshop)
Reverse Engineering: Protecting and Breaking the Software (Workshop)Reverse Engineering: Protecting and Breaking the Software (Workshop)
Reverse Engineering: Protecting and Breaking the Software (Workshop)
 
Presentation5
Presentation5Presentation5
Presentation5
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
 
Class 1
Class 1Class 1
Class 1
 
Class 1
Class 1Class 1
Class 1
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
01slide
01slide01slide
01slide
 
Java notes
Java notesJava notes
Java notes
 

Mais de Graham Royce (20)

Chapter 18
Chapter 18Chapter 18
Chapter 18
 
Chapter 17
Chapter 17Chapter 17
Chapter 17
 
Chapter 16
Chapter 16Chapter 16
Chapter 16
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Chapter 08
Chapter 08Chapter 08
Chapter 08
 
Chapter 07
Chapter 07Chapter 07
Chapter 07
 
Chapter 05
Chapter 05Chapter 05
Chapter 05
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 
13 java in oracle
13 java in oracle13 java in oracle
13 java in oracle
 
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
 
My 3 min pitch pack
My 3 min pitch packMy 3 min pitch pack
My 3 min pitch pack
 
Things to do
Things to doThings to do
Things to do
 
Blank 10 all you need
Blank 10 all you needBlank 10 all you need
Blank 10 all you need
 
Goals
GoalsGoals
Goals
 
New frontiers motivation
New frontiers motivationNew frontiers motivation
New frontiers motivation
 
The only slides you need
The only slides you needThe only slides you need
The only slides you need
 

Último

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Chapter 02

  • 2. 2 ProgramConcepts Modern object-oriented programs help us build models to manage the complexity found in a problem domain. The problem domain describes real-world objects and concepts that a computer program is trying to solve.
  • 3. 2 Models A model is a simplification of a complex system. A good model: Helps to identify the most important aspects of a problem. Helps a programmer to focus on the problem he or she is trying to solve instead of on the complexity of the problem’s data.
  • 4. 2 What is a metaphor? A metaphor is a word or phrase used in place of another word or phrase to denote a likeness. Computer programs use “metaphors” to represent real objects.
  • 5. 2 Objects Objects represent real-world things: Ship Rudder Wheel Instruments Objects have: properties (characteristics) methods (behaviors)
  • 6. 2 Classes and Objects A class is a definition of a type: Like a template, a class defines the characteristics and behaviors of the type. An object is an instance of a class: Can be instantiated and manipulated An object’s characteristics are defined by the class that was used to create the object.
  • 7. 2 Fields Fields define the properties of a class. Can be intrinsic types (int, boolean…) Can be user-defined objects State is the current value of a field in an object.
  • 8. 2 Methods Methods describe the capabilities of the class. Every method must be called from another method. The only exception is main(), which is called by the OS. Methods can accept parameters.
  • 9. 2 Object Relationships Association A method of one object calls the method of another object. Composition Some objects are composed of other objects.
  • 10. 2 Specialization Hierarchies of classes move from a generalized class to a more specific class.
  • 11. 2 Creating Programs Syntax and Semantics A language’s exact keywords, punctuation, and order of terms are called its syntax. Semantics refers to the meaning of one’s instructions; what the program is trying to accomplish.
  • 12. 2 Writing a Java Program Writing a Java program requires five steps: Analyze Design Write Compile Test
  • 13. 2 Compiling the Code Programs must be compiled in order for the CPU to understand and execute the instructions. Java byte code is run through the Java Virtual Machine (JVM), which translates the code for the CPU. .java files are compiled by the javac (java compiler) program into .class files.
  • 14. 2 Types of Java Programs Applet Requires an .HTML file with the <applet> tag to reference the .class file Can also be run using the appletviewer.exe program file Application Run by the java.exe program file Run without a browser interface, often using the console window
  • 15. 2 HelloWorld.java Analysis The keyword import allows existing class libraries to be reused. The keyword public signifies that a class is visible to other classes. Braces {} indicate the beginning and end of a block of code. Braces must always be “balanced” Align opening and closing braces
  • 16. 2 More HelloWorld.java Analysis The keyword void signifies that a method does not return a value. Identifiers are the names given to classes, fields, and methods. Identifiers are case sensitive. Identifiers often use camel case notation.