Chapter 1 Java Csc60a
Chapter 1 Java Csc60a
Creating
Java Programs
Objectives
• Define basic programming terminology
• Compare procedural and object-oriented
programming
• Describe the features of the Java programming
language
• Analyze a Java application that produces console
output
• RESOURCES:
– https://www.jdoodle.com/online-java-compiler
– https://www.codiva.io/#
– http://www.crunchytricks.com/2016/07/offline-java-compilers.html
Java Programming, Eighth Edition 3
Think … Java
13
Comparing Procedural and Object-Oriented
Programming Concepts
• Object-oriented programming was used most frequently for
two major types of applications
– Computer simulations
– Graphical user interfaces (GUIs)
• Not all object-oriented programs are written to use a GUI
• Object-oriented programming differs from traditional
procedural programming
• Polymorphism
• Inheritance
• Encapsulation
• Method
– A self-contained block of program code that carries out an
action
– Similar to a procedure
• Encapsulation
– Conceals internal values and methods from outside sources.
• Concealing data is sometimes called information hiding, and concealing
how methods work is implementation hiding
– Provides security
– Keeps data and methods safe from inadvertent
(unintended) changes 19
1.2 Understanding Inheritance and
Polymorphism
• Inheritance
– An important feature of object-oriented programs
– Classes share attributes and methods of existing classes
but with more specific features
– Helps you understand real-world objects
• Polymorphism
– Means literally “many forms”
– Allows the same word to be interpreted correctly in
different situations based on context
Method
Requires information to
perform its task Literal string
Will appear in output exactly as
entered
Written between double quotation
marks
Java Programming, Eighth Edition 30
Java Programming, Eighth Edition 31
How to Build Java Program