Introduction to Java Programming - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Introduction to Java Programming

Description:

Electronic devices that stores and process data. Includes both hardware and software ... Forte by Sun MicroSystems. IBM Visual Age for Java ... – PowerPoint PPT presentation

Number of Views:131
Avg rating:3.0/5.0
Slides: 36
Provided by: yda3
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Java Programming


1
Introduction toJava Programming
  • Y. Daniel Liang

2
Introduction
  • What is a computer?
  • Electronic devices that stores and process data
  • Includes both hardware and software
  • Hardware physical aspects that you can see
  • Central Processing Unit (CPU)
  • Memory (main memory)
  • Storage Devices (hard disk, floppy disk, CDs,
    tapes)
  • Input and Output Devices (monitors, keyboards,
    mice, printers)
  • Communication Devices (modems and network
    interface cards)

3
Hardware
  • Central Processing Unit (CPU)
  • Brain of a computer
  • Retrieves instructions from memory and executes
    them
  • 2 components
  • control unit
  • controls and coordinates the actions of the other
    components
  • arithmetic/logic unit
  • perform numeric operations (addition,
    subtraction, multiplication, division)
  • Perform logic operations (comparison)
  • Built on semiconductor chip with millions of
    transistors

4
Hardware
  • Memory (main memory)
  • Data are encoded as a series of bits.
  • Bit binary digit zero and one
  • Stores data and program instructions for CPU to
    execute
  • A memory unit is an ordered sequence of bytes,
    each holding 8 bits
  • Encoding scheme ASCII

5
Hardware
  • Memory (main memory)
  • A program and its data must be brought to memory
    before they can be executed
  • The content of memory is lost when new infor is
    placed in it.
  • Each byte has a unique address, used to locate
    the byte.
  • Can be accessed in any order, thus is called RAM
    (Random-access memory)
  • 1 Megabyte (MB) is about 1 million bytes.
  • Also built on silicon semiconductor ships
    containing thousands of transistors, but less
    complicated.
  • Memory is volatile, the content is lost when the
    power is turned off.

6
Hardware
  • Storage Devices (hard disk, floppy disk, CDs,
    tapes)
  • Programs and data are stored permanently on
    storage devices and moved to memory when computer
    actually uses them.
  • 4 main types of storage devices
  • Disk drives (hard disks, floppy disks)
  • CD drives (CD-R, CD-RW, DVD). DVD stands for
    Digital versatile disc.
  • Tape drives
  • USB flash drives

7
Hardware
  • Input and Output Devices (monitors, keyboards,
    mice, printers)
  • Allows user to communicate with the computer
  • Common input devices keyboards, mice
  • Common output devices monitors, printers.

8
Hardware
  • Communication Devices (modems and network
    interface cards)
  • To create network of computers

9
Software
  • Software/computer program
  • invisible instructions that control the hardware
    and make it perform specific tasks.
  • Tell computer what to do in computer/machine
    language

10
Software
  • Computer languages
  • Machine language
  • Assembly language
  • High level language

11
Software
  • Machine language
  • a set of primitive instructions built into every
    computer
  • Different for different types of computers.
  • The instructions are in the form of binary code,
    e.g. to add 2 numbers (very tedious)
  • 1101101010011010

12
Software
  • Assembly language
  • Low-level programming language which uses
    mnemonic to represent machine-language
    instructions
  • E.g. ADDF3 R1, R2, R3
  • Assembly code need to be converted into machine
    code by using an assembler
  • Assembly program
  • is platform dependent
  • Combination of mnemonic and machine instruction

13
Software
  • High-level language
  • English-like and easy to learn and program.
  • E.g.
  • Area 5 5 3.1415
  • COBOL, FORTRAN, BASIC, Pascal, Ada, C, Visual
    Basic, Delphi, C, C, Java
  • Source program is compiled into machine code by a
    compiler and linked to supporting library code by
    a linker to form an executable file. Fig. 1.4

14
Software
  • High-level language (continue)
  • Can port/move a source program to any machine
    with appropriate compilers but the source program
    must be recompiled
  • Java program, compiled it once into intermediate
    machine code known as bytecode. Bring the
    bytecode to any computer with a JVM (Java Virtual
    Machine). JVM interprets the bytecode into the
    machine codes and execute them.

