Chapter 1�Introduction
Java Software Solutions
Foundations of Program Design
9th Edition
Copyright © 2017 Pearson Education, Inc.
John Lewis
William Loftus
Focus of the Course
Copyright © 2017 Pearson Education, Inc.
Introduction
Copyright © 2017 Pearson Education, Inc.
Outline
Copyright © 2017 Pearson Education, Inc.
Computer Processing
Hardware Components
Networks
The Java Programming Language
Program Development
Object-Oriented Programming
Hardware and Software
Copyright © 2017 Pearson Education, Inc.
CPU and Main Memory
Copyright © 2017 Pearson Education, Inc.
Central
Processing
Unit
Main
Memory
Chip that executes program commands
Primary storage area for programs and data that are in active use
Synonymous with RAM
Input / Output Devices
Copyright © 2017 Pearson Education, Inc.
Central
Processing
Unit
Main
Memory
Monitor screen
Keyboard
Mouse
Touch screen
I/O devices facilitate
user interaction
Secondary Memory Devices
Copyright © 2017 Pearson Education, Inc.
Central
Processing
Unit
Main
Memory
Information is moved
between main and
secondary memory
as needed
Hard Disk
USB Flash Drive
Secondary memory
devices provide
long-term storage
Software Categories
Copyright © 2017 Pearson Education, Inc.
Analog vs. Digital
Copyright © 2017 Pearson Education, Inc.
Analog Information
Copyright © 2017 Pearson Education, Inc.
Sampling
Copyright © 2017 Pearson Education, Inc.
Digital Information
Copyright © 2017 Pearson Education, Inc.
Representing Text Digitally
Copyright © 2017 Pearson Education, Inc.
H i , H e a t h e r .
72 105 44 32 72 101 97 116 104 101 114 46
Binary Numbers
Copyright © 2017 Pearson Education, Inc.
Bit Permutations
Copyright © 2017 Pearson Education, Inc.
1 bit
0
1
2 bits
00
01
10
11
3 bits
000
001
010
011
100
101
110
111
4 bits
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Each additional bit doubles the number of possible permutations
Bit Permutations
Copyright © 2017 Pearson Education, Inc.
21 = 2 items
22 = 4 items
23 = 8 items
24 = 16 items
25 = 32 items
1 bit ?
2 bits ?
3 bits ?
4 bits ?
5 bits ?
How many
items can be
represented by
Quick Check
Copyright © 2017 Pearson Education, Inc.
How many bits would you need to represent each of the 50 United States using a unique permutation of bits?
Quick Check
Copyright © 2017 Pearson Education, Inc.
How many bits would you need to represent each of the 50 United States using a unique permutation of bits?
Five bits wouldn't be enough, because 25 is 32.
Six bits would give us 64 permutations, and some wouldn't be used.
000000 Alabama
000001 Alaska
000010 Arizona
000011 Arkansas
000100 California
000101 Colorado
etc.
Outline
Copyright © 2017 Pearson Education, Inc.
Computer Processing
Hardware Components
Networks
The Java Programming Language
Program Development
Object-Oriented Programming
A Computer Specification
Copyright © 2017 Pearson Education, Inc.
Computer Architecture
Copyright © 2017 Pearson Education, Inc.
Memory
Copyright © 2017 Pearson Education, Inc.
Main memory is divided into many memory locations (or cells)
9278
9279
9280
9281
9282
9283
9284
9285
9286
Each memory cell has a numeric address, which uniquely identifies it
Storing Information
Copyright © 2017 Pearson Education, Inc.
9278
9279
9280
9281
9282
9283
9284
9285
9286
Large values are
stored in consecutive
memory locations
10011010
Each memory cell stores a set number of bits (usually 8 bits, or one byte)
Storage Capacity
Copyright © 2017 Pearson Education, Inc.
Unit | Symbol | Number of Bytes |
kilobyte | KB | 210 = 1024 |
megabyte | MB | 220 (over one million) |
gigabyte | GB | 230 (over one billion) |
terabyte | TB | 240 (over one trillion) |
petabyte | PB | 250 (a whole bunch) |
Memory
Copyright © 2017 Pearson Education, Inc.
Hard Disk Drive
Copyright © 2017 Pearson Education, Inc.
RAM vs. ROM
Copyright © 2017 Pearson Education, Inc.
Compact Discs
Copyright © 2017 Pearson Education, Inc.
DVDs
Copyright © 2017 Pearson Education, Inc.
The Central Processing Unit
Copyright © 2017 Pearson Education, Inc.
fetch
Retrieve an instruction from main memory
decode
Determine what the
instruction is
execute
Carry out the
instruction
The Central Processing Unit
Copyright © 2017 Pearson Education, Inc.
Arithmetic / Logic Unit
Registers
Control Unit
Small storage areas
Performs calculations and makes decisions
Coordinates processing steps
The Central Processing Unit
Copyright © 2017 Pearson Education, Inc.
Monitor
Copyright © 2017 Pearson Education, Inc.
Outline
Copyright © 2017 Pearson Education, Inc.
Computer Processing
Hardware Components
Networks
The Java Programming Language
Program Development
Object-Oriented Programming
Networks
Copyright © 2017 Pearson Education, Inc.
Network Connections
Copyright © 2017 Pearson Education, Inc.
This technique is not practical for
more than a few close machines
Adding a computer requires
a new communication line
for each computer already
in the network
Network Connections
Copyright © 2017 Pearson Education, Inc.
Network traffic must take
turns using the line, which
introduces delays
Often information is broken
down in parts, called packets,
which are sent to the receiving
machine and then reassembled
A Computer Network
Copyright © 2017 Pearson Education, Inc.
Local-Area Networks
Copyright © 2017 Pearson Education, Inc.
LAN
A Local-Area Network
(LAN) covers a small
distance and a small
number of computers
A LAN often connects the machines
in a single room or building
Wide-Area Networks
Copyright © 2017 Pearson Education, Inc.
LAN
A Wide-Area Network (WAN)
connects two or more LANs,
often over long distances
LAN
The Internet
Copyright © 2017 Pearson Education, Inc.
TCP/IP
Copyright © 2017 Pearson Education, Inc.
IP and Internet Addresses
204.192.116.2
hector.vt.edu
Copyright © 2017 Pearson Education, Inc.
Domain Names
Copyright © 2017 Pearson Education, Inc.
edu educational institution
com commercial entity
org non-profit organization
net network-based organization
Sometimes the suffix
indicates the country:
uk United Kingdom
au Australia
ca Canada
se Sweden
Additional TLDs have
been added, including:
biz, info, tv, name
Domain Names
Copyright © 2017 Pearson Education, Inc.
The World Wide Web
Copyright © 2017 Pearson Education, Inc.
The World Wide Web
http://www.google.com
http://www.whitehouse.gov/issues/education
Copyright © 2017 Pearson Education, Inc.
Outline
Copyright © 2017 Pearson Education, Inc.
Computer Processing
Hardware Components
Networks
The Java Programming Language
Program Development
Object-Oriented Programming
Java
Copyright © 2017 Pearson Education, Inc.
Java Program Structure
Copyright © 2017 Pearson Education, Inc.
Copyright © 2017 Pearson Education, Inc.
//********************************************************************
// Lincoln.java Author: Lewis/Loftus
//
// Demonstrates the basic structure of a Java application.
//********************************************************************
public class Lincoln
{
//-----------------------------------------------------------------
// Prints a presidential quote.
//-----------------------------------------------------------------
public static void main(String[] args)
{
System.out.println("A quote by Abraham Lincoln:");
System.out.println("Whatever you are, be a good one.");
}
}
Copyright © 2017 Pearson Education, Inc.
//********************************************************************
// Lincoln.java Author: Lewis/Loftus
//
// Demonstrates the basic structure of a Java application.
//********************************************************************
public class Lincoln
{
//-----------------------------------------------------------------
// Prints a presidential quote.
//-----------------------------------------------------------------
public static void main(String[] args)
{
System.out.println("A quote by Abraham Lincoln:");
System.out.println("Whatever you are, be a good one.");
}
}
Output
A quote by Abraham Lincoln:
Whatever you are, be a good one.
Java Program Structure
Copyright © 2017 Pearson Education, Inc.
public class MyProgram
{
}
// comments about the class
class header
class body
Comments can be placed almost anywhere
Java Program Structure
Copyright © 2017 Pearson Education, Inc.
public class MyProgram
{
}
// comments about the class
public static void main (String[] args)
{
}
// comments about the method
method header
method body
Comments
Copyright © 2017 Pearson Education, Inc.
// this comment runs to the end of the line
/* this comment runs to the terminating
symbol, even across line breaks */
/** this is a javadoc comment */
Identifiers
Copyright © 2017 Pearson Education, Inc.
Identifiers
Copyright © 2017 Pearson Education, Inc.
Reserved Words
Copyright © 2017 Pearson Education, Inc.
abstract
assert
boolean
break
byte
case
catch
char
class
const
continue
default
do
double
else
enum
extends
false
final
finally
float
for
goto
if
implements
import
instanceof
int
interface
long
native
new
null
package
private
protected
public
return
short
static
strictfp
super
switch
synchronized
this
throw
throws
transient
true
try
void
volatile
while
Quick Check
Copyright © 2017 Pearson Education, Inc.
Which of the following are valid Java identifiers?
grade
quizGrade
NetworkConnection
frame2
3rdTestScore
MAXIMUM
MIN_CAPACITY
student#
Shelves1&2
Quick Check
Copyright © 2017 Pearson Education, Inc.
Which of the following are valid Java identifiers?
grade
quizGrade
NetworkConnection
frame2
3rdTestScore
MAXIMUM
MIN_CAPACITY
student#
Shelves1&2
Valid
Valid
Valid
Valid
Invalid – cannot begin with a digit
Valid
Valid
Invalid – cannot contain the '#' character
Invalid – cannot contain the '&' character
White Space
Copyright © 2017 Pearson Education, Inc.
Outline
Copyright © 2017 Pearson Education, Inc.
Computer Processing
Hardware Components
Networks
The Java Programming Language
Program Development
Object-Oriented Programming
Program Development
Copyright © 2017 Pearson Education, Inc.
Language Levels
Copyright © 2017 Pearson Education, Inc.
Programming Languages
Copyright © 2017 Pearson Education, Inc.
Java Translation
Copyright © 2017 Pearson Education, Inc.
Java Translation
Copyright © 2017 Pearson Education, Inc.
Development Environments
Copyright © 2017 Pearson Education, Inc.
Syntax and Semantics
Copyright © 2017 Pearson Education, Inc.
Errors
Copyright © 2017 Pearson Education, Inc.
Basic Program Development
Copyright © 2017 Pearson Education, Inc.
errors?
errors?
Edit and
save program
Compile program
Execute program and
evaluate results
Outline
Copyright © 2017 Pearson Education, Inc.
Computer Processing
Hardware Components
Networks
The Java Programming Language
Program Development
Object-Oriented Programming
Problem Solving
Copyright © 2017 Pearson Education, Inc.
Problem Solving
Copyright © 2017 Pearson Education, Inc.
Object-Oriented Programming
Copyright © 2017 Pearson Education, Inc.
Objects
Copyright © 2017 Pearson Education, Inc.
Classes
Copyright © 2017 Pearson Education, Inc.
Class = Blueprint
Copyright © 2017 Pearson Education, Inc.
Objects and Classes
Copyright © 2017 Pearson Education, Inc.
Bank Account
A class
(the concept)
John’s Bank Account
Balance: $5,257
An object
(the realization)
Bill’s Bank Account
Balance: $1,245,069
Mary’s Bank Account
Balance: $16,833
Multiple objects
from the same class
Inheritance
Copyright © 2017 Pearson Education, Inc.
Bank Account
Account
Charge Account
Savings Account
Checking Account
Summary
Copyright © 2017 Pearson Education, Inc.