0% found this document useful (0 votes)
23 views43 pages

Introduction To Computers, The Internet & Java: Academic 2019 Academic 2019 Class: BIT23/BCS10 Class: BIT23/BCS10

JAVA INTRODUCTION

Uploaded by

mohamed muse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views43 pages

Introduction To Computers, The Internet & Java: Academic 2019 Academic 2019 Class: BIT23/BCS10 Class: BIT23/BCS10

JAVA INTRODUCTION

Uploaded by

mohamed muse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 43

Academic

Academic 2019
2019

Class:
Class: BIT23/BCS10
BIT23/BCS10

Chapter 01

Introduction to Computers, the Internet & Java


Java How to Program,
10/e

Abdulaziz Yasin Nageye


Faculty of Computing

06/12/21 1
 Java is one of the world’s most widely used computer
programming languages.
 You’ll learn to write instructions commanding

computers to perform tasks.


 Software (i.e., the instructions you write) controls

hardware (i.e., computers).


 You’ll learn object-oriented programming—today’s

key programming methodology.


 You’ll create and work with many software objects.

06/12/21 2
 For many organizations, the preferred language for
meeting their enterprise programming needs is Java.
 Java is also widely used for implementing Internet-

based applications and software for devices that


communicate over a network.
 According to Oracle, 97% of enterprise desktops, 89%

of PC desktops, three billion devices (Fig. 1.1) and


100% of all Blu-ray Disc™ players run Java, and there
are over 9 million Java developers. (
http://www.oracle.com/technetwork/articles/java/javaone12review
-1863742.html
)

06/12/21 3
06/12/21 4
Java Standard Edition
Java How to Program, 10/e is based on Java Standard

Edition 7 (Java SE 7) and Java Standard Edition 8 (Java


SE 8)
Java Standard Edition contains the capabilities needed

to develop desktop and server applications.


Prior to Java SE 8, Java supported three programming

paradigms—procedural programming, object-oriented


programming and generic programming. Java SE 8
adds functional programming.

06/12/21 5
Java Enterprise Edition
Java is used in such a broad spectrum of applications

that it has two other editions.


The Java Enterprise Edition (Java EE) is geared toward

developing large-scale, distributed networking


applications and web-based applications.

06/12/21 6
 Java Micro Edition (Java ME)
◦ a subset of Java SE.
◦ geared toward developing applications for resource-
constrained embedded devices, such as
 Smartwatches
 MP3 players
 television set-top boxes
 smart meters (for monitoring electric energy usage)
 and more.

06/12/21 7
 Computers can perform calculations and make logical
decisions phenomenally faster than human beings can.
 Today’s personal computers can perform billions of
calculations in one second—more than a human can
perform in a lifetime.
 Supercomputers are already performing thousands of
trillions (quadrillions) of instructions per second!
 Computers process data under the control of sequences of
instructions called computer programs.

06/12/21 8
 These software programs guide the computer through
ordered actions specified by people called computer
programmers.

 You’ll learn a key programming methodology that’s


enhancing programmer productivity, thereby reducing
software development costs—object-oriented programming.

06/12/21 9
 A computer consists of various devices referred to as
hardware
◦ (e.g., the keyboard, screen, mouse, hard disks, memory, DVD drives
and processing units).
 Computing costs are dropping dramatically, owing to rapid
developments in hardware and software technologies.
 Computers that might have filled large rooms and cost
millions of dollars decades ago are now inscribed on silicon
chips smaller than a fingernail, costing perhaps a few
dollars each.
 Silicon-chip technology has made computing so economical
that computers have become a commodity.

06/12/21 10
 Every year or two, the capacities of computers have
approximately doubled inexpensively.
 This remarkable trend often is called Moore’s Law.
 Named for the person who identified the trend, Gordon
Moore, co-founder of Intel.
 Moore’s Law and related observations apply especially
to the amount of memory that computers have for
programs, the amount of secondary storage (such as disk
storage) they have to hold programs and data over longer
periods of time, and their processor speeds—the speeds
at which they execute their programs (i.e., do their work).

06/12/21 11
 Similar growth has occurred in the communications
field.

 Costs have plummet as enormous demand for


communications bandwidth (i.e., information-carrying
capacity) has attracted intense competition.

 Such phenomenal improvement is fostering the


Information Revolution.

06/12/21 12
 Computers can be envisioned as divided into various
logical units or sections.

06/12/21 13
06/12/21 14
06/12/21 15
06/12/21 16
06/12/21 17
 Data items processed by computers form a data
