Background information - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Background information

Description:

Machine. Linker. Previously Compiled Helper Programs. Java Program Translation Including Linker. Lesson 1. 16. Java Virtual Machine ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 18
Provided by: LewRa5
Category:

less

Transcript and Presenter's Notes

Title: Background information


1
LESSON 1
Introduction and a Taste of Java
  • Background information
  • Introduction to Java

2
Object-Oriented Concepts
  • What is an Object?
  • A software bundle of related variable methods.
    Often used to model real-world objects.
  • What is a Method?
  • A function (subroutine) associated with an object.

3
OO Concepts continued.
  • What is Modularity?
  • The source code for an object can be written
    maintained independently of the source code for
    other objects.
  • Object can be easily passed around in the system.

4
OO Concepts continued.
  • What is Encapsulation?
  • Data actions are combined into a single item (a
    class object) the details of the implementation
    are hidden.
  • An object has a public interface that other
    objects use to communicate with it.
  • Information hiding, Abstract data types
    Encapsulation refer to basically the same idea.

5
OO Concepts continued.
  • What is a Message?
  • Software objects interact communicate with each
    other using messages.
  • Message components are
  • object to which message is addressed
  • name of the method to perform
  • any parameters needed by the method

6
OO Concepts continued.
  • What is a Class?
  • A blueprint, or prototype, that defines the
    variables the methods common to all objects of
    a certain kind.
  • What is Inheritance?
  • A class inherits state behaviour from its
    superclass. Allows code reuse.

7
OO Concepts continued.
  • What is an Interface?
  • A contract in the form of a collection of method
    constant declarations.
  • A device or a system that unrelated entities use
    to interact.
  • When a class implements an interface, it promises
    to implement all of the methods declared in that
    interface.

8
OO Concepts continued.
  • What is Polymorphism?
  • Ability of one thing to have several forms, or
    one form to apply to several things.
  • E.g. two different classes can have methods with
    the same name.

9
Object-Oriented Programming
  • OOP
  • A design and programming technique
  • Some terminology
  • object - usually a person, place or thing (a
    noun)
  • method - an action performed by an object (a
    verb)
  • type or class - a category of similar objects
    (such as automobiles)
  • Objects have both data and methods
  • Objects of the same class have the same data
    elements and methods
  • Objects send and receive messages to invoke
    actions

10
Example of an Object Class
Class automobile
  • Data Items
  • manufacturers name
  • model name
  • year made
  • color
  • number of doors
  • size of engine
  • etc.
  • Methods
  • Define/Assign data items (specify manufacturers
    name, model, year, etc.)
  • Change a data item (color, engine, etc.)
  • Display data items
  • Calculate cost
  • etc.

11
Why OOP?
  • Save development time (and cost) by reusing code
  • once an object class is created it can be used in
    other applications
  • Easier debugging
  • classes can be tested independently
  • reused objects have already been tested

12
Java Characteristics
  • Platform independent
  • Virtual machine architecture
  • Object-oriented
  • Full GUI multimedia support
  • Also platform independent
  • Multi-threading capabilities
  • Parallel programs
  • Applications (locally) Applets (remotely)

13
Compilers vs. Assemblers vs. Interpreters
  • Compilers and Assemblers
  • translation is a separate user step
  • translation is off-line, i.e. not at run time
  • Interpreters - another way to translate source to
    object code
  • interpretation (from source to object code) is
    not a separate user step
  • translation is on-line, i.e. at run time

Compiler, Assembler, or Interpreter
Object Code
Source Code
14
Java Program Translation
Data for Java Program
Java Program
  • Both Compilation and Interpretation
  • Intermediate CodeByte Code
  • portable low-level code
  • similar to assembly code,but hardware
    independent
  • invisible to Java programmer
  • Interpreter translates from generic byte code to
    hardware-specific machine code

JavaVirtual Machine
Java Compiler
Byte-Code Program
Byte-Code Interpreter
Machine-Language Instructions
Computer Execution of Machine-Language
Instructions
Output of Java Program
15
Java Program Translation Including Linker
Data for Java Program
Previously Compiled Helper Programs
Java Program
Java Compiler
JavaVirtual Machine
Byte-Code Program
Byte-Code Interpreter
Machine-Language Instructions
Linker
Computer Execution of Machine-Language
Instructions
Output of Java Program
16
Java Virtual Machine
  • The JVM executes a special machine code
    ("bytecode")
  • Java compiles to .class files
  • Imaginary computer
  • Simulated by an Interpreter
  • Advantage
  • Enables platform independence
  • Disadvantage
  • Takes longer to interpret than the norm
    (compiled)

17
Applets vs. Java Applications
  • Applets
  • Java programs intended to be downloaded via the
    WWW and run immediately
  • little applications
  • requires a web browser
  • Applications
  • Java programs intended to be installed then run
  • often larger applications
  • Slightly different programming for each, but both
    are easy to do
Write a Comment
User Comments (0)
About PowerShow.com