Professional Documents
Culture Documents
Introduction To Computers and Java
Introduction To Computers and Java
Introduction To Computers and Java
Fifth Edition
by Tony Gaddis
Chapter Topics
– Java History
– Programming Languages
– The Complete Programming Process
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-2
Java History
• Created by Sun Microsystems in 1991
• Green Team – handheld controller *7 for multiple
entertainment systems
• There was a need for a programming language that
would run on various devices.
• Java (first named Oak) was developed for this purpose.
• Java is “cross platform”, meaning that it can run on
various computer operating systems.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-3
Java Applications and Applets
• Java programs can be of two types:
– Applications
• Stand-alone programs that run without the aid of a web
browser.
• Relaxed security model since the user runs the program
locally.
– Applets
• Small applications that require the use of a Java enabled
web browser to run.
• Enhanced security model since the user merely goes to a
web page and the applet runs itself.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-4
Programming Languages
• A programming language is a special language used to
write computer programs.
• A program is a set of instructions with rigorous syntax
a computer follows in order to perform a task.
• An algorithm is a set of well defined steps to complete
a task.
– English-like pseudo code
– For example, to compute gross pay
• Get payroll data
• Calculate gross pay
• Display gross pay
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-5
Programming Languages: 1GL
• A computer needs the algorithm to be written in machine
language (also called first generation programming language).
– Machine language is written using binary numbers.
• Each CPU has its own machine language.
– Motorola 68000 series processors
– Intel x86 series processors
– ARM processors, etc.
• Example of a machine language instruction:
1011010000000101
• Machine code is tedious and unfriendly to human.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-6
Programming Languages: 2GL
• Programmers developed assembly language (also called
second generation programming language or low level
language).
• Example:
MOV id3, R2
MUL #60.0, R2
MOV id2, R1
ADD R2, R1
MOV R1, id1
• Assembler made things easier but was also processor
dependent.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-7
Programming Languages: 3GL
• High level programming languages followed
that were not processor dependent.
• Some common programming languages:
Java C Visual Basic
BASIC C++ Python
COBOL C# Ruby
Pascal PHP JavaScript
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-8
Programming Languages
• 4GL and 5GL
– Closer to natural languages
– The language environment provides visual
programming tools that allow non-programmers to
create software applications
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-9
Programming Languages
Common Language Elements
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-10
Programming Languages
Sample Program
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-11
Programming Languages
Sample Program
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-12
Programming Languages
Lines vs Statements
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-13
Programming Languages
Variables
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-14
Programming Languages
Variables
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-15
Programming Languages
Variables
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-16
The Compiler and the Java Virtual Machine
• A programmer writes Java statements for a
program. These statements are known as
source code.
• A text editor is used to edit and save a Java
source code file.
– Source code files have a .java file extension.
• A compiler is a program that translates
source code into an object code.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-17
The Compiler and the Java Virtual Machine
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-18
The Compiler and the Java Virtual Machine
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-19
The Compiler and the Java Virtual Machine
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-20
Program Development Process
Saves Java statements
Text editor Source code
(.java)
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-21
The Complete Programming Process
1. Understand problem statement.
2. Design algorithms.
3. Enter the code and compile it.
4. Correct any syntax errors found during compilation.
Repeat Steps 3 and 4 as many times as necessary.
5. Run the program with test data for input.
6. Correct any runtime errors found while running the
program.
Repeat Steps 3 through 6 as many times as necessary.
7. Validate the results of the program.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-22