java_chapter_one
java_chapter_one
Introduction to Computers,
Programs, and Java
by : Addisu A.
Objectives
• To review computer basics and programs
• To understand what programming paradigm is?
• To distinguish the terms API, IDE, and JDK.
• To write a simple Java program .
• To display output on the console .
• To explain the basic syntax of a Java program
• To create, compile, and run Java programs .
What is Computer ?
• is an electronic device designed to process data, perform
calculations, and execute a set of instructions (programs) to
accomplish various tasks.
• Here are the key components and functions of a computer:
1) Hardware:
• Central Processing Unit (CPU): The brain of the computer that performs
calculations and executes instructions.
• Memory (RAM): Temporary storage that holds data and instructions
that the CPU is currently processing.
• Storage: Devices like hard drives (HDDs) or solid-state drives (SSDs) that
store data permanently.
What else?
2)Software:
• Operating System: The system software that manages hardware and
software resources (e.g., Windows, macOS, Linux).
• Applications: Programs that perform specific tasks (e.g., word
processors, web browsers, games).
What is Computer Program?
• Computer programs, known as software, are instructions to the
computer.
• You tell a computer what to do through programs.
• Without programs, a computer is an empty machine.
• Computers do not understand human languages, so you need to use
computer languages to communicate with them.
• Programs are written using programming languages.
• Computer programs are instructions that tell a computer what to do.
• What is software , program and code ?
What is Programming Languages?
• Programming languages are languages that programmers use to write
code/program to instruct a computer.
• Computers do not understand human languages, so programs must be
written in a language a computer can use.
• There are hundreds of programming languages, and they were
developed to make the programming process easier for people.
• Programming languages are classified into three categories. Machine,
Assembly and High- Level Language
Cont...
Machine Language
• Machine language is a set of primitive instructions built into every
computer.
• The instructions are in the form of binary code, so you have to enter
binary codes for various instructions.
• Program with native machine language is a tedious process.
• Moreover the programs are highly difficult to read and modify.
• For example, you might write an instruction in binary like this:
1101101010011010
Cont...
Assembly Language
• Programming in machine language is a tedious process.
• Moreover, programs written in machine language are very
difficult to read and modify.
• For this reason, assembly language was created in the early
days of computing as an alternative to machine languages.
• Assembly language uses a short descriptive word, known as
a mnemonic, to represent each of the machine-language
instructions.
• For example, the mnemonic ADD typically means to add
numbers and SUB means to subtract numbers.
Cont...
Assembly Language
• Assembly languages were developed to make programming
easy.
• Since the computer cannot understand assembly language,
however, a program called assembler is used to convert
assembly language programs into machine code, as shown
in the following Figure.
• For example, to add two numbers, you might write an
instruction in assembly code like this:
ADD 2, 3, result
Cont...
Assembly Language
• Writing code in assembly language is easier than in machine
language.
• However, it is still tedious to write code in assembly
language.
• Writing in assembly requires that you know how the CPU
works.
• Assembly language is referred to as a low-level language,
because assembly language is close in nature to machine
language and is machine dependent.
Cont...
High-Level Language
• Platform independent, which means that you can write a
program in a high level language and run it in different
types of machines.
• The high-level languages are English-like and easy to learn
and program.
• The instructions in a high-level programming language are
called statements.
• For example, the following is a high-level language
statement that computes the
area of a circle with radius 5:
area = 5* 5 * 3.1415;
Cont...
High-Level Language
• There are many high-level programming languages, and
each was designed for a specific purpose.
• Some popular ones are C, C++, C#, VIB and Java.
• But for this course Java is our focus.
• A program written in a high-level language is called a source
program or source code.
• Because a computer cannot understand a source program,
a source program , a source program must be translated
into machine code for
Cont...
High-Level Language
• The translation can be done using another programming
tool called an interpreter or a compiler
• An interpreter reads one statement from the source code,
translates it to the machine code or virtual machine code,
and then executes it right away, as shown in the following.
Cont...
High-Level Language
• A compiler translates the entire source code into a machine-code file,
and the machine-code file is then executed, as shown in figure below.