Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Programming: Guided Learning with Early Objects Chapter 0 An Overview of Computer and Programming Languages.

Similar presentations


Presentation on theme: "Java Programming: Guided Learning with Early Objects Chapter 0 An Overview of Computer and Programming Languages."— Presentation transcript:

1 Java Programming: Guided Learning with Early Objects Chapter 0 An Overview of Computer and Programming Languages

2 Java Programming: Guided Learning with Early Objects2 Objectives Learn about different types of computers Explore the hardware and software components of a computer system Learn about the language of a computer Learn about the evolution of programming languages Examine high-level programming languages

3 Java Programming: Guided Learning with Early Objects3 Objectives (continued) Discover what a compiler is and what it does Examine how a Java program is processed Learn what an algorithm is and explore problem-solving techniques Become familiar with structured and object- oriented programming design methodologies

4 Java Programming: Guided Learning with Early Objects4 Introduction Without software the computer is useless Software developed with programming languages –Java is a programming language Java suited for a wide variety of programming tasks Before programming, it is useful to understand terminology and computer components

5 Java Programming: Guided Learning with Early Objects5 An Overview of the History of Computers Abacus: first device to calculate –Invented in Asia –Used in ancient Babylonia, China, Europe until the Middle Ages –Performed addition and subtraction

6 Java Programming: Guided Learning with Early Objects6 An Overview of the History of Computers (continued) 1642: Blaise Pascal invented the Pascaline –Eight dials on wheels –Calculated figures up to eight figures long –Performed addition and subtraction 17 th Century: Gottfried von Leibniz –Invented a device that could add, subtract, multiply, and divide

7 Java Programming: Guided Learning with Early Objects7 An Overview of the History of Computers (continued) 1819: Joseph Jacquard –Weaving instructions stored on cards with holes punched in them –Cards moved through the loom in sequence –Needles passed through holes, picked up threads of correct color and texture –Cards rearranged to change the pattern

8 Java Programming: Guided Learning with Early Objects8 An Overview of the History of Computers (continued) Early and mid-1800s: Charles Babbage –English mathematician and physical scientist –Difference engine Performed complex operations automatically –Analytical engine Included an output device, data storage, control unit, output devices –Designs remained as blueprints

9 Java Programming: Guided Learning with Early Objects9 An Overview of the History of Computers (continued) Ada Augusta, Countess of Lovelace –Method to calculate Bernoulli numbers –First computer program End of 19 th century: Herman Hollerith –Machine that ran on electricity, stored census data on punch cards –Tabulating Machine Company became IBM

10 Java Programming: Guided Learning with Early Objects10 An Overview of the History of Computers (continued) 1944: Howard Aiken –Mark I built by IBM and Harvard –Punched cards fed data into the machine –52 ft. long, 50 tons, 750,000 parts 1946: ENIAC built at University of Pennsylvania –18,000 vacuum tubes, 30 tons Late 1940s: John von Neumann –Arithmetic logic unit, control unit, memory, input/output devices

11 Java Programming: Guided Learning with Early Objects11 An Overview of the History of Computers (continued) 1951: UNIVAC 1956: Transistor invented –Faster, more reliable, energy-efficient computers –FORTRAN and COBOL –Transistors replaced by chips 1970: Microprocessor 1977: Stephen Wozniak and Steven Jobs –Built the Apple computer in their garage

12 Java Programming: Guided Learning with Early Objects12 An Overview of the History of Computers (continued) 1981: IBM introduced the PC –Clones of IBM PC made computers affordable Mid-1990s: people from all walks of life can afford computers Today: –Powerful reliable computers –Mobile computing applications growing

13 Java Programming: Guided Learning with Early Objects13 Elements of a Computer System Computer: electronic device capable of performing commands Basic commands: –Input –Storage –Arithmetic and logic operations –Output Two categories of specifications: –Hardware –Software

14 Java Programming: Guided Learning with Early Objects14 Hardware Central Processing Unit –“Brain” of the computer –Single most expensive piece of hardware –Main components: Control Unit (CU) Arithmetic Logic Unit (ALU) Registers

15 Java Programming: Guided Learning with Early Objects15 Hardware (continued) Control Unit (CU) –Fetch, decode instructions –Control information flow Arithmetic Logic Unit (ALU) –Arithmetic and logical operations Instruction register and program counter

16 Java Programming: Guided Learning with Early Objects16 Figure 0-1 Hardware components of a computer

17 Java Programming: Guided Learning with Early Objects17 Hardware (continued) Main memory: random access memory (RAM) –All programs loaded into main memory before being executed –All data must be brought into main memory before a program can manipulate it –Everything lost when computer turned off

