Presentation is loading. Please wait.

Presentation is loading. Please wait.

The University of Akron Summit College 2440: 160 Java Programming Introduction to Computers & Java Professor: Enoch E. Damson.

Similar presentations


Presentation on theme: "The University of Akron Summit College 2440: 160 Java Programming Introduction to Computers & Java Professor: Enoch E. Damson."— Presentation transcript:

1 The University of Akron Summit College 2440: 160 Java Programming Introduction to Computers & Java Professor: Enoch E. Damson

2 Introduction to Computers & Java2 Parts of an Information System Hardware Hardware Software Software Procedures Procedures Data Data People People

3 Introduction to Computers & Java3 Hardware Physical components of a computer Physical components of a computer Consists of: Consists of: Input devices Input devices Processor or Central Processing Unit (CPU) Processor or Central Processing Unit (CPU) Main memory Main memory Secondary storage devices Secondary storage devices Output devices Output devices

4 Introduction to Computers & Java4 Input Devices Collects data for the computer Collects data for the computer Common devices include: Common devices include: Keyboard Keyboard Mouse Mouse Scanner Scanner Digital camera Digital camera

5 Introduction to Computers & Java5 Central Processing Unit (CPU) Fetches instructions, follow the instructions, and produce some resulting data Fetches instructions, follow the instructions, and produce some resulting data Measured in terms of its speed in hertz (MHz, GHz) Measured in terms of its speed in hertz (MHz, GHz) Consists of two parts: Consists of two parts: Control Unit – coordinates all of the computers operations Control Unit – coordinates all of the computers operations Arithmetic & Logic Unit (ALU) – performs mathematical operations Arithmetic & Logic Unit (ALU) – performs mathematical operations

6 Introduction to Computers & Java6 Main Memory Commonly known as the random-access memory (RAM) Commonly known as the random-access memory (RAM) Measured in terms of its size in bytes (KB, MB, GB) Measured in terms of its size in bytes (KB, MB, GB) RAM is usually a volatile type of memory for temporary storage RAM is usually a volatile type of memory for temporary storage Divided into sections (bytes) that hold equal amount of data Divided into sections (bytes) that hold equal amount of data Each byte is made up of 8 binary digits (bits) that use 0 and 1 to represents on and off switches Each byte is made up of 8 binary digits (bits) that use 0 and 1 to represents on and off switches Each byte is a assigned a unique number known as an address, which are ordered from lowest to highest Each byte is a assigned a unique number known as an address, which are ordered from lowest to highest

7 Introduction to Computers & Java7 Secondary Storage Devices Type of memory that hold data for long periods of time Type of memory that hold data for long periods of time Measured in terms of their size in bytes (KB, MB, GB) Measured in terms of their size in bytes (KB, MB, GB) Common types of secondary storage devices include: Common types of secondary storage devices include: Hard disks Hard disks Jump drives Jump drives Zip disks Zip disks Floppy disks Floppy disks

8 Introduction to Computers & Java8 Output Devices Formats and presents processed data (information) to the outside world Formats and presents processed data (information) to the outside world Common devices include: Common devices include: Monitors Monitors Printers Printers

9 Introduction to Computers & Java9 Software Programs that run on a computer Programs that run on a computer Has two general categories: Has two general categories: System software – enables application software to interact with the computer hardware System software – enables application software to interact with the computer hardware E.g. operating systems, utilities, device drivers, and programming languages E.g. operating systems, utilities, device drivers, and programming languages Application software – programs that solve specific problems or perform general operations useful to the user Application software – programs that solve specific problems or perform general operations useful to the user E.g. word processors, spreadsheets, etc E.g. word processors, spreadsheets, etc

10 Introduction to Computers & Java10 Procedures Rules or guidelines for people to follow when using software, hardware, and data Rules or guidelines for people to follow when using software, hardware, and data Guidelines are documented in manuals Guidelines are documented in manuals

11 Introduction to Computers & Java11 Data Raw facts entered into the computer system for processing Raw facts entered into the computer system for processing Processed to produce information Processed to produce information

12 Introduction to Computers & Java12 People Making people more productive is what computers are all about Making people more productive is what computers are all about Users include: Users include: Analysts Analysts Designers Designers Developers Developers End-users End-users

13 Introduction to Computers & Java13 Computer Program Set of instructions that enables the computer to solve a problem or perform a task Set of instructions that enables the computer to solve a problem or perform a task The instructions are called algorithms The instructions are called algorithms A computers CPU can only process algorithms written in machine language – consisting of binary numbers (0s and 1s) A computers CPU can only process algorithms written in machine language – consisting of binary numbers (0s and 1s) E.g E.g Each different type of CPU has its own machine language Each different type of CPU has its own machine language Algorithms written with programming languages are much easier to understand Algorithms written with programming languages are much easier to understand

