Download presentation
Presentation is loading. Please wait.
Published byRachel Evans Modified over 9 years ago
1
1 60-212 Programming in Java This is a one semester course. You will learn the language and some basic programming skills. You are expected to read, program, read, program, read, program, …. Code-oriented teaching
2
2 60-212: Highlight of the course outline Lecture Hours –Section 30 – Thursdays,1900 - 2150, Room: TC104 –Tutorial (Open to all sections) – Fridays, 1000 - 1120, Room: DH361 Office hours –Thursdays, 1300 - 1400, 1750 - 1850 Exams –Midterm 1: Sat, Oct. 22, 2005, 0900-1200, LC: TC 200 –Midterm 2: Sat, Nov. 26, 2005, 0900-1200, LC: TC 200 –Final Examination: Friday, December 16, 2005, 1900-2200, Exam Slot: TBA
3
3 60-212: Highlight of the course outline Labs –Students MUST register in one of the following sections. Section 53 -- Wednesdays 1600 – 1720, ER 3119 Section 54 – Thursdays 1600 – 1720, ER 3119 Section 55 -- Wednesdays 1730 – 1850, WL 305 Section 58 -- Wednesdays 2030 – 2150, WL 305 –Note: Lab attendance is mandatory. All students must check the SIS to ensure that they are enrolled in a lab section as well as in a lecture section. Students who registered in lab sections 51, 52, 56 or 57 must register in one of the lab sections shown above.
4
4 60-212: Highlight of the course outline Evaluation scheme 4.5% 9 Laboratory 10% 2 Laboratory tests 5.5% 1 Project 25% Midterm #1, Sat, Oct. 22, 0900-1200 25% Midterm #2, Sat, Nov. 26, 0900-1200 30% Final Exam, Fri, Dec 16, 1900-2200
5
5 60-212: Highlight of the course outline Grading Scheme 93< 100 A+, 86< 93 A, 80< 86 A- 77< 80 B+, 73< 77 B, 70< 73 B- 67< 70 C +, 63< 67 C, 60< 63 C- 57< 60 D+, 53< 57 D, 50< 53 D- 35< 50 F, <35 F- Read through the course outline to familiarize yourself with the rules regarding for example:
6
6 60-212: Highlight of the course outline –Missed labs, midterms, and final…, –Appeal your marks for lab and project…, –Late submission for labs, project… –Doctor’s note –Academic misconduct –see course outline, for more details, …..
7
7 60-212: Resources Textbook –Lecture notes (courseware) –Deitel, “Java How to program, 5 th or 6 th ed.” –Find a used one at » www.amazon.comwww.amazon.com »www.ebay.cawww.ebay.ca »www.campusbooks.comwww.campusbooks.com –Bruce Eckel, “Thinking in Java”. It is FREE. »www.mindview.netwww.mindview.net Do I have to have textbooks? –For your exams
8
8 60-212: Resources Hardware Environment –Unix workstation at school, ER3119, WL305 – At home, your choice ! Software –J2SE 1.4.2, or J2SE 1.5 already installed at school –Can be downloaded for home use, free again: http://java.sun.com/downloads/index.html http://java.sun.com/downloads/index.html –Command line vs. IDE Eclipse, www.eclipse.org, a very nice IDE for java programmingwww.eclipse.org
9
9 60-212: Resources Do you have a computer science account for using computing facilities at the School of Compute Science? –How to find out? A website for the course will be available this weekend. A discussion group probably will be set up in two weeks. More details will be announced. Java Lab, ie. ER3150 will start to open on Sept 12, 9am-10pm.
10
10 Thinking About Objects Objects –Reusable software components that model real-world items –Look all around you People, animals, plants, cars, etc. –Attributes Size, shape, color, weight, etc. –Behaviors Babies cry, crawl, sleep, etc.
11
11 Java Class Libraries Classes –Include methods that perform tasks Return information after task completion –Used to build Java programs Java contains class libraries –Known as Java APIs (Application Programming Interfaces)
12
12 Basics of a Typical Java Environment Java programs normally undergo five phases –Edit Programmer writes program (and stores program on disk) –Compile Compiler creates bytecodes from program –Load Class loader stores bytecodes in memory –Verify Verifier ensures bytecodes do not violate security requirements –Execute Interpreter translates bytecodes into machine language
13
13 Typical Java environment. Primary Memory............ Disk Editor Compiler Class Loader Program is created in an editor and stored on disk in a file ending with.java. Compiler creates bytecodes and stores them on disk in a file ending with.class. Class loader reads.class files containing bytecodes from disk and puts those bytecodes in memory. Phase 1 Phase 2 Phase 3 Primary Memory............ Bytecode Verifier Bytecode verifier confirms that all bytecodes are valid and do not violate Java’s security restrictions. Phase 4 Primary Memory............ Interpreter Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes. Phase 5
14
14 Thinking About Objects Object-oriented design (OOD) –Models real-world objects –Models communication among objects –Encapsulates attributes and operations (behaviors) Information hiding Communication through well-defined interfaces Object-oriented language –Programming in object oriented languages is called object-oriented programming (OOP) –Java
15
15 Thinking About Objects Object-Oriented Analysis and Design (OOA/D) –Essential for large programs –Analyze program requirements, then develop solution –UML Unified Modeling Language
16
16 Week 1 Programs A First Program in Java: Printing a Line of Text Modifying Our First Java Program Displaying Text in a Dialog Box Another Java Application: Adding Integers Memory Concepts Arithmetic Decision Making: Equality and Relational Operators
17
17 Discuss four small Java programs Welcome1.java Welcome2.java Welcome3.java Welcome4.java
18
18 Escape characters –Backslash ( \ ) –Indicates special characters be output
19
19 Another Java Application: Adding Integers Addition.java
20
20 Memory Concepts Visual Representation –Sum = 0; number1 = 1; number2 = 2; –Sum = number1 + number2; after execution of statement sum0 3
21
21 Arithmetic Arithmetic calculations used in most rograms –Usage * for multiplication / for division +, - No operator for exponentiation (more in Chapter 5) –Integer division truncates remainder 7 / 5 evaluates to 1 –Remainder operator % returns the remainder 7 % 5 evaluates to 2
22
22 Arithmetic Operator precedence –Some arithmetic operators act before others (i.e., multiplication before addition) Use parenthesis when needed –Example: Find the average of three variables a, b and c Do not use: a + b + c / 3 Use: ( a + b + c ) / 3 –Follows PEMDAS Parentheses, Exponents, Multiplication, Division, Addition, Subtraction
23
23 Arithmetic
24
24 Decision Making: Equality and Relational Operators
25
25 Precedence of operators
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.