18 Java Programming: Guided Learning with Early Objects18 Hardware (continued) Memory cells –Ordered sequence of cells –Each cell has unique address as 0s and 1s –Today’s computers have billions of cells

19 Java Programming: Guided Learning with Early Objects19 Figure 0-2 Main memory with some data

20 Java Programming: Guided Learning with Early Objects20 Hardware (continued) Secondary Storage –Stores longer-term information –Components connected directly to each other –Examples: hard disks, flash memory, CD-ROM

21 Java Programming: Guided Learning with Early Objects21 Hardware (continued) Input/Output Devices –Input devices feed data and programs into computers Keyboard, mouse, secondary storage –Output devices display and store results Monitor, printer, secondary storage

22 Java Programming: Guided Learning with Early Objects22 Software Programs written to perform specific tasks System programs –Control the computer –Operating system monitors overall activity of the computer Memory management, input/output activities, storage management Application programs –Perform specific tasks Word processors, spreadsheets, games

23 Java Programming: Guided Learning with Early Objects23 Language of a Computer Electrical signals move along channels Analog signals: continuous waveforms represent things such as sound –Audio tapes store data in analog signals

24 Java Programming: Guided Learning with Early Objects24 Language of a Computer (continued) Digital signals: sequence of 0s and 1s –0 represents low voltage, 1 represents high voltage –More reliable carriers of information –Can be copied from one device to another precisely

25 Java Programming: Guided Learning with Early Objects25 Language of a Computer (continued) Machine language: sequence of 0s and 1s Binary digit (bit): 0 or 1 Binary code or binary number: sequence of 0s and 1s Byte: eight bits Kilobyte (KB): 2 10 = 1024 bytes

26 Java Programming: Guided Learning with Early Objects26 Table 0-1 Binary Units

27 Java Programming: Guided Learning with Early Objects27 Language of a Computer (continued) Every symbol on the keyboard encoded as unique sequence of bits –ASCII most common encoding ASCII data set consists of 128 characters Seven-bit code with 0 added on the left ‘ A ’ is 01000001 –Unicode: 65,536 characters Two bytes, used by Java ‘ A ’ is 0000000001000001 First 128 characters of Unicode same in ASCII

28 Java Programming: Guided Learning with Early Objects28 Evolution of Programming Languages Machine language provides program instructions in bits –Machine language of one computer not the same for other computers –Example: wages = rate * hours 100100 010001 100110 010010 100010 010011 To manipulate data, programmer had to remember memory addresses

29 Java Programming: Guided Learning with Early Objects29 Evolution of Programming Languages (continued) Assembly language: instructions were mnemonics –Example: wages = rate * hours LOADrate MULThours STORwages –Assembler: translates a program in assembly language to machine language

30 Java Programming: Guided Learning with Early Objects30 Table 0-2 Examples of instructions in Assembly Language and Machine Language

31 Java Programming: Guided Learning with Early Objects31 Evolution of Programming Languages (continued) High-level languages (Java, FORTRAN) –Example: wages = rate * hours Java instructions translated into bytecode –Interpreted into a particular machine language

32 Java Programming: Guided Learning with Early Objects32 Evolution of Programming Languages (continued) Compiler: translates high-level language into machine language –Java compiler translates to bytecode Java Virtual Machine (JVM) makes Java machine independent –Bytecode is the machine language for the JVM