14 Introduction to Computers & Java14 Computer Programming An art and a science of creating instructions to solve problems and perform tasks An art and a science of creating instructions to solve problems and perform tasks An art because every aspect of the program should be carefully designed An art because every aspect of the program should be carefully designed A science because of the need to indulge in the tasks of analyzing, experimenting, correcting, and redesigning A science because of the need to indulge in the tasks of analyzing, experimenting, correcting, and redesigning

15 Program Development (Programming) Cycle The process of writing instructions (programs) for a computer to solve a problem The process of writing instructions (programs) for a computer to solve a problem Programming steps include: Programming steps include: 1. Creating program specifications 2. Designing the application 3. Writing source code 4. Compiling/Interpreting programs 5. Executing (running) program Introduction to Computers & Java15

16 Program Development (Programming) Cycle… Creating program specifications – the requirements the application must meet Creating program specifications – the requirements the application must meet Introduction to Computers & Java16

17 Program Development (Programming) Cycle… Designing the application – create file formats, screen layouts, and algorithms Designing the application – create file formats, screen layouts, and algorithms Algorithm – a sequence of procedures, programming code, or commands that are used as part of a program or result in a program Algorithm – a sequence of procedures, programming code, or commands that are used as part of a program or result in a program Tools used in designing the sequential and logical structure of a program include: Tools used in designing the sequential and logical structure of a program include: Flowchart – uses symbols for program design Flowchart – uses symbols for program design Pseudocode – uses natural English for program design Pseudocode – uses natural English for program design Introduction to Computers & Java17

18 Program Development (Programming) Cycle… Writing source code – the code must be written, tested and debugged Writing source code – the code must be written, tested and debugged Source code (file) – the file with the actual code which is written with a programming language of choice in a text editor Source code (file) – the file with the actual code which is written with a programming language of choice in a text editor Debugging – the process of going through program code to locate and fix errors such as: Debugging – the process of going through program code to locate and fix errors such as: Syntax errors – grammatical mistakes in program language use Syntax errors – grammatical mistakes in program language use Logical errors – logical mistakes in a program Logical errors – logical mistakes in a program Introduction to Computers & Java18

19 Program Development (Programming) Cycle… Compiling/Interpreting programs – the source code is translated in its entirety at one time (compiled) or a single line at a time (interpreted) from high-level program instructions into machine language, and executed if no errors are found (run) Compiling/Interpreting programs – the source code is translated in its entirety at one time (compiled) or a single line at a time (interpreted) from high-level program instructions into machine language, and executed if no errors are found (run) Introduction to Computers & Java19

20 Program Development (Programming) Cycle… Compiling/Interpreting programs Compiling/Interpreting programs Compiler – a system software program that translates an entire high-level program (source code) at one time into machine language (object code grouped together in files called library files) that the computer can interpret and execute Compiler – a system software program that translates an entire high-level program (source code) at one time into machine language (object code grouped together in files called library files) that the computer can interpret and execute It gives no feedback until the entire program has been compiled It gives no feedback until the entire program has been compiled Interpreter – a system software program that translates a single line at a time in a program Interpreter – a system software program that translates a single line at a time in a program An immediate feedback is given if the code contains an error An immediate feedback is given if the code contains an error Introduction to Computers & Java20

21 Program Development (Programming) Cycle… Executing (running) program – the compiled or interpreted code is executed if no errors are found Executing (running) program – the compiled or interpreted code is executed if no errors are found Executable code – a linker or link editor resolves object code references to other programs by creating an executable code. Executable code – a linker or link editor resolves object code references to other programs by creating an executable code. Introduction to Computers & Java21

22 Introduction to Computers & Java22 Programming Languages Invented to ease the task of programming with the use of words instead of binary numbers Invented to ease the task of programming with the use of words instead of binary numbers Programming languages have evolved in generations and are improved over the years Programming languages have evolved in generations and are improved over the years The generations of programming languages include: The generations of programming languages include: Low-level languages Low-level languages High-level languages High-level languages

23 Introduction to Computers & Java23 Programming Languages… Low-level languages – include: Low-level languages – include: Machine language (1 st Generation) – instructions are coded as a series of 0s and 1s and are unique to a particular computer Machine language (1 st Generation) – instructions are coded as a series of 0s and 1s and are unique to a particular computer Assembler language (2 nd Generation) – instructions are coded using some recognized symbols called mnemonics (memory aids) and are also unique to a particular computer Assembler language (2 nd Generation) – instructions are coded using some recognized symbols called mnemonics (memory aids) and are also unique to a particular computer Example: MUL is used to represent a multiply instruction. An assembler translates the mnemonics into 0s and 1s Example: MUL is used to represent a multiply instruction. An assembler translates the mnemonics into 0s and 1s

