SlideShare a Scribd company logo
1 of 57
CHAPTER
1
Introduction
to Computers
and Java
Copyright © 2016 Pearson Education, Inc., Hoboken NJ
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-2
Chapter Topics
Chapter 1 discusses the following main topics:
– Introduction
– Why Program?
– Computer Systems: Hardware and Software
– Programming Languages
– What Is a Program Made Of?
– The Programming Process
– Object-Oriented Programming
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-3
Java History
• 1991 - Green Team started by Sun
Microsystems (now owned by Oracle).
• *7 Handheld controller 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.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-4
Introduction
• Java enabled web browser (HotJava)
demonstrated at 1995 Sun World conference.
• Java incorporated into Netscape shortly after.
• Java is “cross platform”, meaning that it can
run on various computer operating systems.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-5
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.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-6
Why Program?
• Computers are tools that can be programmed to
perform many functions, such as:
• Computers are versatile because they can be
programmed.
• Computer Programmers implement programs
that perform these functions.
• spreadsheets
• databases
• word processing
• games
• etc.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-7
Why Program?
Aspects of a computer program that must be designed:
– The logical flow of the instructions
– The mathematical procedures
– The layout of the programming statements
– The appearance of the screens
– The way information is presented to the user
– The program’s “user friendliness”
– Manuals, help systems, and/or other forms of written
documentation.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-8
Why Program?
• 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.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-9
Computer Systems: Hardware
• Computer hardware components are the
physical pieces of the computer.
• The major hardware components of a computer
are:
– The central processing unit (CPU)
– Main memory
– Secondary storage devices
– Input and Output devices
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-10
Computer Systems: Hardware
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-11
Computer Systems: Hardware
Central Processing Unit
Instruction (input) Result (output)
Arithmetic
Logic
Unit
Control
Unit
CPU
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-12
Computer Systems: Hardware
Central Processing Unit
– The CPU performs the fetch, decode, execute cycle
in order to process program information.
Fetch
The CPU’s control unit fetches, from main memory,
the next instruction in the sequence of program instructions.
Decode
The instruction is encoded in the form of a number.
The control unit decodes the instruction and
generates an electronic signal.
Execute
The signal is routed to the appropriate component
of the computer (such as the ALU, a disk drive, or
some other device). The signal causes the
component to perform an operation.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-13
Computer Systems: Hardware
Main Memory
• Commonly known as random-access memory
(RAM)
• RAM contains:
– currently running programs
– data used by those programs.
• RAM is divided into units called bytes.
• A byte consists of eight bits that may be either
on or off.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-14
Computer Systems: Hardware
Main Memory
• A bit is either on or off:
– 1 = on
– 0 = off
• The bits form a pattern that represents a character or a
number.
• Each byte in memory is assigned a unique number
known as an address.
• RAM is volatile, which means that when the computer
is turned off, the contents of RAM are erased.
1 1 1 1
0 0 0 0
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-15
Computer Systems: Hardware
Main Memory
A section of memory is called a byte.
A section of two or four bytes is
often called a word.
Main memory can be visualized as a column or row of cells.
0x000
0x001
0x003
0x002
0x004
0x005
0x006
0x007
A byte is made up of 8 bits.1 0 1 0 1 0 1 0
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-16
Computer Systems: Hardware
Secondary Storage Devices
• Secondary storage devices are capable of
storing information for longer periods of time
(non-volatile).
• Common Secondary Storage devices:
• Disk drive
• External drive
• CD drive
• Solid state drive
• USB drive
• DVD drive
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-17
Computer Systems: Hardware
Input Devices
• Input is any data the computer collects from the
outside world.
• That data comes from devices known as input
devices.
• Common input devices:
– Keyboard
– Mouse
– Scanner
– Digital camera
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-18
Computer Systems: Hardware
Output Devices
• Output is any data the computer sends to the outside
world.
• That data is displayed on devices known as output
devices.
• Common output devices:
– Monitors
– Printers
• Some devices such as disk drives perform input and
output and are called I/O devices (input/output).
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-19
Computer Systems: Software
• Software refers to the programs that run on a
computer.
• There are two classifications of software:
– Operating Systems
– Application Software
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-20
Computer Systems: Software
Operating Systems
• An operating system is a set of programs that
manages the computer’s hardware devices and
controls their processes.
• Most all modern operating systems are
multitasking.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-21
Computer Systems: Software
Operating Systems
• A multitasking operating system is capable of running
multiple programs at once.
– Unix
– Linux
– Mac OS
– Windows
• The technique is called time sharing.
• A multitasking system divides the allocation of
hardware resources and the attention of the CPU
among all the executing programs.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-22
Computer Systems: Software
Application Software
• Application software refers to programs that make the
computer useful to the user.
• Application software provides a more specialized type
of environment for the user to work in.
• Common application software:
– Spreadsheets
– Word processors
– Accounting software
– Tax software
– Games
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-23
Programming Languages
• A program is a set of instructions a computer follows
in order to perform a task.
• A programming language is a special language used to
write computer programs.
• A computer program is a set of instructions that enable
the computer to solve a problem or perform a task.
• Collectively, these instructions form an algorithm
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-24
Programming Languages
• An algorithm is a set of well defined steps to
completing a task.
• The steps in an algorithm are performed sequentially.
• A computer needs the algorithm to be written in
machine language.
• Machine language is written using binary numbers.
• The binary numbering system (base 2) only has two
digits (0 and 1).
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-25
Programming Languages
• The binary numbers are encoded as a machine
language.
• 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
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-26
Programming Languages
• In the distant past, programmers wrote
programs in machine language.
• Programmers developed higher level
programming languages to make things easier.
• The first of these was assembler.
• Assembler made things easier but was also
processor dependent.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-27
Programming Languages
• High level programming languages followed
that were not processor dependent.
• Some common programming languages:
Java
BASIC C++
C
Python
COBOL
JavaScript
Ruby
PHP
C#
Visual Basic
Pascal
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-28
Programming Languages
Common Language Elements
• There are some concepts that are common to
virtually all programming languages.
• Common concepts:
– Key words
– Operators
– Punctuation
– Programmer-defined identifiers
– Strict syntactic rules.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-29
Programming Languages
Sample Program
public class HelloWorld
{
public static void main(String[] args)
{
String message = "Hello World";
System.out.println(message);
}
}
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-30
Programming Languages
Sample Program
• Key words in the sample program are:
• Key words are lower case (Java is a case
sensitive language).
• Key words cannot be used as a programmer-
defined identifier.
•public
•class
•static
•void
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-31
Programming Languages
• Semi-colons are used to end Java statements;
however, not all lines of a Java program end a
statement.
• Part of learning Java is to learn where to
properly use the punctuation.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-32
Programming Languages
Lines vs Statements
• There are differences between lines and
statements when discussing source code.
System.out.println(
message);
• This is one Java statement written using two
lines. Do you see the difference?
• A statement is a complete Java instruction that
causes the computer to perform an action.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-33
Programming Languages
Variables
• Data in a Java program is stored in memory.
• Variable names represent a location in memory.
• Variables in Java are sometimes called fields.
• Variables are created by the programmer who assigns
it a programmer-defined identifier.
example: int hours = 40;
• In this example, the variable hours is created as an
integer (more on this later) and assigned the value of
40.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-34
Programming Languages
Variables
• Variables are simply a name given to represent
a place in memory.
0x000
0x001
0x002
0x003
0x004
0x005
0x006
0x007
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-35
Programming Languages
Variables
0x000
0x001
0x002
0x003
0x004
0x005
0x006
0x007
The Java Virtual
Machine (JVM)
actually decides
where the value
will be placed
in memory.
72
Assume that the this
variable declaration
has been made.
int length = 72;
The variable length
is a symbolic name
for the memory
location 0x003.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-36
The Compiler and the Java Virtual
Machine
• A programmer writes Java programming
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 executable form.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-37
The Compiler and the Java Virtual
Machine
• A compiler is run using a source code file as
input.
• Syntax errors that may be in the program will
be discovered during compilation.
• Syntax errors are mistakes that the programmer
has made that violate the rules of the
programming language.
• The compiler creates another file that holds the
translated instructions.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-38
The Compiler and the Java Virtual
Machine
• Most compilers translate source code into
executable files containing machine code.
• The Java compiler translates a Java source file
into a file that contains byte code instructions.
• Byte code instructions are the machine
language of the Java Virtual Machine (JVM)
and cannot be directly executed directly by the
CPU.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-39
The Compiler and the Java Virtual
Machine
• Byte code files end with the .class file
extension.
• The JVM is a program that emulates a micro-
processor.
• The JVM executes instructions as they are read.
• JVM is often called an interpreter.
• Java is often referred to as an interpreted
language.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-40
Program Development Process
Text editor Source code
(.java)
Saves Java statements
Java compiler
Is read by
Byte code
(.class)
Produces
Java
Virtual
Machine
Is interpreted by
Program
Execution
Results in
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-41
Portability
• 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:
•Unix
•BSD
•Etc.
•Windows
•Mac
•Linux
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-42
Portability
• With most programming languages, portability
is achieved by compiling a program for each
CPU it will run on.
• Java provides an JVM for each platform so that
programmers do not have to recompile for
different platforms.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-43
Portability
Java Virtual
Machine for Windows
Byte code
(.class)
Java Virtual
Machine for Linux
Java Virtual
Machine for Mac
Java Virtual
Machine for Unix
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-44
Java Versions
• The software you use to write Java programs is
called the Java Development Kit, or JDK.
• There are different editions of the JDK:
– Java SE - Java2 Standard Edition.
– Java EE - Java2 Enterprise Edition.
– Java ME - Java2 Micro Edition.
• Available for download at
http://java.oracle.com
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-45
Compiling a Java Program
• The Java compiler is a command line utility.
• The command to compile a program is:
java filename.java
• javac is the Java compiler.
• The .java file extension must be used.
Example: To compile a java source code file named
Payroll.java you would use the command:
javac Payroll.java
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-46
The Programming Process
1. Clearly define what the program is to do.
2. Visualize the program running on the computer.
3. Use design tools to create a model of the program.
4. Check the model for logical errors.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-47
The Programming Process
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.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-48
Software Engineering
• 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.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-49
Software Engineering
• Software engineers develop:
– program specifications,
– diagrams of screen output,
– diagrams representing the program components and
the flow of data,
– pseudocode,
– examples of expected input and desired output.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-50
Software Engineering
• Software engineers also use special software designed
for testing programs.
• Most commercial software applications are large and
complex.
• Usually a team of programmers, not a single
individual, develops them.
• Program requirements are thoroughly analyzed and
divided into subtasks that are handled by
– individual teams
– individuals within a team.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-51
Procedural Programming
• Older programming languages were procedural.
• A procedure is a set of programming language
statements that, together, perform a specific
task.
• Procedures typically operate on data items that
are separate from the procedures.
• In a procedural program, the data items are
commonly passed from one procedure to
another.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-52
Procedural Programming
Procedure A
Data Element
Procedure B
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-53
Procedural Programming
• In procedural programming, procedures are
developed to operate on the program’s data.
• Data in the program tends to be global to the
entire program.
• Data formats might change and thus, the
procedures that operate on that data must
change.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-54
Object-Oriented Programming
• Object-oriented programming is centered on
creating objects rather than procedures.
• Objects are a melding of data and procedures
that manipulate that data.
• Data in an object are known as attributes.
• Procedures in an object are known as methods.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-55
Object-Oriented Programming
Object
Attributes (data)
Methods
(behaviors / procedures)
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-56
Object-Oriented Programming
• 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.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-57
Object-Oriented Programming
Object
Attributes (data)
typically private to this object
Methods
(behaviors / procedures)
Other
objects
Programming
Interface

