Java - academichelp
Download
Report
Transcript Java - academichelp
Java
Computing Concepts
What Is the Computer?
A machine that stores data(numbers,
words, pictures)
Interacts with devices (monitor, sound,
printer)
Executes programs
What Is a Program?
A sequence of instructions and
decisions that the computer carries out
to achieve a task.
Programs are so sophisticated that they
are only composed of extremely
primitive operations
What Is Programming
Tells a computer, in minute detail, the
sequence of steps that are needed to
fulfill a task.
It is the act of designing and
implementing these programs.
It is how to direct the computer to
execute a task.
Anatomy of a Computer Central Processing Unit
The heart of the
computer is the
CPU.
Pentium III contains
over 28 million
structural
transistors.
Performs
- Program controllocates and executes
program instructions
- Arithmetic –
operations (MDAS)
- Data movementfetches and stores
data from external
sources
Storage Devices
Primary storage.
- Ram.
Disadvantages.
- Expensive.
- Loses all its data
when power is
turned off.
Secondary storage
-
-
Hard disk, floppy
disk, compact disk,
tapes
Usually made of
magnetic media
Schematic Diagram of a
Computer
ports
Printer, Mouse, Keyboard, Modem
Central Processing Unit
Random Access Memory
bus
set of electrical lines
Disk Contoller
CD-ROM
Drive
Floppy
Disk
Hard Disk
Graphics Card
Sound Card
Network Card
Monitor
Speakers
Internet
The CPU reads machine instructions from memory. The
instructions direct it to communicate with memory,
secondary storage and peripheral devices.
Translating Human – Readable
Programs to Machine Code
Machine code depends on the CPU type. The
instruction set of the Java virtual machine (JVM) can be
executed on many CPUs.
Machine instructions are encoded as numbers, it is
difficult to write programs in machine code.
Assembly language makes it easier to generate
machine instructions by translating mnemonics and
symbolic names.
Another feature that assemblers have is that they give
names to memory locations as well as the instructions.
Programming Languages
Each programming language has its own set of rules for
forming instructions. Compilers enforce these rules
strictly.
When the compiler reads programming instructions in a
programming language, it will translate them into
machine code only if the input follow the language
conventions exactly.
You can not omit grammatical instructions or formats of
the programming language, unusual results or errors will
be created by the compiler.
Translating Human – Readable
Programs to Machine Code (con’t)
In the mid-1950’s, high level programming
languages are being produced.
High-level languages let you describe tasks at a
higher conceptual level than machine code.
A compiler translates programs written in a highlevel language into machine code.
*****************************************
The compiler is a sophisticated program
that does all the translations of logical
statements. (A behind the scenes program)
*****************************************
Java Programming Language
James Gosling and Patrick Naughton at Sun
Microsystems, in 1991, designed a language that they
code-named “Green” for use in consumer devices such
as intelligent television boxes. It was to be architectureneutral and simple.
In 1994, a browser was created that could done in real
time, would be reliable and secure. It was able to
download applets off the web and run individually
independent.
It has a rich library that make portable programs possible
and it is able to bypass proprietary operating systems.
Java Programming Language
(cont’)
It was designed for both Internet users and students.
This language is inherently safe and can run on any
machine.
It has been established that Java is one of the most
important languages for general purpose programming as
well as for computer science instruction.
Java Programming Language
(cont’)
It maybe good for beginners but there are two
reasons to be careful of this language.
A certain amount of technical machinery is necessary
in java to write even the simplest of programs.
The Java language is so compact in the amount of
library packages that it would take a long time to
understand all of the programs.
Some of the packages include graphics, user
interface design, cryptography, networking, sound,
database storage, and many other purposes.
Becoming Familiar With Your
Computer
Steps to become familiar with your
computer
Log in – computers in the home
environment may not have you logging
in but in the lab or classroom
environment you will need to log in with
you login name and password.
Becoming Familiar With Your
Computer cont’
Locate the Java Compiler – computer
systems differ greatly. Some computers
have you open a shell window 9 (
where you type commands to invoke
the compiler) and others may have an
integrated development environment
where you write and test your
programs.
Becoming Familiar With Your
Computer cont’
Understand files and folders – making a
program in java will ask you to store
them in a file. This program must end
in an extension of .Java and the file
names cannot contain spaces, and the
distinction between upper and
lowercase letters is important because
this program is case sensitive.
Becoming Familiar With Your
Computer cont’
Write a simple program – You will be
shown how to type up the commands,
how to compile it or run it and how to
fix mistakes.
Becoming Familiar With Your
Computer cont’
Save your work – A safety feature in
any programming language is to save
your work before compiling it.
It is important to rename the revised
programs with new names so that you can
have the original programs to work from.
Always have backup copies stored on a
floppy in a safe place other than your
computer in case of computer problems or
malfunctions.
Backup Copies
Back up often
Rotate backups
Back up source files only
Pay attention to the backup direction
Check your backups once in a while
Relax, then restore
Compiling a Simple Program
File Hello.java
public class Hello
{
public static void main(String{} args)
{
//display a greeting in the console window
System.out.println(“Hello, World!”);
}
}