1 / 21

CMSC 202

CMSC 202. Computer Science II for Majors Object-Oriented Programming. Instructors. Mr. Dennis Frey Sections 0101 – 0105 Tues/Thurs 10:00am – 11:15am LH 4 (ACIV) Mr. Sa’ad Raouf Sections 0201 - 0205 Mon/Wed 5:30pm – 6:45pm LH 2 (CHEM). Course Co-ordination.

kynton
Download Presentation

CMSC 202

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 Object-Oriented Programming

  2. Instructors Mr. Dennis Frey Sections 0101 – 0105 Tues/Thurs 10:00am – 11:15am LH 4 (ACIV) Mr. Sa’ad Raouf Sections 0201 - 0205 Mon/Wed 5:30pm – 6:45pm LH 2 (CHEM)

  3. Course Co-ordination • All sections are assigned the same projects • All sections are assigned the same labs • All sections get the same lecture material, but exams are different. • You must take the exam given by your instructor

  4. What is CMSC 202? • CMSC 202 is an introduction to Object-Oriented programming using the Java programming language • Course website www.cs.umbc.edu/courses/undergraduate/202/fall07

  5. Eclipse An integrated development environment (IDE) for writing Java programs • Free download for your PC • See course “Resources” page • Available in all OIT labs around campus • We’ll show you more in lab 1

  6. What is OOP? • Object-Oriented Programming (OOP) is a different way of thinking about a programming problem. • Rather than looking at a problem as some data and functions (procedures) that manipulate that data, we look at a problem and think about what “things” (objects) must be represented in the problem • What are the attributes/properties/characteristics of each object • What are the behaviors of each object

  7. More OOP How is OOP different than programming in a language like C? With C, your program consists of lots of functions being called from main, or calling each other. Functions are the focus. With OOP (using Java/C++) your program consists of lots of objects used to represent “things” in your program. The objects use each other’s services.

  8. What’s an Object? • A bundle of related • data which make up the object’s “state” • operations which define the objects “behavior” • Data are referred to as “instance variables” • Operation are referred to as “methods”

  9. Object Examples • Bank Account • State: account number, owner’s name, balance, interest rate, etc • Operations: deposit, withdraw, transfer, etc • Student • State: name, ID, birthday, major • Operations: compute age, compute tuition, lookup grades • String • State: sequence of characters • Operations: compute length, test for equality, concatenate, etc.

  10. What is Java? • 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 • Team developed a two-step translation process to simplify the task of compiler writing for each class of appliances

  11. Significance of Java translation process • Writing a compiler (translation program) for each type of appliance processor would have been very costly • Instead, developed intermediate language that is the same for all types of processors : Java byte-code • Therefore, only a small, easy to write program was needed to translate byte-code into the machine code for each processor

  12. Why Java? • Popular Modern Language • Used in many applications • Desirable Features • Object-oriented • Garbage Collection • Portability of Byte Code • Simpler GUI programming

  13. Java is an Object-Oriented Language • Programming methodology that views a program as consisting of objects that interact with one another by means of actions (called methods) • Objects of the same kind are said to have the same type or be in the same class • Other high-level languages have constructs called procedures, methods, functions, and/or subprograms • These types of constructs are called methods in Java • All programming constructs in Java, including methods, are part of a class

  14. Java Applications • There are two types of Java programs: applications and applets • A Java application program or "regular" Java program is a class with a method 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

  15. Applets • A Java applet (little Java application) is a 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 • In contrast, application programs may use a windowing interface or console (i.e., text) I/O

  16. Java Byte-Code • The compilers for most programming languages translate high-level programs directly into the machine language for a particular computer • Since different computers have different machine languages, a different compiler is needed for each one • In contrast, the Java compiler translates Java programs into byte-code, a machine language for a fictitious computer called the Java Virtual Machine (JVM) • Once compiled to byte-code, a Java program can be used on any computer, making it very portable

  17. Java Virtual Machine • The JVM is the program that translates a program written in Java byte-code into the machine language for a particular computer when a Java program is executed • The JVM translates and immediately executes each byte-code instruction, one after another • Translating byte-code into machine code is relatively easy compared to the initial compilation step

  18. 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++

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

  20. Java Terminology The Java acronyms are plentiful and confusing. Here are the basics. • JRE – Java Runtime Environment • This is the Java Virtual Machine (JVM) that executes your Java byte code • 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” • JSE API – application programming interface for the class libraries included with the JSE • To learn more about JDK, JRE, etc, visit http://java.sun.com/javase/technologies/index.jsp

  21. Java Versions • The current version of Java is Java 6, also known as Java 1.6 or Java 1.6.0 • This is the version running on GL servers • The previous version was Java 5, also known as Java 1.5, Java 1.5.0 or “Java 2 SE Version 5” • This is the recommended version for your PC/laptop • To learn find what version is on your PC/laptop, visit http://www.javatester.org/version.html • To learn more about Java version naming, visit http://java.sun.com/javase/namechange.html

More Related