More Related Content

What's hot

Computer generation and classification
Computer generation and classificationComputer generation and classification
Computer generation and classificationBaliThorat1
 
fundamental of computer-u-1-computer hardware system
fundamental of  computer-u-1-computer hardware systemfundamental of  computer-u-1-computer hardware system
fundamental of computer-u-1-computer hardware systemRai University
 
Bba i-introduction to computer-u-2- application and system software
Bba  i-introduction to computer-u-2- application and system softwareBba  i-introduction to computer-u-2- application and system software
Bba i-introduction to computer-u-2- application and system softwareRai University
 
1 fundamentals of computer
1 fundamentals of computer1 fundamentals of computer
1 fundamentals of computerBaliThorat1
 
Computer Organization and Design
Computer Organization and DesignComputer Organization and Design
Computer Organization and DesignRa'Fat Al-Msie'deen
 
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 5 - System ...
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 5 - System ...Understanding Computers: Today and Tomorrow, 13th Edition Chapter 5 - System ...
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 5 - System ...yaminohime
 
6 input output devices
6 input output devices6 input output devices
6 input output devicesBaliThorat1
 
8 operating system concept
8 operating system concept8 operating system concept
8 operating system conceptBaliThorat1
 
A walk through the computer system
A walk through the computer systemA walk through the computer system
A walk through the computer systemfaiqikhan
 
