Presentation is loading. Please wait.

Presentation is loading. Please wait.

OOP with Java, David J. Barnes Bits, Bytes, and Java1 The Challenge Writing programs well is a challenge. –From coder to software engineer. We want programs.

Similar presentations


Presentation on theme: "OOP with Java, David J. Barnes Bits, Bytes, and Java1 The Challenge Writing programs well is a challenge. –From coder to software engineer. We want programs."— Presentation transcript:

1 OOP with Java, David J. Barnes Bits, Bytes, and Java1 The Challenge Writing programs well is a challenge. –From coder to software engineer. We want programs to solve ever more complex problems. Java TM helps to bridge the gap between a problem and its solution.

2 OOP with Java, David J. Barnes Bits, Bytes, and Java2 A Simple Model of a Computer Hardware –Central Processing Unit (CPU). –Random Access Memory (RAM). –Disk drives, keyboard, mouse, printer, etc. Look-and-Feel Software –Window manager. –Operating system.

3 OOP with Java, David J. Barnes Bits, Bytes, and Java3 Bits Bit - A Binary Digit –Has a value of either 0 or 1. –A variety of hardware representations. Voltage, light level, magnetic field, etc. –The fundamental building block for modeling data.

4 OOP with Java, David J. Barnes Bits, Bytes, and Java4 Using Bits to Model Real-Life Objects Bits allow us to model real-world states. –2 bits model four door states. –3 bits model eight colors. Redundant values represent impossible states. Objects (models) should not enter impossible or inconsistent states.

5 OOP with Java, David J. Barnes Bits, Bytes, and Java5 Bytes 8 bits is known as a byte. One byte can represent 256 different patterns. Hardware and software often deal with bytes rather than single bits. –64 Megabytes of memory. –8 Gigabytes of disk. –4 byte data type.

6 OOP with Java, David J. Barnes Bits, Bytes, and Java6 Common Powers of 2 2 0 = 1 2 1 = 2 2 8 = 256 2 10 = 1, 024 (Kilo) 2 16 = 65,536 (2 bytes) 2 20 = 1, 048,576 (Mega) 2 30 = 1,073,741,824 (Giga) 2 40 = 1,099,511,627,776 (Tera)

7 OOP with Java, David J. Barnes Bits, Bytes, and Java7 The Central Processing Unit The computational heart of a computer. A CPU obeys its own instruction set. Individual instructions are usually simple. Programs often only run on a CPU with a particular instruction set. –Such programs are not portable.

8 OOP with Java, David J. Barnes Bits, Bytes, and Java8 The Fetch-Execute Cycle Endlessly repeated by the CPU. –Fetch the next instruction. –Execute the instruction just fetch. The instructions are fetched from the computer’s fast-access memory. The program counter identifies the next instruction. –It is incremented between each step.

9 OOP with Java, David J. Barnes Bits, Bytes, and Java9 Skipping and Repeating Instructions The fetch-execute cycle will perform an infinite linear sequence of instructions. –We often want to repeat some instructions. –We often want to skip some instructions. Branching is achieved by modifying the program counter’s contents. –This alters which instruction is fetched next.

10 OOP with Java, David J. Barnes Bits, Bytes, and Java10 High Level Programming Languages CPU instruction sets are low-level programming languages. High level programming languages represent attempts to make writing programs easier. –Ada TM Algol, BASIC, C, C++, COBOL, FORTRAN, Java, Pascal, etc.

11 OOP with Java, David J. Barnes Bits, Bytes, and Java11 Java’s Ancestry Oak: a reimplementation of C++ in the early 1990s by James Gosling. –Intended for intelligent consumer devices. Oak became Java in 1995. –Portability and Security of primary concern. –Eminently suitable for Web applets. –Also a powerful language in its own right.

12 OOP with Java, David J. Barnes Bits, Bytes, and Java12 Program Translation High-level languages provide data types and control structures. A high-level language program must be translated into low-level instructions. –Compilation. –Increases a program’s portability. –Translated versions may differ in subtle ways on different machines.

13 OOP with Java, David J. Barnes Bits, Bytes, and Java13 Java's Approach to Portability Its implementation on different machines is rigidly defined. It is defined to be run on a virtual machine. –The JVM is an imaginary CPU with bytecode instructions. Java programs are translated to bytecodes by the Java compiler. Converted programs are interpreted.

14 OOP with Java, David J. Barnes Bits, Bytes, and Java14 Review A single bit has a value of either 0 or 1. A byte is 8 bits. A CPU repeats the fetch-execute cycle. Each CPU has its own instruction set. High-level languages must be translated. Java programs are translated into bytecodes for a Java Virtual Machine.


Download ppt "OOP with Java, David J. Barnes Bits, Bytes, and Java1 The Challenge Writing programs well is a challenge. –From coder to software engineer. We want programs."

Similar presentations


Ads by Google