Chapter One Java
Chapter One Java
By Hagos Tesfahun
Computing Faculty
Institute of Technology
Bahir Dar University
2008 E.C
1
Chapter One
Introduction to Computers, Programs, and Java
2
Objectives
4
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.
7
What is Programming Languages?
Machine Language Assembly Language High-Level Language
8
What is Programming Languages?
Machine Language Assembly Language High-Level Language
10
What is Programming Languages?
Machine Language Assembly Language High-Level Language
11
What is Programming Languages?
Machine Language Assembly Language High-Level Language
They are 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;
12
What is Programming Languages?
Machine Language Assembly Language High-Level Language
14
What is Programming Languages?
Machine Language Assembly Language High-Level Language
17
Some Uses of Java Programming Language
An application is a program
Java can be used to develop: that runs on your computer,
a) Applications under the operating system of
that computer. An application
created by Java is more or less
like one created using any other
Java is a general purpose type of computer language,
programming language. such as Visual Basic or C++.
You can use it to develop applications Java applications do
on your desktop and on the server. have the main() as
You can also use it to develop member of their class
applications for small hand-held
devices, such as personal digital
assistants (PDA) and cell phones.
E.g., The following pictures shows a Java
program that displays the calendar on a
BlackBerry® and on a cell phone.
18
Java can be used to develop applications for hand-held and wireless
devices, such as a BlackBerry, PDA and Cell Phone.
19
Some Uses of Java …
An applet is an application
b) Java applets designed to be transmitted over
the Internet and executed by a
Java-compatible Web browser.
21
Some Uses of Java …
c) Server-side applications
Java server pages (JSP)
Java Servlets
Java Server Face (JSF)
Java Beans, etc.
d) Multimedia application
Java Graphics, Java Graphics 2D, etc.
e) Etc…
22
Key Features of Java Technology
No language is simple, but Java is
Java Is Simple a bit easier than the popular
object-oriented programming
Java Is Object-Oriented language C++, which was the
Java Is Distributed dominant software-development
Java Is Interpreted language before Java. Java is
Java Is Robust partially modeled on C++, but
Java Is Secure greatly simplified and improved.
Java Is Architecture-Neutral
Java Is Portable
Java's Performance
Java Is Multithreaded
Java Is Dynamic
23
Key Features of Java …
Java is inherently object-oriented.
Java Is Simple Although many object-oriented
Java Is Object-Oriented languages began strictly as procedural
Java Is Distributed languages, Java was designed from the
start to be object-oriented.
Java Is Interpreted
Java Is Robust Object-oriented programming (OOP) is
Java Is Secure a popular programming approach that
is replacing traditional procedural
Java Is Architecture-Neutral programming techniques.
Java Is Portable
Java's Performance One of the central issues in software
development is how to reuse code.
Java Is Multithreaded Object-oriented programming provides
Java Is Dynamic great flexibility, modularity, clarity, and
reusability through encapsulation,
inheritance, and polymorphism.
24
Key Features of Java …
Java Is Simple
Java Is Object-Oriented
Java Is Distributed Distributed computing involves several
Java Is Interpreted computers working together on a
Java Is Robust network. Java is designed to make
distributed computing easy. Since
Java Is Secure networking capability is inherently
Java Is Architecture-Neutral integrated into Java, writing network
Java Is Portable programs is like sending and receiving
Java's Performance data to and from a file.
Java Is Multithreaded
Java Is Dynamic
25
Key Features of Java …
Java Is Simple
Java Is Object-Oriented
You need an interpreter to run Java
Java Is Distributed
programs. The programs are compiled
Java Is Interpreted into the Java Virtual Machine code
Java Is Robust called bytecode. The bytecode is
Java Is Secure machine-independent and can run on
Java Is Architecture-Neutral any machine that has a Java interpreter,
which is part of the Java Virtual
Java Is Portable
Machine (JVM).
Java's Performance
Java Is Multithreaded
Java Is Dynamic
26
Key Features of Java …
Java Is Simple
Java compilers can detect many
Java Is Object-Oriented problems that would first show up at
Java Is Distributed execution time in other languages.
Java Is Interpreted
Java Is Robust Java has eliminated certain types of
error-prone programming constructs
Java Is Secure
found in other languages.
Java Is Architecture-Neutral
Java Is Portable Java has a runtime exception-handling
Java's Performance feature to provide programming
Java Is Multithreaded support for robustness.
Java Is Dynamic
27
Key Features of Java …
Java Is Simple
Java Is Object-Oriented Java implements several security
Java Is Distributed mechanisms to protect your system
against harm caused by stray programs.
Java Is Interpreted
Java Is Robust
Java Is Secure
Java Is Architecture-Neutral
Java Is Portable
Java's Performance
Java Is Multithreaded
Java Is Dynamic
28
Key Features of Java …
Java Is Simple
Java Is Object-Oriented Architectural-Neutral means
Java Is Distributed platform-independent.
Java Is Interpreted
Java Is Robust With a Java Virtual Machine
(JVM), you can write one program
Java Is Secure that will run on any platform.
Java Is Architecture-Neutral
Java Is Portable With a Java Virtual Machine
Java's Performance (JVM), you can write one program
Java Is Multithreaded that will run on any platform.
Java Is Dynamic
29
Key Features of Java …
Java Is Simple
Java Is Object-Oriented
Java Is Distributed
Java Is Interpreted
Because Java is architecture
Java Is Robust neutral, Java programs are
Java Is Secure portable. They can be run on any
Java Is Architecture-Neutral platform without being
Java Is Portable recompiled.
Java's Performance
Java Is Multithreaded
Java Is Dynamic
30
Key Features of Java …
31
Key Features of Java …
Java Is Simple
Java Is Object-Oriented
Java Is Distributed
Java Is Interpreted
Java Is Robust
Java Is Secure Multithreading is a program’s capability
Java Is Architecture-Neutral to perform several tasks
simultaneously.
Java Is Portable
Java's Performance Multithread programming is smoothly
Java Is Multithreaded integrated in Java, whereas in other
Java Is Dynamic languages you have to call procedures
specific to the operating system to
enable multithreading.
32
Key Features of Java …
Java Is Simple
Java Is Object-Oriented
Java Is Distributed
Java Is Interpreted
Java Is Robust
Java Is Secure
Java Is Architecture-Neutral Java was designed to adapt to an
Java Is Portable evolving environment. New code can be
Java's Performance loaded on the fly without
Java Is Multithreaded recompilation. There is no need for
developers to create, and for users to
Java Is Dynamic install, major new software versions.
New features can be incorporated
transparently as needed.
33
The Java Language Specification, API, JDK, and IDE
35
The Java Language Specification…
NB:
If you have the JDK installed, you don’t need to install
the JRE separately to run any Java software.
JVM is platform dependent
37
The Java Language Specification…
Integrated Development Environment (IDE) is provided by the
Java development tool for rapidly developing Java programs.
38
Java Development Tools
40
Creating, Compiling, and Executing a Java Program
42
Creating, Compiling, and Executing ...
Result
43
If runtime errors or incorrect result
Creating, Compiling, and Executing ...
44
Questio Answer
n
45