Introduction to Computer and Programming - Lecture 01
Introduction to Computer and Programming - Lecture 01Introduction to Computer and Programming - Lecture 01
Introduction to Computer and Programming - Lecture 01hassaanciit
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem SolvingSukhendra Singh
 
FoeduMed: Hardware and Software 40_16
FoeduMed: Hardware and Software 40_16FoeduMed: Hardware and Software 40_16
FoeduMed: Hardware and Software 40_16Majid Ali
 
Foedu med hardware and sowftware 40 16
Foedu med hardware and sowftware 40 16Foedu med hardware and sowftware 40 16
Foedu med hardware and sowftware 40 16Majid Ali
 
Co module1a introdctnaddressingmodes
Co module1a introdctnaddressingmodesCo module1a introdctnaddressingmodes
Co module1a introdctnaddressingmodesManu Jose
 

What's hot (20)

what is Operating system
what is Operating systemwhat is Operating system
what is Operating system
 
Ch01
Ch01Ch01
Ch01
 
Computer generation and classification
Computer generation and classificationComputer generation and classification
Computer generation and classification
 
I.T for Management: What is a computer and how does it work
I.T for Management: What is a computer and how does it work I.T for Management: What is a computer and how does it work
I.T for Management: What is a computer and how does it work
 
fundamental of computer-u-1-computer hardware system
fundamental of  computer-u-1-computer hardware systemfundamental of  computer-u-1-computer hardware system
fundamental of computer-u-1-computer hardware system
 
