1 / 17

CMSC 202: Introduction to Object-Oriented Programming in Java

This course provides an introduction to object-oriented programming using the Java programming language. Emphasis is placed on proper program design and the fundamentals of object-oriented programming. All sections have the same assignments, labs, lecture material, and final exam.

lynettec
Download Presentation

CMSC 202: Introduction to Object-Oriented Programming in Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CMSC 202 Computer Science II for Majors Fall 2009 Introduction

  2. Instructors Mr. Ryan Bergeron Section 01 Mon/Wed, 8:30am – 9:45am in ACIV 305 Mr. Dennis Frey Section 04 Tues/Thurs, 10:00am – 11:15am in SOND 110 Section 07 Tues/Thurs, 1:00pm – 2:15pm in SOND 209 Ms. Susan Mitchell Section 10 Mon/Wed, 5:30pm – 6:45pm in SOND 209

  3. Course Coordination • All sections • have the same website • are assigned the same projects • are assigned the same labs • get the same lecture material • have the same final exam • all at the same day and time (Dec. 17, 3:30-5:30pm) • all at the same location (Lecture Hall 5) • Midterm 1 and Midterm 2 exams are different. • You must take the exam given by your instructor.

  4. What is CMSC 202? • An introduction to object-oriented programming • Uses the Java programming language • Strong emphasis on proper program design • Course website www.cs.umbc.edu/courses/undergraduate/202/fall09

  5. A Collection of Objects Procedural vs. OO Programming Procedural Object-Oriented (OO) Examples: C, Pascal, Basic 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. A Hierarchy of Functions

  6. Bank Account String account number owner’s name balance interest rate more? sequence of characters more? compute length concatenate test for equality more? deposit money withdraw money check balance transfer money more? 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” name attributes (state) operations (behaviors)

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

  8. 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

  9. 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

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

  11. Project Library for Linux Linux binary Linux executable C/C++ Code Linux C/C++linker Linux C/C++compiler Project Library for Windows Windows binary Windows executable Windows C/C++ compiler Windows C/C++linker Compiling and Running C/C++

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

  13. 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

  14. 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

  15. 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.

  16. 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.

  17. Eclipse IDE Screenshot

More Related