15
An overview of the java development process.
Source http//java.sun.com/docs/books/tutorial/ge
tStarted/intro/definition.html
16
Through the Java VM, the same application is
capable of running on multiple platforms.
Source http//java.sun.com/docs/books/tutorial/ge
tStarted/intro/definition.html
17
Software
  • Compiling versus interpreting
  • Compiling translates the high-level code into a
    target language code as a single unit
  • Interpreting translates the individual steps in
    the high level code one at a time. Each step is
    execute immediately after it is translated.

18
Software
  • Operating system (OS)
  • Software that controls and manages the systems
  • Fig. 1.6, page 36.
  • E.g. Windows (98, NT, XP, ME), MacOS, Linux etc.
  • Major tasks
  • Controlling and monitoring system activities
    (security, input, output, file directories, make
    sure programs running together do not interfere
    with each other)
  • Allocating and assigning system resources to
    program
  • Scheduling operations
  • Multiprogramming multiple programs to run
    simultaneously by sharing CPU
  • Multithreading allows concurrency within a
    program it subunits can run at the same time
    (e.g. editing and saving at the same time)
  • Multiprocessing/parallel processing use 2 or
    more processors together to perform a task.

19
What Is Java?
  • History
  • Characteristics of Java

20
History
  • James Gosling
  • Oak 1991, for embedded consumer electronic
    appliances
  • Renamed Java, 1995, for developing Internet
    applications
  • HotJava
  • The first Java-enabled Web browser
  • Java applets java programs that run from a Web
    browser
  • http//javaboutique.internet.com/movingtree/

21
Characteristics 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 is portable
  • Javas performance
  • Java is multithreaded
  • Java is dynamic

22
Java IDE Tools
  • Inprise JBuilder
  • Microsoft Visual J
  • Symantec Café
  • Forte by Sun MicroSystems
  • IBM Visual Age for Java
  • NetBeans 6.0 (free, open-source IDE, runs on
    Windows, Linux, Solaris, and the MacOS)
  • JCreator LE 4.0 (free) by Xinox Software

23
Java Language Specification, API, JDK and IDE
  • Java Language Specification
  • Technical definition of the language which
    includes the syntax and semantics of the Java
    Programming language (java.sun.com/docs/books/jls)
  • API
  • Contains predefined classes and interfaces for
    developing Java programs.
  • 3 editions of Java API
  • J2SE - version Java SE 6.0 (jdk1.6.0_02)
  • J2EE
  • J2ME

24
Java Language Specification, API, JDK and IDE
  • JDK
  • A set of programs for developing and testing Java
    program, each of which is invoked from a command
    line.
  • IDE (integrated development environment)
  • Software that provides integrated development
    environment (editing, compiling, building,
    debugging and online help) for rapidly developing
    Java program

25
Getting Started with Java Programming
  • A Simple Java Application
  • Compiling Programs
  • Executing Applications

26
A Simple Application
  • Example 1.1
  • //This application program prints Welcome
  • //to Java!
  • public class Welcome
  • public static void main(String args)
  • System.out.println("Welcome to Java!")

Run
Source
27
Creating, compiling and executing a Java Programs
  • Fig. 1.11, page 44.

28
Compiling Programs
  • On command line
  • javac file.java

29
Executing Applications
  • On command line
  • java classname

30
Example
  • javac Welcome.java
  • java Welcome
  • output...

31
Anatomy of a Java program
  • Comments
  • Reserved words
  • Modifier
  • Statement
  • Block
  • Class
  • Method
  • The main method

32
Anatomy of a Java program
  • Comments
  • Documents the program for understanding purpose
  • Ignored by compiler
  • //
  • / /
  • Reserved words or keywords
  • Words that have specific meaning to the compiler
    and cannot be used for other purposes in the
    program
  • E.g public, static, class, void

33
Anatomy of a Java program
  • Modifier
  • Certain reserved words are modifiers that specify
    the properties of the data, methods and class and
    how they can be used.
  • E.g public, private, static, final, abstract,
    protected.
  • Statement
  • Represents an action or a sequence of actions
  • Ends with semicolon ()
  • Block
  • Groups the components of the program
  • Begins with opening brace and ends with a
    closing brace
  • Class block, method block

34
Anatomy of a Java program
  • Class
  • Program is defined by using one or more class
  • Will be covered in more details later.
  • Method
  • A collection of statements that perform a
    sequence of operations.
  • Can be used without fully understanding how it
    works.
  • Invoke by calling the method name with the
    requirement argument
  • The main method
  • A special method where the program execution
    begins.
  • JVM invokes the main method to execute an
    application.

35
Summary
Write a Comment
User Comments (0)
About PowerShow.com