Starting Out With Java: 7 Edition
Starting Out With Java: 7 Edition
Starting Out With Java: 7 Edition
7th Edition
Chapter 1
Introduction to Computers
and Java
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Chapter Topics
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Java History
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Introduction
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Java Applications and Applets
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Why Program? (1 of 3)
• Computers are tools that can be programmed to
perform many functions, such as:
• spreadsheets • games
• databases • etc.
• word processing
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Why Program? (2 of 3)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Why Program? (3 of 3)
• Programs must be analytically correct as well.
• Programs rarely work the first time they are
programmed.
• Programmers must perform the following on a continual
basis:
– analyze,
– experiment,
– correct, and
– redesign.
• Programming languages have strict rules, known as
syntax, that must be carefully followed.
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware (1 of 2)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware (2 of 2)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
Central Processing Unit (1 of 2)
CPU
Arithmetic
Logic
Unit
Instruction (input) Result (output)
Control
Unit
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
Central Processing Unit (2 of 2)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
Main Memory (1 of 3)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
Main Memory (2 of 3)
1 1 1 1
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
Main Memory (3 of 3)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
Secondary Storage Devices
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
Input Devices
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
Output Devices
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Software
Operating Systems (1 of 2)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Computer Systems: Software
Operating Systems (2 of 2)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages (2 of 5)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages (3 of 5)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages (4 of 5)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages (5 of 5)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages
Common Language Elements
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages
Sample Program (1 of 2)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages
Sample Program (2 of 2)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages
Lines vs Statements
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages
Variables (1 of 3)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages
Variables (2 of 3)
0x000
0x001
0x002
0x003
0x004
0x005
0x006
0x007
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Programming Languages
Variables (3 of 3)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
The Compiler and the Java Virtual
Machine (1 of 4)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
The Compiler and the Java Virtual
Machine (2 of 4)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
The Compiler and the Java Virtual
Machine (3 of 4)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
The Compiler and the Java Virtual
Machine (4 of 4)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Portability (1 of 3)
• Portable means that a program may be written on one
type of computer and then run on a wide variety of
computers, with little or no modification.
• Java byte code runs on the JVM and not on any
particular CPU; therefore, compiled Java programs are
highly portable.
• JVMs exist on many platforms:
• Windows • Unix
• Mac • BSD
• Linux • Etc.
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Portability (2 of 3)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Portability (3 of 3)
Byte code
(.class)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Java Versions
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Compiling a Java Program
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
The Programming Process (2 of 2)
5. Enter the code and compile it.
6. Correct any errors found during compilation.
Repeat Steps 5 and 6 as many times as necessary.
7. Run the program with test data for input.
8. Correct any runtime errors found while running the
program.
Repeat Steps 5 through 8 as many times as
necessary.
9. Validate the results of the program.
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Software Engineering (1 of 3)
• Encompasses the whole process of crafting
computer software.
• Software engineers perform several tasks in
the development of complex software projects.
– designing,
– writing,
– testing,
– debugging,
– documenting,
– modifying, and
– maintaining.
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Software Engineering (2 of 3)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Software Engineering (3 of 3)
Data Element
Procedure A Procedure B
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Procedural Programming (3 of 3)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Object-Oriented Programming (1 of 4)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Object-Oriented Programming (2 of 4)
Object
Attributes (data)
Methods
(behaviors / procedures)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Object-Oriented Programming (3 of 4)
• Object-oriented programming combines data and
behavior via encapsulation.
• Data hiding is the ability of an object to hide data from
other objects in the program.
• Only an objects methods should be able to directly
manipulate its attributes.
• Other objects are allowed manipulate an object’s
attributes via the object’s methods.
• This indirect access is known as a programming
interface.
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Object-Oriented Programming (4 of 4)
Object
Attributes (data)
Programming typically private to this object
Interface
Other
objects
Methods
(behaviors / procedures)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Copyright
This work is protected by United States copyright laws and is provided solely
for the use of instructions in teaching their courses and assessing student
learning. dissemination or sale of any part of this work (including on the
World Wide Web) will destroy the integrity of the work and is not permit-
ted. The work and materials from it should never be made available to
students except by instructors using the accompanying text in their
classes. All recipients of this work are expected to abide by these
restrictions and to honor the intended pedagogical purposes and the needs of
other instructors who rely on these materials.
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved