Chapter 1: Introduction
– Computer Systems:
Hardware & Software
– Programming Languages
– The Programming
Process
– Procedural Programming
vs. Object-Oriented
Programming (OOP)
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
Computer hardware components are the physical pieces of the
computer.
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Computer Systems: Hardware
The major hardware components include:
1. The central processing unit (C P U): performs the
fetch, decode, execute cycle in order to process
program information.
2. Main memory (RAM): stores the currently running
programs and the data they use.
3. Secondary storage devices: stores information for
longer periods of time (non-volatile).
4. Input and output devices: Input is any data the
computer collects from the outside world via for
devices such as keyboard, mouse, scanner, digital
camera. Output is any data the computer sends to the
outside world via devices such as monitors & printers.
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Computer Systems: Software
• Software refers to the programs that run on a computer.
• There are two classifications of software:
– Operating Systems: a set of programs that manages
the computer’s hardware devices and controls their
processes. Most all modern operating systems are
multitasking (Unix, Linux, macOS, Windows) via time
sharing.
– Application Software: programs that make the
computer useful to the user (such as spreadsheets,
Word processors, Accounting software, Tax software,
Games).
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Programming Languages
• A programming language is a language used to write
computer programs.
• 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.
• High level programming languages followed and are not
processor dependent. Some examples are: C/C++, Java,
Python.
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Programming Languages: Java (since 1991)
• Sample Java Program: • Common concepts to
public class HelloWorld programming languages:
{ – Key words
public static void main(String[] args) – Operators
{ – Punctuation
String message = "Hello World";
– Programmer-defined
[Link](message);
identifiers
}
– Strict syntactic rules.
}
• Java is case sensitive.
• Key words (Public, class, static, void) are lower-case.
• Key words cannot be used as a programmer-defined identifier.
• Semi-colons are used to end Java statements.
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
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. For example, the
variable hours is created as an integer and assigned the
value 40.
int hours = 40;
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Compiler and Java Virtual Machine (JVM)
• A programmer writes source code.
• 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.
• Syntax errors that may be in the program will be discovered
during compilation.
• 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 Java
Virtual Machine (JVM) and cannot be directly executed by
the CPU. Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Program Development Process
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Portability
• Portable: 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.
• Java provides an JVM for each platform so that programmers do not
have to recompile for different platforms.
• JVMs exist on many platforms:
– Windows
– macOS
– Linux
– Unix
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Procedural Programming
• Older programming languages were procedural.
• A procedure is a set of programming language statements
that, together, perform a specific task.
• In a procedural program, data tends to be global to the entire
program. Items are commonly passed from one procedure to
another.
• Data formats might change and thus, the procedures that
operate on that data must change.
Copyright © 2022 Pearson Education, Inc. All Rights Reserved
Object-Oriented Programming (OOP)
• Object-oriented programming (OOP)
is centered on creating objects
rather than procedures.
• Objects are a melding of data and
procedures that manipulate the data.
• Data in an object are known as
attributes.
• Procedures in an object are known
as methods.
• Only an object’s methods can directly manipulate its data.
• Other objects are allowed to manipulate an object’s attributes
via the object’s methods. This indirect access is known as a
programming interface.
Copyright © 2022 Pearson Education, Inc. All Rights Reserved