hierarchy that becomes larger and more complex in
structure as we progress from the simplest data items
(called “bits”) to richer ones, such as characters and
fields.

06/12/21 18
06/12/21 19
Bits
The smallest data item in a computer can assume the value 0
or the value 1.
Such a data item is called a bit (short for “binary digit”—a
digit that can assume either of two values).
Remarkably, the impressive functions performed by
computers involve only the simplest manipulations of 0s and
1s—examining a bit’s value, setting a bit’s value and
reversing a bit’s value (from 1 to 0 or from 0 to 1).

06/12/21 20
Characters
We prefer to work with decimal digits (0–9), uppercase
letters (A–Z), lowercase letters (a–z), and special symbols
(e.g., $, @, %, &, *, (, ), –, +, ", :, ? and / ).
Digits, letters and special symbols are known as characters.
The computer’s character set is the set of all the characters
used to write programs and represent data items on that
device.
Computers process only 1s and 0s, so every character is
represented as a pattern of 1s and 0s.
Java uses Unicode® characters that are composed of one,
two or four bytes (8, 16 or 32 bits).

06/12/21 21
 Unicode contains characters for many of the world’s
languages.
 See Appendix B for more information on the ASCII
(American Standard Code for Information Interchange)
character set—the popular subset of Unicode that represents
uppercase and lowercase letters in the English alphabet,
digits and some common special characters.

06/12/21 22
Fields
Just as characters are composed of bits, fields are composed
of characters or bytes.
Afield is a group of characters or bytes that conveys
meaning.
For example, a field consisting of uppercase and lowercase
letters could be used to represent a person’s name, and a field
consisting of decimal digits could represent a person’s age.

06/12/21 23
Records
Several related fields can be used to compose a record
(implemented as a class in Java).
In a payroll system, for example, the record for an employee
might consist of the following fields (possible types for these
fields are shown in parentheses):
◦ Employee identification number (a whole number)
◦ Name (a string of characters)
◦ Address (a string of characters)
◦ Hourly pay rate (a number with a decimal point)
◦ Year-to-date earnings (a number with a decimal point)
◦ Amount of taxes withheld (a number with a decimal point)
Thus, a record is a group of related fields.
In the preceding example, all the fields belong to the same
employee.

06/12/21 24
Files
A file is a group of related records.

More generally, a file contains arbitrary data in arbitrary


formats.
In some operating systems, a file is viewed simply as a
sequence of bytes—any organization of the bytes in a file,
such as organizing the data into records, is a view created by
the application programmer.

06/12/21 25
Database
A database is a collection of data that’s organized for easy
access and manipulation.
The most popular database model is the relational database
in which data is stored in simple tables.
A table includes records and fields.
◦ For example, a table of students might include first name, last name,
major, year, student ID number and grade point average fields.
◦ The data for each student is a record, and the individual pieces of
information in each record are the fields.
You can search, sort and otherwise manipulate the data
based on its relationship to multiple tables or databases.

06/12/21 26
Big Data
The amount of data being produced worldwide is huge and
growing explosively.
According to IBM, approximately 2.5 quintillion bytes (2.5
exabytes) of data are created daily and 90% of the world’s
data was created in just the past two years!
(www-01.ibm.com/software/data/bigdata/)
Big data applications deal with such massive amounts of data
and this field is growing quickly, creating lots of opportunity
for software developers.

06/12/21 27
06/12/21 28
 Programmers write instructions in various
programming languages, some directly understandable
by computers and others requiring intermediate
translation steps.
 These may be divided into three general types:

◦ Machine languages
◦ Assembly languages
◦ High-level languages

06/12/21 29
Machine Languages
Any computer can directly understand only its own machine
language, defined by its hardware design.
◦ Generally consist of strings of numbers (ultimately reduced to 1s and
0s) that instruct computers to perform their most elementary operations
one at a time.
◦ Machine dependent—a particular ma-chine language can be used on
only one type of computer.
Assembly Languages and Assemblers
English-like abbreviations that represent elementary operations
formed the basis of assembly languages.
Translator programs called assemblers convert early assembly-
language programs to machine language.

06/12/21 30
High-Level Languages and Compilers
High-level languages
◦ Single statements accomplish substantial tasks.
◦ Compilers convert high-level language programs into machine language.
◦ Allow you to write instructions that look almost like everyday English
and contain commonly used mathematical notations.
◦ A payroll program written in a high-level language might contain a
single statement such as
 grossPay = basePay + overTimePay
Interpreters
Compiling a high-level language program into machine
language can take considerable computer time.
Interpreter programs, developer to execute high-level language
programs directly, avoid the delay or compilation, although they
run slower than compiled programs.

06/12/21 31
Introduction to Java
Java is an object-oriented programming language developed by
James Gosling and colleagues at Sun Microsystems in the early
1990s. which resulted in a C++-based object-oriented programming
language that Sun called Java.

The language itself borrows much syntax from C and C++ but has a
simpler object model and fewer low-level facilities. Java is only
distantly related to JavaScript, though they have similar names and
share a C-like syntax

Key goal of Java is to be able to write programs that will run on a


great variety of computer systems and computer-controlled devices.
This is sometimes called “write once, run anywhere.”

06/12/21 32
Java (Cont.)
1993
The web exploded in popularity
Sun saw the potential of using Java to add dynamic
content to web pages.
Java drew the attention of the business community
because of the phenomenal interest in the web.
Java is used to develop large-scale enterprise
applications, to enhance the functionality of web servers,
to provide applications for consumer devices and for
many other purposes.

06/12/21 33
Methods and Classes
Performing a task in a program requires a method.
The method houses the program statements that actually
perform its tasks.
Hides these statements from its user, just as the accelerator
pedal of a car hides from the driver the mechanisms of
making the car go faster. In Java, we create a program unit
called a class to house the set of methods that perform the
class’s tasks.
A class is similar in concept to a car’s engineering drawings,
which house the design of an accelerator pedal, steering
wheel, and so on.

06/12/21 34
Java (Cont.)

Java Class Libraries


Rich collections of existing classes and
methods
Also known as the Java APIs (Application
Programming Interfaces).

06/12/21 35
A Typical Java Development Environment

Normally there are five phases


edit
compile
load
verify
execute.

Phase 1 consists of editing a file with an editor program


oUsing the editor, you type a Java program (source code).
oMake any necessary corrections.
oSave the program.
oJava source code files are given a name ending with the .java
extension indicating that the file contains Java source code.

06/12/21 36
A Typical Java Development Environment
(Cont.)
Linux editors: vi and emacs.
Windows provides Notepad.
OSX provides TextEdit.
Many freeware and shareware editors available online:
Notepad++ (notepad-plus-plus.org)
EditPlus (www.editplus.com)
TextPad (www.textpad.com)
jEdit (www.jedit.org).

Integrated development environments (IDEs)


Provide tools that support the software development process, such as editors,
debuggers for locating logic errors (errors that cause programs to execute
incorrectly) and more.

06/12/21 37
Typical Java Development Environment (Cont.)

Popular Java IDEs


Eclipse (www.eclipse.org)
NetBeans (www.netbeans.org)
IntelliJ IDEA (www.jetbrains.com)

Phase 2: Compiling a Java Program into Bytecodes


Use the command javac (the Java compiler) to compile a program.
For example, to compile a program called Welcome.java,

06/12/21 38
Cont….
Java compiler translates Java source code into bytecodes that
represent the tasks to execute.

Phase 3: Loading a Program into Memory


The JVM places the program in memory to execute it—this is
known as loading.
Class loader takes the .class files containing the program’s
bytecodes and transfers them to primary memory.
Also loads any of the .class files provided by Java that your
program uses.
The .class files can be loaded from a disk on your system or over
a network.

06/12/21 39
Cont….

Phase 4: Bytecode Verification


As the classes are loaded, the bytecode verifier examines their
bytecodes
Ensures that they’re valid and do not violate Java’s security
restrictions.
Java enforces strong security to make sure that Java programs
arriving over the network do not damage your files or your system
(as computer viruses and worms might).

06/12/21 40
Cont….
Phase 5: Execution
The JVM executes the program’s bytecodes.
JVMs typically execute bytecodes using a combination of
interpretation and so-called just-in-time (JIT) compilation.
Analyzes the bytecodes as they’re interpreted
A just-in-time (JIT) compiler—such as Oracle’s Java HotSpot™
compiler—translates the bytecodes into the underlying computer’s

machine language.

06/12/21 41
Cont….
When the JVM encounters these compiled parts again, the faster
machine-language code executes.
Java programs go through two compilation phases
One in which source code is translated into bytecodes (for
portability across JVMs on different computer platforms) and
A second in which, during execution, the bytecodes are translated
into machine language for the actual computer on which the
program executes.

06/12/21 42
END

06/12/21 43

You might also like