Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMSC 202 Computer Science II for Majors Fall 2010 Introduction Version 9/101.

Similar presentations


Presentation on theme: "CMSC 202 Computer Science II for Majors Fall 2010 Introduction Version 9/101."— Presentation transcript:

1 CMSC 202 Computer Science II for Majors Fall 2010 Introduction Version 9/101

2 2 Instructors Mr. Ryan Bergeron Lecture Section 01 Tues/Thurs, 10:00am – 11:15am in Lecture Hall 3 Ms. Susan Mitchell Lecture Section 07 Mon/Wed, 5:30pm – 6:45am in Lecture Hall 1 Mr. John Park Lecture Section 13 Tues/Thurs, 1:00pm – 2:15pm in SOND 110

3 Version 9/103 Bergeron & Mitchell Sections For students with little or no Java background Both sections have the same website are assigned the same projects are given the same lab assignments get the same lecture material have the same final exam (same day, time, location) Exams1 and 2 are different. You must take the exam given by your instructor.

4 Advanced Section (13) – Mr. Park For students with substantial Java background (or equivalent) Students must either have previously taken a course in Java (e.g., AP Comp Sci), or feel *completely* comfortable with a similar language (e.g., C/C++) Emphasis on OO Design Syllabus restructured to incorporate design principles throughout the various topics Coverage of Advanced Topics Will cover additional Java concepts (time permitting) Version 9/104

5 Park Section (con’t) Shares the CMSC 202 web site with the other two sections Some links are different (schedules/notes, projects) Some pages have additional comments for this section, but are well-marked Unique schedule, notes, and projects Exams1 and 2 are different. (This is true for all CMSC 202 sections.) Has own final at the regularly schedule date and time Version 9/105

6 6 What is CMSC 202? An introduction to object-oriented programming (OOP) and object-oriented design (OOD) Uses the Java programming language Uses the Eclipse integrated development environment (IDE) Strong emphasis on proper program design Course website www.cs.umbc.edu/courses/undergraduate/202/fall10

7 Version 9/107 Procedural vs. OO Programming Examples: C, Pascal, Basic, Python Modular units: functions Program structure: hierarchical Data and operations are not bound to each other. Examples: Java, C++, Ruby Modular units: objects Program structure: a graph Data and operations are bound to each other. ProceduralObject-Oriented (OO) A Hierarchy of Functions A Collection of Objects

8 Python vs. Java – A Little Sample Version 9/108 Python: print “Hello, world” quotient = 3 / 4 if quotient == 0: print “3/4 == 0”, print “in Python” else: print “3/4 != 0” Java: public class Hello { public static void main(String[] args) { int quotient; System.out.println(“Hello, world”); quotient = 3 / 4; if (quotient == 0) { System.out.print(“3/4 == 0”); System.out.println(“ in Java”); } else { System.out.println(“3/4 != 0”); } // Things to note: // Everything has to be in some class // We need a “main()” // Statements end with ‘;’ // Variables must be declared // “if/else” syntax different // Statement blocks demarcated by “{…}” // Comments are different // …but there is much that is similar

9 Version 9/109 What’s an Object? Must first define a class A data type containing Attributes - make up the object’s “state” Operations - define the object’s “behaviors” deposit money withdraw money check balance transfer money more? Bank Account account number owner’s name balance interest rate more? String sequence of characters more? compute length concatenate test for equality more? operations (behaviors) name attributes (state)

10 Version 9/1010 So, an object is … a particular “instance” of a class. Bergeron’s AccountFrey’s AccountMitchell’s Account 43-261-5 Susan Mitchell $825.50 2.5% For any of these accounts, one can deposit money withdraw money check the balance transfer money 12-345-6 Ryan Bergeron $1,250.86 1.5% 65-432-1 Dennis Frey $5.50 2.7%

11 Version 9/1011 Why Java for 202? Popular modern OO language Wide industry usage Used in many types of applications Desirable features Object-oriented Portability (cross-platform) Easy handling of dynamic variables Garbage collection Built-in GUI libraries

12 Version 9/1012 Java History Created by Sun Microsystems team led by James Gosling (1991) Originally designed for programming home appliances Difficult task because appliances are controlled by a wide variety of computer processors Writing a compiler (translation program) for each type of appliance processor would have been very costly. Solution: two-step translation process compile, then interpret

13 Version 9/1013 Compilers, Interpreters, and the JVM compile interpret source code Compiled Languages (e.g. C, C++) bytecode binary code execute Java interpret source code Interpreted Languages (e.g. JavaScript, Perl, Ruby) Small, easy to write Interpreter is unique to each processor Interpreter translates one code instruction at a time into binary and executes it Compiler is unique to each processor JVM is unique to each processor Bytecode is processor independent Java Virtual Machine (JVM)

14 Version 9/1014 Compiling and Running C/C++ C/C++ Code Linux binary Windows binary Linux executable Windows executable Project Library for Linux Project Library for Windows Linux C/C++ compiler Windows C/C++ compiler Linux C/C++ linker Windows C/C++ linker

15 Version 9/1015 Compiling and Running Java Java Code Java Bytecode JRE for Linux JRE for Windows Java compiler Hello.java javac Hello.java Hello.class java Hello Java interpreter (JVM) translates bytecode to machine code in JRE

16 Version 9/1016 Java Terminology Java acronyms are plentiful and confusing. Here are the basics. JVM – Java Virtual Machine Translates Java bytecode to machine code API – Application Programming Interface Java code libraries JRE – Java Runtime Environment The JVM and the Java API together JDK (formerly SDK) – Java Development Kit JRE + tools (compiler, debugger) for developing Java applications and applets J2SE – Java 2 Platform, Standard Edition The JRE and JDK products taken as a “family” To learn more about JDK, JRE, etc, visit: http://java.sun.com/javase/technologies/index.jsp

17 Version 9/1017 Java Versions Current version of Java: Java 6, also known as Java 1.6 or Java 1.6.0 This is the version running on GL servers Previous version: Java 5, also known as Java 1.5, Java 1.5.0 or “Java 2 SE Version 5” To learn more about Java version naming, visit: http://java.sun.com/javase/namechange.html

18 Version 9/1018 Java Applications Two types of Java programs: Applications (a “regular” Java program) A program with a class that contains an operation named main When a Java application program is run, the run-time system automatically invokes the method named main. All Java application programs start with the main method. Applets Java program that is meant to be run from a Web browser Can be run from a location on the Internet Can also be run with an applet viewer program for debugging Applets always use a windowing interface, whereas applications may use a windowing interface or console I/O.

19 Version 9/1019 The Eclipse IDE An integrated development environment (IDE) for writing Java programs. Contains (minimally): editor debugger Java compiler Java JVM Free download for your PC See course “Resources” page on the CMSC 202 website Available in all OIT labs around campus We’ll show you more in Lab 1.

20 Version 9/1020 Eclipse IDE Screenshot


Download ppt "CMSC 202 Computer Science II for Majors Fall 2010 Introduction Version 9/101."

Similar presentations


Ads by Google