24 Introduction to Computers & Java24 Programming Languages… High-level languages – programs instructions are often written in English-like expressions in languages such as: High-level languages – programs instructions are often written in English-like expressions in languages such as: 3 rd Generation languages – instructions are coded at the programmers convenience but cannot be executed in their original form (source code) 3 rd Generation languages – instructions are coded at the programmers convenience but cannot be executed in their original form (source code) A compiler or interpreter is needed to translate the language syntax into low- level machine language to be executed. A compiler or interpreter is needed to translate the language syntax into low- level machine language to be executed. Examples include: FORTRAN (FORmula TRANslator)-1955, Pascal- 1968, C-1972, C s, Java-1990 Examples include: FORTRAN (FORmula TRANslator)-1955, Pascal- 1968, C-1972, C s, Java th Generation languages – Has a graphical user interface (GUI) that combines a code editor, compiler, debugger, linker, and executor into a single Inter-Development Environment (IDE). 4 th Generation languages – Has a graphical user interface (GUI) that combines a code editor, compiler, debugger, linker, and executor into a single Inter-Development Environment (IDE). Examples include: Visual Basic, Delphi, PowerBuilder, Visual.NET, etc Examples include: Visual Basic, Delphi, PowerBuilder, Visual.NET, etc

25 Introduction to Computers & Java25 Programming Language Elements Every programming language uses the following general program elements: Every programming language uses the following general program elements: Syntax – rules of a programming language Syntax – rules of a programming language Comments – non executing programming language statements Comments – non executing programming language statements Constant data – raw data used in programming such as numbers, strings, etc Constant data – raw data used in programming such as numbers, strings, etc Data output – displaying data on a screen or sending data to a file Data output – displaying data on a screen or sending data to a file Data input – receiving data from the keyboard or file Data input – receiving data from the keyboard or file Variables – named memory locations for data storage Variables – named memory locations for data storage

26 Introduction to Computers & Java26 Programming Language Elements… Other programming language elements include: Other programming language elements include: Data types – specifies the types of data native to the programming language Data types – specifies the types of data native to the programming language Keywords – words with a special meaning in the programming language Keywords – words with a special meaning in the programming language Operators – symbols or words that perform operations on operands Operators – symbols or words that perform operations on operands Selections (Condition testing) Selections (Condition testing) Repetitions (Looping structures) Repetitions (Looping structures) Arrays Arrays Files/Databases Files/Databases

27 Introduction to Computers & Java27 Methods of Programming Two primary methods of programming are: Two primary methods of programming are: Procedural – creates programs made up of variables and procedures Procedural – creates programs made up of variables and procedures Variable – named storage location in a computers memory Variable – named storage location in a computers memory Procedure – set of programming language statements that perform a specific task Procedure – set of programming language statements that perform a specific task Object-oriented – creates programs made up of objects (instances of a class) Object-oriented – creates programs made up of objects (instances of a class) Object – a software entity with attributes (fields) and procedures (methods) Object – a software entity with attributes (fields) and procedures (methods) Class – specifies the attributes and methods of objects Class – specifies the attributes and methods of objects

28 Introduction to Computers & Java28 Principles of Object-Oriented Programming (OOP) Encapsulation – grouping data (fields, methods, etc) into a single object Encapsulation – grouping data (fields, methods, etc) into a single object Information Hiding (Abstraction) – hiding an objects data from other objects Information Hiding (Abstraction) – hiding an objects data from other objects The objects methods are used directly access its data The objects methods are used directly access its data Typically, the objects data is hidden but allows its methods to be accessed Typically, the objects data is hidden but allows its methods to be accessed Inheritance – deriving classes (subclasses) based on other existing classes (superclasses) Inheritance – deriving classes (subclasses) based on other existing classes (superclasses) Polymorphism - using the same procedure name or operator with different types of arguments Polymorphism - using the same procedure name or operator with different types of arguments There are 2 types of polymorphism: overloading and overriding There are 2 types of polymorphism: overloading and overriding

29 Introduction to Computers & Java29 History of Java In 1991 the Green Team was formed at Sun Microsystems to develop a hand-held device (named *7) to control home entertainment devices In 1991 the Green Team was formed at Sun Microsystems to develop a hand-held device (named *7) to control home entertainment devices James Gosling (the project leader) created the Oak language for the project James Gosling (the project leader) created the Oak language for the project The Oak language translated programs into byte code for different processors The Oak language translated programs into byte code for different processors Oak (renamed Java) was later used to develop a Web browser named HotJava – which was able to download and run small Java programs known as applets Oak (renamed Java) was later used to develop a Web browser named HotJava – which was able to download and run small Java programs known as applets HotJava was demonstrated in 1995 which made Java popular HotJava was demonstrated in 1995 which made Java popular Netscape later incorporated Java into its Navigator browser Netscape later incorporated Java into its Navigator browser

