Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMSC 202 Computer Science II for Majors Object-Oriented Programming.

Similar presentations

Presentation on theme: "CMSC 202 Computer Science II for Majors Object-Oriented Programming."— Presentation transcript:

1 CMSC 202 Computer Science II for Majors Object-Oriented Programming

2 Jan 14, 20082 Instructors Mr. Dennis Frey Sections 0101 & 0102 Mon/Wed 10:00am – 11:15am in Sond 409 Sections 0201 & 0202 Tues/Thurs 10:00am – 11:15am in ITE 231 Sections 0301 & 0302 Tues/Thurs 1:00pm – 2:15pm in ITE 227 Ms. Susan Mitchell Sections 0401 & 0402 Mon/Wed 5:30pm – 6:45pm in Sond 113

3 Jan 14, 20083 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 Common Final Exam The final exam for all students in all sections will be the same and given at the same time (to be be determined).

4 Jan 14, 20084 What is CMSC 202? CMSC 202 is an introduction to Object- Oriented programming using the Java programming language Course website

5 Aug 24, 20075 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 Aug 24, 20076 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 Aug 24, 20077 OOP vs C 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. A program is a collection of interacting objects.

8 Aug 24, 20078 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 Aug 24, 20079 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 Aug 24, 200710 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 Aug 24, 200711 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 Aug 24, 200712 Why Java? Popular Modern Language Used in many applications Desirable Features Object-oriented Garbage Collection Portability of Byte Code Simpler GUI programming

13 Aug 24, 200713 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 Aug 24, 200714 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 Aug 24, 200715 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 Aug 24, 200716 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 Aug 24, 200717 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 Aug 24, 200718 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

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

20 Aug 24, 200720 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

21 Aug 24, 200721 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” To learn find what version is on your PC/laptop, visit To learn more about Java version naming, visit

Download ppt "CMSC 202 Computer Science II for Majors Object-Oriented Programming."

Similar presentations

Ads by Google