Bba i-introduction to computer-u-2- application and system software
Bba  i-introduction to computer-u-2- application and system softwareBba  i-introduction to computer-u-2- application and system software
Bba i-introduction to computer-u-2- application and system software
 
Chapter3
Chapter3Chapter3
Chapter3
 
1 fundamentals of computer
1 fundamentals of computer1 fundamentals of computer
1 fundamentals of computer
 
Computer Organization and Design
Computer Organization and DesignComputer Organization and Design
Computer Organization and Design
 
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 5 - System ...
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 5 - System ...Understanding Computers: Today and Tomorrow, 13th Edition Chapter 5 - System ...
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 5 - System ...
 
Fcp lecture 01
Fcp lecture 01Fcp lecture 01
Fcp lecture 01
 
6 input output devices
6 input output devices6 input output devices
6 input output devices
 
8 operating system concept
8 operating system concept8 operating system concept
8 operating system concept
 
A walk through the computer system
A walk through the computer systemA walk through the computer system
A walk through the computer system
 
2 software
2 software2 software
2 software
 
Introduction to Computer and Programming - Lecture 01
Introduction to Computer and Programming - Lecture 01Introduction to Computer and Programming - Lecture 01
Introduction to Computer and Programming - Lecture 01
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
FoeduMed: Hardware and Software 40_16
FoeduMed: Hardware and Software 40_16FoeduMed: Hardware and Software 40_16
FoeduMed: Hardware and Software 40_16
 
Foedu med hardware and sowftware 40 16
Foedu med hardware and sowftware 40 16Foedu med hardware and sowftware 40 16
Foedu med hardware and sowftware 40 16
 
Co module1a introdctnaddressingmodes
Co module1a introdctnaddressingmodesCo module1a introdctnaddressingmodes
Co module1a introdctnaddressingmodes
 

Similar to Introduction to Java and computers

Cso gaddis java_chapter1
Cso gaddis java_chapter1Cso gaddis java_chapter1
Cso gaddis java_chapter1mlrbrown
 
Foundation of information system - Software
Foundation of information system - SoftwareFoundation of information system - Software
Foundation of information system - Softwarerh8g7p44p7
 
Problem Solving and Program Design in C_1.pdf
Problem Solving and Program Design in C_1.pdfProblem Solving and Program Design in C_1.pdf
Problem Solving and Program Design in C_1.pdfjlu08167
 
Organization of modern digital computers
Organization of modern digital computersOrganization of modern digital computers
Organization of modern digital computersDrRamaPrasathAssista
 
Operating system 01 introduction
Operating system 01 introductionOperating system 01 introduction
Operating system 01 introductionVaibhav Khanna
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-IntroductionShipra Swati
 
Topic -Anatomy of Computer.pptx
Topic -Anatomy  of Computer.pptxTopic -Anatomy  of Computer.pptx
Topic -Anatomy of Computer.pptxPragatiKachhi1
 
Unit 1 computer concepts
Unit 1   computer conceptsUnit 1   computer concepts
Unit 1 computer conceptsMithun DSouza
 
HARDWARE AND SOFTWARE.pptx
HARDWARE AND SOFTWARE.pptxHARDWARE AND SOFTWARE.pptx
HARDWARE AND SOFTWARE.pptxKhushiSinghal52
 
Chapter 1 - Introduction to Operating System.pptx
Chapter 1 - Introduction to Operating System.pptxChapter 1 - Introduction to Operating System.pptx
Chapter 1 - Introduction to Operating System.pptxgowthamiv26
 
fdocuments.in_unit-2-foc.ppt
fdocuments.in_unit-2-foc.pptfdocuments.in_unit-2-foc.ppt
fdocuments.in_unit-2-foc.pptKrishanPalSingh39
 
Introduction to Computers Lecture # 11
Introduction to Computers Lecture # 11Introduction to Computers Lecture # 11
Introduction to Computers Lecture # 11Sehrish Rafiq
 

Similar to Introduction to Java and computers (20)

Week 01.pdf
Week 01.pdfWeek 01.pdf
Week 01.pdf
 
Cso gaddis java_chapter1
Cso gaddis java_chapter1Cso gaddis java_chapter1
Cso gaddis java_chapter1
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
COMPUTER PROGRAM.pptx
COMPUTER PROGRAM.pptxCOMPUTER PROGRAM.pptx
COMPUTER PROGRAM.pptx
 
Foundation of information system - Software
Foundation of information system - SoftwareFoundation of information system - Software
Foundation of information system - Software
 
Problem Solving and Program Design in C_1.pdf
Problem Solving and Program Design in C_1.pdfProblem Solving and Program Design in C_1.pdf
Problem Solving and Program Design in C_1.pdf
 
K04 software
K04 softwareK04 software
K04 software
 
Organization of modern digital computers
Organization of modern digital computersOrganization of modern digital computers
Organization of modern digital computers
 
Chapter # 1
Chapter # 1Chapter # 1
Chapter # 1
 
Operating system 01 introduction
Operating system 01 introductionOperating system 01 introduction
Operating system 01 introduction
 
Cpp htp5e 01
Cpp htp5e 01Cpp htp5e 01
Cpp htp5e 01
 
Computer basics
Computer basicsComputer basics
Computer basics
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-Introduction
 
Topic -Anatomy of Computer.pptx
Topic -Anatomy  of Computer.pptxTopic -Anatomy  of Computer.pptx
Topic -Anatomy of Computer.pptx
 
Computer software and computer network
Computer software and computer networkComputer software and computer network
Computer software and computer network
 
Unit 1 computer concepts
Unit 1   computer conceptsUnit 1   computer concepts
Unit 1 computer concepts
 
HARDWARE AND SOFTWARE.pptx
HARDWARE AND SOFTWARE.pptxHARDWARE AND SOFTWARE.pptx
HARDWARE AND SOFTWARE.pptx
 
Chapter 1 - Introduction to Operating System.pptx
Chapter 1 - Introduction to Operating System.pptxChapter 1 - Introduction to Operating System.pptx
Chapter 1 - Introduction to Operating System.pptx
 
fdocuments.in_unit-2-foc.ppt
fdocuments.in_unit-2-foc.pptfdocuments.in_unit-2-foc.ppt
fdocuments.in_unit-2-foc.ppt
 
Introduction to Computers Lecture # 11
Introduction to Computers Lecture # 11Introduction to Computers Lecture # 11
Introduction to Computers Lecture # 11
 

Recently uploaded

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 

Recently uploaded (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 

Introduction to Java and computers

  • 1. CHAPTER 1 Introduction to Computers and Java Copyright © 2016 Pearson Education, Inc., Hoboken NJ
  • 2. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-2 Chapter Topics Chapter 1 discusses the following main topics: – Introduction – Why Program? – Computer Systems: Hardware and Software – Programming Languages – What Is a Program Made Of? – The Programming Process – Object-Oriented Programming
  • 3. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-3 Java History • 1991 - Green Team started by Sun Microsystems (now owned by Oracle). • *7 Handheld controller 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.
  • 4. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-4 Introduction • Java enabled web browser (HotJava) demonstrated at 1995 Sun World conference. • Java incorporated into Netscape shortly after. • Java is “cross platform”, meaning that it can run on various computer operating systems.
  • 5. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-5 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.
  • 6. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-6 Why Program? • Computers are tools that can be programmed to perform many functions, such as: • Computers are versatile because they can be programmed. • Computer Programmers implement programs that perform these functions. • spreadsheets • databases • word processing • games • etc.
  • 7. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-7 Why Program? Aspects of a computer program that must be designed: – The logical flow of the instructions – The mathematical procedures – The layout of the programming statements – The appearance of the screens – The way information is presented to the user – The program’s “user friendliness” – Manuals, help systems, and/or other forms of written documentation.
  • 8. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-8 Why Program? • 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.
  • 9. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-9 Computer Systems: Hardware • Computer hardware components are the physical pieces of the computer. • The major hardware components of a computer are: – The central processing unit (CPU) – Main memory – Secondary storage devices – Input and Output devices
  • 10. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-10 Computer Systems: Hardware
  • 11. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-11 Computer Systems: Hardware Central Processing Unit Instruction (input) Result (output) Arithmetic Logic Unit Control Unit CPU
  • 12. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-12 Computer Systems: Hardware Central Processing Unit – The CPU performs the fetch, decode, execute cycle in order to process program information. Fetch The CPU’s control unit fetches, from main memory, the next instruction in the sequence of program instructions. Decode The instruction is encoded in the form of a number. The control unit decodes the instruction and generates an electronic signal. Execute The signal is routed to the appropriate component of the computer (such as the ALU, a disk drive, or some other device). The signal causes the component to perform an operation.
  • 13. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-13 Computer Systems: Hardware Main Memory • Commonly known as random-access memory (RAM) • RAM contains: – currently running programs – data used by those programs. • RAM is divided into units called bytes. • A byte consists of eight bits that may be either on or off.
  • 14. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-14 Computer Systems: Hardware Main Memory • A bit is either on or off: – 1 = on – 0 = off • The bits form a pattern that represents a character or a number. • Each byte in memory is assigned a unique number known as an address. • RAM is volatile, which means that when the computer is turned off, the contents of RAM are erased. 1 1 1 1 0 0 0 0
  • 15. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-15 Computer Systems: Hardware Main Memory A section of memory is called a byte. A section of two or four bytes is often called a word. Main memory can be visualized as a column or row of cells. 0x000 0x001 0x003 0x002 0x004 0x005 0x006 0x007 A byte is made up of 8 bits.1 0 1 0 1 0 1 0
  • 16. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-16 Computer Systems: Hardware Secondary Storage Devices • Secondary storage devices are capable of storing information for longer periods of time (non-volatile). • Common Secondary Storage devices: • Disk drive • External drive • CD drive • Solid state drive • USB drive • DVD drive
  • 17. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-17 Computer Systems: Hardware Input Devices • Input is any data the computer collects from the outside world. • That data comes from devices known as input devices. • Common input devices: – Keyboard – Mouse – Scanner – Digital camera
  • 18. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-18 Computer Systems: Hardware Output Devices • Output is any data the computer sends to the outside world. • That data is displayed on devices known as output devices. • Common output devices: – Monitors – Printers • Some devices such as disk drives perform input and output and are called I/O devices (input/output).
  • 19. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-19 Computer Systems: Software • Software refers to the programs that run on a computer. • There are two classifications of software: – Operating Systems – Application Software
  • 20. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-20 Computer Systems: Software Operating Systems • An operating system is a set of programs that manages the computer’s hardware devices and controls their processes. • Most all modern operating systems are multitasking.
  • 21. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-21 Computer Systems: Software Operating Systems • A multitasking operating system is capable of running multiple programs at once. – Unix – Linux – Mac OS – Windows • The technique is called time sharing. • A multitasking system divides the allocation of hardware resources and the attention of the CPU among all the executing programs.
  • 22. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-22 Computer Systems: Software Application Software • Application software refers to programs that make the computer useful to the user. • Application software provides a more specialized type of environment for the user to work in. • Common application software: – Spreadsheets – Word processors – Accounting software – Tax software – Games
  • 23. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-23 Programming Languages • A program is a set of instructions a computer follows in order to perform a task. • A programming language is a special language used to write computer programs. • A computer program is a set of instructions that enable the computer to solve a problem or perform a task. • Collectively, these instructions form an algorithm
  • 24. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-24 Programming Languages • An algorithm is a set of well defined steps to completing a task. • The steps in an algorithm are performed sequentially. • A computer needs the algorithm to be written in machine language. • Machine language is written using binary numbers. • The binary numbering system (base 2) only has two digits (0 and 1).
  • 25. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-25 Programming Languages • The binary numbers are encoded as a machine language. • 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
  • 26. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-26 Programming Languages • In the distant past, programmers wrote programs in machine language. • Programmers developed higher level programming languages to make things easier. • The first of these was assembler. • Assembler made things easier but was also processor dependent.
  • 27. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-27 Programming Languages • High level programming languages followed that were not processor dependent. • Some common programming languages: Java BASIC C++ C Python COBOL JavaScript Ruby PHP C# Visual Basic Pascal
  • 28. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-28 Programming Languages Common Language Elements • There are some concepts that are common to virtually all programming languages. • Common concepts: – Key words – Operators – Punctuation – Programmer-defined identifiers – Strict syntactic rules.
  • 29. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-29 Programming Languages Sample Program public class HelloWorld { public static void main(String[] args) { String message = "Hello World"; System.out.println(message); } }
  • 30. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-30 Programming Languages Sample Program • Key words in the sample program are: • Key words are lower case (Java is a case sensitive language). • Key words cannot be used as a programmer- defined identifier. •public •class •static •void
  • 31. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-31 Programming Languages • Semi-colons are used to end Java statements; however, not all lines of a Java program end a statement. • Part of learning Java is to learn where to properly use the punctuation.
  • 32. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-32 Programming Languages Lines vs Statements • There are differences between lines and statements when discussing source code. System.out.println( message); • This is one Java statement written using two lines. Do you see the difference? • A statement is a complete Java instruction that causes the computer to perform an action.
  • 33. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-33 Programming Languages Variables • Data in a Java program is stored in memory. • Variable names represent a location in memory. • Variables in Java are sometimes called fields. • Variables are created by the programmer who assigns it a programmer-defined identifier. example: int hours = 40; • In this example, the variable hours is created as an integer (more on this later) and assigned the value of 40.
  • 34. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-34 Programming Languages Variables • Variables are simply a name given to represent a place in memory. 0x000 0x001 0x002 0x003 0x004 0x005 0x006 0x007
  • 35. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-35 Programming Languages Variables 0x000 0x001 0x002 0x003 0x004 0x005 0x006 0x007 The Java Virtual Machine (JVM) actually decides where the value will be placed in memory. 72 Assume that the this variable declaration has been made. int length = 72; The variable length is a symbolic name for the memory location 0x003.
  • 36. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-36 The Compiler and the Java Virtual Machine • A programmer writes Java programming 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 executable form.
  • 37. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-37 The Compiler and the Java Virtual Machine • A compiler is run using a source code file as input. • Syntax errors that may be in the program will be discovered during compilation. • Syntax errors are mistakes that the programmer has made that violate the rules of the programming language. • The compiler creates another file that holds the translated instructions.
  • 38. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-38 The Compiler and the Java Virtual Machine • Most compilers translate source code into executable files containing machine code. • The Java compiler translates a Java source file into a file that contains byte code instructions. • Byte code instructions are the machine language of the Java Virtual Machine (JVM) and cannot be directly executed directly by the CPU.
  • 39. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-39 The Compiler and the Java Virtual Machine • Byte code files end with the .class file extension. • The JVM is a program that emulates a micro- processor. • The JVM executes instructions as they are read. • JVM is often called an interpreter. • Java is often referred to as an interpreted language.
  • 40. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-40 Program Development Process Text editor Source code (.java) Saves Java statements Java compiler Is read by Byte code (.class) Produces Java Virtual Machine Is interpreted by Program Execution Results in
  • 41. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-41 Portability • 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: •Unix •BSD •Etc. •Windows •Mac •Linux
  • 42. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-42 Portability • With most programming languages, portability is achieved by compiling a program for each CPU it will run on. • Java provides an JVM for each platform so that programmers do not have to recompile for different platforms.
  • 43. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-43 Portability Java Virtual Machine for Windows Byte code (.class) Java Virtual Machine for Linux Java Virtual Machine for Mac Java Virtual Machine for Unix
  • 44. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-44 Java Versions • The software you use to write Java programs is called the Java Development Kit, or JDK. • There are different editions of the JDK: – Java SE - Java2 Standard Edition. – Java EE - Java2 Enterprise Edition. – Java ME - Java2 Micro Edition. • Available for download at http://java.oracle.com
  • 45. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-45 Compiling a Java Program • The Java compiler is a command line utility. • The command to compile a program is: java filename.java • javac is the Java compiler. • The .java file extension must be used. Example: To compile a java source code file named Payroll.java you would use the command: javac Payroll.java
  • 46. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-46 The Programming Process 1. Clearly define what the program is to do. 2. Visualize the program running on the computer. 3. Use design tools to create a model of the program. 4. Check the model for logical errors.
  • 47. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-47 The Programming Process 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.
  • 48. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-48 Software Engineering • 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.
  • 49. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-49 Software Engineering • Software engineers develop: – program specifications, – diagrams of screen output, – diagrams representing the program components and the flow of data, – pseudocode, – examples of expected input and desired output.
  • 50. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-50 Software Engineering • Software engineers also use special software designed for testing programs. • Most commercial software applications are large and complex. • Usually a team of programmers, not a single individual, develops them. • Program requirements are thoroughly analyzed and divided into subtasks that are handled by – individual teams – individuals within a team.
  • 51. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-51 Procedural Programming • Older programming languages were procedural. • A procedure is a set of programming language statements that, together, perform a specific task. • Procedures typically operate on data items that are separate from the procedures. • In a procedural program, the data items are commonly passed from one procedure to another.
  • 52. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-52 Procedural Programming Procedure A Data Element Procedure B
  • 53. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-53 Procedural Programming • In procedural programming, procedures are developed to operate on the program’s data. • Data in the program tends to be global to the entire program. • Data formats might change and thus, the procedures that operate on that data must change.
  • 54. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-54 Object-Oriented Programming • Object-oriented programming is centered on creating objects rather than procedures. • Objects are a melding of data and procedures that manipulate that data. • Data in an object are known as attributes. • Procedures in an object are known as methods.
  • 55. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-55 Object-Oriented Programming Object Attributes (data) Methods (behaviors / procedures)
  • 56. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-56 Object-Oriented Programming • 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.
  • 57. ©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. 1-57 Object-Oriented Programming Object Attributes (data) typically private to this object Methods (behaviors / procedures) Other objects Programming Interface