30 Introduction to Computers & Java30 Types of Java Programs Two types of Java programs are: Two types of Java programs are: Application – stand-alone programs that run on a computer Application – stand-alone programs that run on a computer Applets – programs that are transmitted over the Internet from a Web server and executed on a Web browser Applets – programs that are transmitted over the Internet from a Web server and executed on a Web browser

31 Introduction to Computers & Java31 Properties of Java Object-Oriented – uses objects to perform specific tasks Object-Oriented – uses objects to perform specific tasks Portable – enables programs to behave identical on different platforms like: Mac, Windows, Solaris (UNIX) Portable – enables programs to behave identical on different platforms like: Mac, Windows, Solaris (UNIX) Compiles into byte code instead of machine language – the byte code is read by the Java Virtual Machine (JVM) – which interprets the code for different processors Compiles into byte code instead of machine language – the byte code is read by the Java Virtual Machine (JVM) – which interprets the code for different processors Architecture-neutral – the byte code that comes out of the compiler will run on any processor and operating system Architecture-neutral – the byte code that comes out of the compiler will run on any processor and operating system Can be embedded on Web pages – applets are downloaded and ran from Web pages Can be embedded on Web pages – applets are downloaded and ran from Web pages Secured – Web browsers run applets in a secure environment within a computers memory Secured – Web browsers run applets in a secure environment within a computers memory

32 Introduction to Computers & Java32 The Java Compiler & Java Virtual Machine (JVM) Text editors are used to write Java programming statements (source code) and saved in a source file (.java extension) and translated (compiled) by a compiler Text editors are used to write Java programming statements (source code) and saved in a source file (.java extension) and translated (compiled) by a compiler Compiler – program that translates source code into an executable form Compiler – program that translates source code into an executable form Java compilers translate source code into a file (.class extension) containing byte code Java compilers translate source code into a file (.class extension) containing byte code The byte code instructions (not machine language) are executed by the Java Virtual Machine (JVM) The byte code instructions (not machine language) are executed by the Java Virtual Machine (JVM) The JVM simulates a computer whose machine language is the Java byte code The JVM simulates a computer whose machine language is the Java byte code

33 Introduction to Computers & Java33 Java Program Development Process 1. The programmer uses a text edit to create a Java source code file (.java extension) 2. The programmer runs the compiler to translate the source code file into a byte code file (.class extension) 3. The Java Virtual Machine (JVM) reads and executes each byte code instruction Text Editor Source File Java Compiler Byte Code File Java Virtual Machine

34 Introduction to Computers & Java34 Java Editions The software used to create Java programs is known as the Java Development Kit (JDK) or the Software Development Kit (SDK) The software used to create Java programs is known as the Java Development Kit (JDK) or the Software Development Kit (SDK) Some Java editions include: Some Java editions include: Java Standard Edition (Java SE) – used for writing Java applications and applets Java Standard Edition (Java SE) – used for writing Java applications and applets Java Enterprise Edition (Java EE) – used to create business client/server and Web server-based applications Java Enterprise Edition (Java EE) – used to create business client/server and Web server-based applications Java Micro Edition (Java ME) – runtime- environment for consumer products like cell phones, pagers, etc Java Micro Edition (Java ME) – runtime- environment for consumer products like cell phones, pagers, etc

35 Introduction to Computers & Java35 Java Integrated Development Environments (IDE) Consists of text editor, compiler, debugger, and other utilities integrated into a package Consists of text editor, compiler, debugger, and other utilities integrated into a package Current popular Java IDEs include: Current popular Java IDEs include: Eclipse (http://www.eclipse.org) Eclipse (http://www.eclipse.org)http://www.eclipse.org NetBeans (http://www.netbeans.org) NetBeans (http://www.netbeans.org)http://www.netbeans.org IntelliJ IDEA (http://www.jetbrains.com/idea) IntelliJ IDEA (http://www.jetbrains.com/idea)http://www.jetbrains.com/idea jGRASP (http://www.jgrasp.org) jGRASP (http://www.jgrasp.org)http://www.jgrasp.org

36 Introduction to Computers & Java36 Compiling & Running Java Programs javac is used to compile Java programs javac is used to compile Java programs E.g. javac Hello.java E.g. javac Hello.java A.class file is created if no are found A.class file is created if no are found java is used to run Java programs java is used to run Java programs E.g. java Hello E.g. java Hello Two types of errors (bugs) are: Two types of errors (bugs) are: Syntax errors – mistakes that violate the rules of the programming language Syntax errors – mistakes that violate the rules of the programming language Logical errors – mistakes that cause programs to produce erroneous results Logical errors – mistakes that cause programs to produce erroneous results


Download ppt "The University of Akron Summit College 2440: 160 Java Programming Introduction to Computers & Java Professor: Enoch E. Damson."

Similar presentations


Ads by Google