Chapter 1 Introduction to Computers and Java

48 slides
0.97 MB
782 views

Similar Presentations

Presentation Transcript

1

Introduction to Computers and JavaChapter 1

2

OutlineComputer Basics Designing Programs A Sip of Java

3

Computer Basics: OutlineHardware and Memory Programs Programming Languages and Compilers Java Byte-Code

4

Hardware and SoftwareComputer systems consist of hardware and software. Hardware includes the tangible parts of computer systems. Software includes programs - sets of instructions for the computer to follow. Familiarity with hardware basics helps us understand software.

5

Hardware and MemoryMost modern computers have similar components including Input devices (keyboard, mouse, etc.) Output devices (display screen, printer, etc.) A processor Two kinds of memory (main memory and auxiliary memory).

6

The ProcessorAlso called the CPU (central processing unit) or the chip (e.g. Pentium processor) The processor processes a program’s instructions. It can process only very simple instructions. The power of computing comes from speed and program intricacy.

7

MemoryMemory holds programs data for the computer to process the results of intermediate processing. Two kinds of memory main memory auxiliary memory

8

Main memoryWorking memory used to store The current program The data the program is using The results of intermediate calculations Usually measured in megabytes or gigabytes (e.g. 512 megabytes or 2 gigabytes) RAM is short for random access memory A byte is a quantity of memory

9

Auxiliary MemoryAlso called secondary memory Disk drives, CDs, DVDs etc. More or less permanent (nonvolatile) Usually measured in gigabytes (e.g. 300 gigabyte hard drive)

10

Bits, Bytes, and AddressesA bit is a digit with a value of either 0 or 1. A byte consists of 8 bits. Each byte in main memory resides at a numbered location called its address.

11

Main MemoryFigure 1.1

12

Storing DataData of all kinds (numbers, letters, strings of characters, audio, video, even programs) are encoded and stored using 1s and 0s. When more than a single byte is needed, several adjacent bytes are used. The address of the first byte is the address of the unit of bytes.

13

FilesLarge groups of bytes in auxiliary memory are called files. Files have names. Files are organized into groups called directories or folders. Java programs are stored in files. Programs files are copied from auxiliary memory to main memory in order to be run.

14

0s and 1sMachines with only 2 stable states are easy to make, but programming using only 0s and 1s is difficult. Fortunately, the conversion of numbers, letters, strings of characters, audio, video, and programs is done automatically.

15

ProgramsA program is a set of instructions for a computer to follow. We use programs almost daily (email, word processors, video games, bank ATMs, etc.). Following the instructions is called running or executing the program.

16

Input and OutputNormally, a computer receives two kinds of input: The program The data needed by the program. The output is the result(s) produced by following the instructions in the program.

17

Running a ProgramFigure 1.2 Sometimes the computer and the program are considered to be one unit. Programmers typically find this view to be more convenient.

18

The Operating SystemThe operating system is a supervisory program that oversees the operation of the computer. The operating system retrieves and starts program for you. Well-known operating systems including: Microsoft Windows, Apple’s Mac OS, Linux, and UNIX.

19

Programming LanguagesHigh-level languages are relatively easy to use Java, C#, C++, Visual Basic, Python, Ruby. Unfortunately, computer hardware does not understand high-level languages. Therefore, a high-level language program must be translated into a low-level language.

20

CompilersA compiler translates a program from a high-level language to a low-level language the computer can run. You compile a program by running the compiler on the high-level-language version of the program called the source program. Compilers produce machine- or assembly-language programs called object programs.

21

CompilersMost high-level languages need a different compiler for each type of computer and for each operating system. Most compilers are very large programs that are expensive to produce.

22

Java Byte-CodeThe Java compiler does not translate a Java program into assembly language or machine language for a particular computer. Instead, it translates a Java program into byte-code. Byte-code is the machine language for a hypothetical computer (or interpreter) called the Java Virtual Machine.

23

Java Byte-CodeA byte-code program is easy to translate into machine language for any particular computer. A program called an interpreter translates each byte-code instruction, executing the resulting machine-language instructions on the particular computer before translating the next byte-code instruction.

24

Compiling, Interpreting, RunningUse the compiler to translate the Java program into byte-code (done using the compile command). Use the byte-code interpreter for your computer to translate each byte-code instruction into machine language and to run the resulting machine-language instructions (done using the run command).

25

PortabilityAfter compiling a Java program into byte-code, that byte-code can be used on any computer with a byte-code interpreter and without a need to recompile. Byte-code can be sent over the Internet and used anywhere in the world. This makes Java suitable for Internet applications.

26

Class LoaderA Java program typically consists of several pieces called classes. Each class may have a separate author and each is compiled (translated into byte-code) separately. A class loader (called a linker in other programming languages) automatically connects the classes together.

Browse More Presentations

Last Updated: 8th March 2018

Recommended PPTs