Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.

Similar presentations


Presentation on theme: "Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java."— Presentation transcript:

1 Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java

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

3 Lesson 1 3 OO Concepts continued…. l 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 Lesson 1 4 OO Concepts continued…. l 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 Lesson 1 5 OO Concepts continued…. l 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 Lesson 1 6 OO Concepts continued…. l What is a Class? »A blueprint, or prototype, that defines the variables & the methods common to all objects of a certain kind. l What is Inheritance? »A class inherits state & behaviour from its superclass. Allows code reuse.

7 Lesson 1 7 OO Concepts continued…. l 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 Lesson 1 8 OO Concepts continued…. l 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 Lesson 1 9 Object-Oriented Programming l OOP l A design and programming technique l 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) l Objects have both data and methods l Objects of the same class have the same data elements and methods l Objects send and receive messages to invoke actions

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

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

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

13 Lesson 1 13 Compilers vs. Assemblers vs. Interpreters l Compilers and Assemblers »translation is a separate user step »translation is “off-line,” i.e. not at run time l 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 Source Code Object Code

14 Lesson 1 14 Java Program Translation l Both Compilation and Interpretation l Intermediate Code: “Byte Code” »portable low-level code »similar to assembly code, but hardware independent »invisible to Java programmer l Interpreter translates from generic byte code to hardware-specific machine code Java Program Data for Java Program Java Compiler Byte-Code Program Byte-Code Interpreter Machine-Language Instructions Computer Execution of Machine-Language Instructions Output of Java Program Java Virtual Machine

15 Java Program Data for Java Program Java Compiler Byte-Code Program Byte-Code Interpreter Machine-Language Instructions Computer Execution of Machine-Language Instructions Output of Java Program Java Virtual Machine Linker Previously Compiled Helper Programs Java Program Translation Including Linker

16 Lesson 1 16 Java Virtual Machine l The JVM executes a special machine code ("bytecode") »Java compiles to *.class files l “Imaginary” computer »Simulated – by an Interpreter l Advantage »Enables platform independence l Disadvantage »Takes longer to interpret than the “norm” (compiled)

17 Lesson 1 17 Applets vs. Java Applications l Applets »Java programs intended to be downloaded via the WWW and run immediately »“little applications” »requires a web browser l Applications »Java programs intended to be installed then run »often larger applications l Slightly different programming for each, but both are easy to do


Download ppt "Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java."

Similar presentations


Ads by Google