33 Java Programming: Guided Learning with Early Objects33 Processing a Java Program Two types of Java programs: –Applications –Applets Java application example: public class MyFirstJavaProgram { public static void main(String[] args) { System.out.println(“Hello”); }

34 Java Programming: Guided Learning with Early Objects34 Processing a Java Program (continued) Use a text editor such as Notepad –Program is the source program –Saved in a text file named ClassName.java –Preceding example saved in a file called “MyFirstJavaProgram.java” Compiler checks source program for syntax errors

35 Java Programming: Guided Learning with Early Objects35 Processing a Java Program (continued) If no syntax errors found, compiler translates to bytecode –Bytecode saved in file with.class extension Run a Java application –.class file loaded into computer memory Run a Java applet –Use Web browser or applet viewer Applet viewer is a stripped-down browser

36 Java Programming: Guided Learning with Early Objects36 Processing a Java Program (continued) Java programs developed with an integrated development environment (IDE) Java package is a set of related classes Java program is a collection of classes Loader: connects bytecode for classes used in the program –Loads bytecode into main memory

37 Java Programming: Guided Learning with Early Objects37 Processing a Java Program (continued) Execute the Java program –Classes loaded into main memory –Bytecode verifier verifies the bytecode is valid and does not violate security restrictions –Interpreter translates each bytecode instruction into machine language and executes it

38 Java Programming: Guided Learning with Early Objects38 Processing a Java Program (continued) Other languages require different compiler for each type of CPU Java compiler translates Java into bytecode, the language of the JVM –Independent of type of CPU Interpreter translates one bytecode instruction at a time –Java programs run slower than compiled programs

39 Java Programming: Guided Learning with Early Objects39 Figure 0-3 Processing a Java program

40 Java Programming: Guided Learning with Early Objects40 Programming with the Problem Analysis-Coding-Execution Cycle Programming is a problem-solving process –Different people use different techniques –Some techniques outlined clearly, easy to follow –Solve the problem –Give insight into how solution reached –Easily modified if problem domain changes

41 Java Programming: Guided Learning with Early Objects41 Programming with the Problem Analysis- Coding-Execution Cycle (continued) Algorithm development is one technique Algorithm: step-by-step problem-solving process in which solution obtained in finite time Problem-solving process –Analyze the problem Outline the problem and solution requirements –Design an algorithm to solve the problem

42 Java Programming: Guided Learning with Early Objects42 Programming with the Problem Analysis- Coding-Execution Cycle (continued) Problem-solving process (continued): –Implement the algorithm in a programming language –Verify the algorithm works –Maintain the program by using and improving it Modify it if the domain changes

43 Java Programming: Guided Learning with Early Objects43 Figure 0-4 Problem analysis-coding-execution cycle

44 Java Programming: Guided Learning with Early Objects44 Programming with the Problem Analysis- Coding-Execution Cycle (continued) Analyzing the problem is the most important step –Thoroughly understand the problem –Understand problem requirements Whether the program requires user interaction Whether it manipulates data Whether it produces output What the output looks like How data are represented

45 Java Programming: Guided Learning with Early Objects45 Programming with the Problem Analysis- Coding-Execution Cycle (continued) Analyzing the problem is the most important step (continued) –How results should be generated and presented –Divide the problem into subproblems Repeat steps 1 and 2 Analyze each subproblem Understand requirements of each subproblem Understand how subproblems relate to each other

46 Java Programming: Guided Learning with Early Objects46 Programming with the Problem Analysis- Coding-Execution Cycle (continued) After analyzing the problem, design an algorithm –Design an algorithm for each subproblem –Check the algorithm for correctness Use sample data Perform mathematical analysis –Integrate subproblem solutions

47 Java Programming: Guided Learning with Early Objects47 Programming with the Problem Analysis- Coding-Execution Cycle (continued) Convert algorithm into high-level language –Use a text editor –Verify the syntax using the compiler –Resolve errors and recompile Execute the program –Compiler does not guarantee program does what you intended –Execute to check for logical errors Take time to complete problem analysis

48 Java Programming: Guided Learning with Early Objects48 Programming Methodologies Structured programming –Structured design Divide a problem into smaller subproblems –Structured programming Implementing structured design –Also known as: Top-down design Bottom-up design Stepwise refinement Modular design

49 Java Programming: Guided Learning with Early Objects49 Programming Methodologies (continued) Object-oriented programming –Object-oriented design (OOD) –Identify objects Objects form the basis for solution –Determine how objects interact –Specify relevant data and operations for each object

50 Java Programming: Guided Learning with Early Objects50 Programming Methodologies (continued) Objects consist of data and operations on the data Encapsulation: data and operations combined in a single unit Object-oriented programming (OOP): programming language that implements OOD Methods associated with objects –Implement algorithms Class combines data and operations into single unit

51 Summary Computer: electronic device that can perform arithmetic and logical operations Computer system has hardware and software Central processing unit (CPU): brain Primary storage is volatile; secondary storage is permanent Operating system monitors the overall activity of the computer and provides services Java Programming: Guided Learning with Early Objects51

52 Summary (continued) Various kinds of languages: machine language, assembly, high-level Algorithm: step-by-step problem-solving process; solution in finite amount of time Problem-solving process –Analyze problem and design an algorithm –Implement the algorithm in code –Maintain the program Java Programming: Guided Learning with Early Objects52

53 Summary (continued) Structured design –Problem is divided into smaller subproblems –Each subproblem is solved –Combine solutions to all subproblems Object-oriented design (OOD): a program is a collection of interacting objects –Object: data and operations on those data Java Programming: Guided Learning with Early Objects53


Download ppt "Java Programming: Guided Learning with Early Objects Chapter 0 An Overview of Computer and Programming Languages."

Similar presentations


Ads by Google