Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Summary and Test Prep: Java Chapters 2-4 TEST Tuesday, Oct. 9, 2012 First Java Program Objectives Chapter 2 Discuss why Java is an important programming language. Explain the Java Virtual Machine and byte code. Choose a user interface style. Describe the structure of a simple Java program. Write a simple program. Edit, compile, and run a program using a Java development environment. Format a program to give a pleasing, consistent appearance. Understand compile-time errors. Vocabulary Chapter 2 Applet Assignment Statement: Byte Code: DOS development environment: Graphical user interface (GUI): Hacking Integrated Development Environment (IDE): Java Virtual Machine (JVM): Just-in-time Compilation (JIT): Parameter Source code: Statement Terminal I\O interface: Variable Know the ONES in bold Why Java: Section 2-1 Page 31 – What makes Java so special? It is one of the fastest growing programming languages in the world because: 1. Modern object-oriented programming language with features from other “objectoriented” languages, for Example: C++ and Smalltalk 2. Java is “robust,” specifically because: a. Makes possible visus free, secure systems b. Will NOT overwrite memory (memory leaks caused by “pointers” not returned to the “stack” c. IT is PORTABLE – can run on many different platforms Java Virtual Machine and Byte Code Sec 2.2 Pages 32: What is the process by which “source code” is translated into byte code? (Read the first two sentences under the Java Virtual Machine subheading) SUMMARIZE below: Sample Q: 1. What is a portable program? 2. Describe two features that make Java better than C++: Sample Q: 1. What does JVM stand for? 2. What is byte code? Describe how the JVM uses byte code: Bishop Lynch H.S. 2 Review: Chapters 2-4 Chapter 2 Objectives Choose a user interface style. Describe the structure of a simple Java program. Write a simple program. Vocabulary Chapter 2 Choosing a User Interface Style: Section 2-3 Two choices: terminal I\O user interface or GUI Read pages 33; But our decision is based on using the Eclipse IDE (define IDE) View Figure 2-1: What is going on? GUI: User enters a number, clicks the “command button” and something is displayed in a “label” Hello World: Section 2-4 Pages 34 – Program: “just a recipe” or a sequence of machine executable instructions that the computer can translate into machine code, using either an IDE or a compiler, and translator (see section 2-2) See below: Read and Summarize and Explanation: Page 35 – 36 In the code: Take notes System.out.: println: What is a string? What contains or surrounds the string? What is the statement and how does it end? What is a parameter? 2 Bishop Lynch H.S. 3 Review: Chapters 2-4 Chapter 2 Edit, compile, and Execute: Section 2-5 Pages 37 Define: Vocabulary Chapter 2 Edit, compile, Execute Page 38: Development Environments: Unix of Linux MS Windows (DOS development environment) MacOS Compile Time Errors: Readabiltiy Computer Ethics: Page 41 Page 40o 2.6: Temperature Conversion: Study “parts” of a program and revisit source code, pages 42 – 45; What is Scanner? What does it meant to “instantiate or create a Scanner object? Page 43 double fahreheit; double celius; What does it mean to declare a variable? Assignment operator, what is it’s symbol and what does it mean? Page 44 3 Bishop Lynch H.S. 4 Review: Chapters 2-4 SAMPLE Q: What is a variable in a program and how do you use it? Describe the role of the assignment operator? What is Scanner object? Describe the difference between print and println: Graphics NOTES (not on test) 4 Bishop Lynch H.S. 5 Review: Chapters 2-4 Syntax, Errors, and Debugging Objectives • Construct and use numeric and string literals. • Name and use variables and constants. • Create arithmetic expressions. • Understand the precedence of different arithmetic operators. • Concatenate two strings or a number and a string. • Know how and when to use comments in a program. • Tell the difference between syntax errors, run-time errors, and logic errors. • Insert output statements to debug a program. Language Elements: Pages 57 – Contrast “natural langauges” with programming languages: Size, rigidity, lieteralness Basic Java Syntax and Semantics: Page 59 Describe: Data type: Syntax: Literals: 5 Vocabulary Arithmetic expression: Comments Exception Literal Logic Error Origin Package Pseudocode Reserved Words: Run-Time Error: Semantics Syntax Virus Screen coordinate system: Graphics context: Coordinate system: Bishop Lynch H.S. 6 Review: Chapters 2-4 Literals: items in a program whose values do NOT change Variables and Declarations: Page 61 See Exercises 3.2: Assignment Statements Arithmetic Expressions Types of Operators and Precedence 6 (Types of Operands) Bishop Lynch H.S. 7 Review: Chapters 2-4 Chapter 3: Syntax, Errors, Debugging Maximum, Minimum, and Arithmetic Overflow Mixed-Mode expressions Casting to int and double String expressions and Methods Escape Characters Know list, page 69 Methods, Messages, and Signatures Continued Page 66 Page 66 See exampels page 67 Concatenation (joining) “\t” or “\\” or “\n” See page 70 – 73 Math methods: Math.sqrt(d) Math.abs(int) Math.abs(double) Math.round(double) Math.pow(double base, double exponent) See BluePelicanJava (pdf file) Packages and Imports Terminal I/O for Diff Data types, Section 3.3 See Figure 3-8 Comments: Page 77 Case Study: Income Tax Calculator Page 79 Programming Errors(3.5) The Three types: 1. Syntax errors 2. Run-time errors 3. Logic errors Page 82 Debugging: Section 3.6 7 Bishop Lynch H.S. 8 Review: Chapters 2-4 Introduction to control statements: Chapter 4 Objectives: Use the increment and decrement operators. Use standard math methods. Use if and if-else statements to make choices. Use while and for loops to repeat a process. Construct appropriate conditions for control statements using relational operators. Detect and correct common errors involving loops. Vocabulary: Control statements: Counter Count-controlled loop: Entry-controlled loop: Flowchart: Infinite loop: Iteration Off-by-one error: Overloading Sentinel Task-controlled loop: Page 105 Additional Operators, Section 4.1 Extended assignment ops: A = A + 3; replace with A += 3; B = B – 3; replace with B -= 3; Increment and decrement operators: A++ ++A B— --B Standard Classes and Methods: Math Class, seven math methods Random class 8 Page 108 Bishop Lynch H.S. 9 Review: Chapters 2-4 The if and if-else statement Section 4.4 Format: if (boolean condition) Statement; // true path, if (boolean condition) Statement; // true path, else Statement; // false path if (boolean condition) { Statement; // true path, Statement2; // true path } else { Statement; // false path Statement2; // false path Statement3; // false path } Set loop control variable while (conditional expression) Statement; // update statement while (conditional expression) { Statement; // Update path } for (counter ;conditional expression; update) { Statement; // false path } 9 Page 111 Bishop Lynch H.S. 10 Review: Chapters 2-4 Complete Page 149- 151 10 Bishop Lynch H.S. 11 Review: Chapters 2-4 11