Object Oriented Programming
Prof. Dr. –Ing. Kalamullah Ramli
Objectives
Understand Object Oriented Design
Paradigm
Understand principles of and best
practice on developing and analysing
Object Oriented System Software
Capable of designing, initializing and
implementing Object Oriented System
Software
1
Syllabus of Course
W Topics Date Lect Task
1Introduction to OOP Sep-3 KLM reading Chap 2, Chap 3, Chap 4 (Cisco-Sun)
2Object Oriented Principles Sep-17 KLM reading Chap 5, Chap 6, Chap 7 (Cisco-Sun)
3Inheritance Sep-24 KLM reading Chap 8 (Cisco-Sun)
4Polymorphism Okt-1 KLM review reading Chap 2 to Chap 8
5Java Packages, AWT Okt-8 KLM reading Chap 9, Chap 10 (Cisco-Sun)
6Introduction to Java Networking, Applets, Graphics Okt-15 KLM reading Chap 11 (Cisco-Sun)
Java Networking: Applets, Remoted Method Invocation
7 (RMI) Okt-23 KLM Overview all read chapters
Mid-Test 25-30-Okt
7 Nov-5 KLM exercise, reading Chap 12 (Cisco-Sun)
8 Lab Exercises: setting, initializing, implementing Object Nov-12 KLM exercise, reading Chap 13 (Cisco-Sun)
Oriented Applications
9 Nov-19 KLM exercise, reading Chap 14 (Cisco-Sun)
10 Nov-26 KLM exercise, reading Chap 15 (Cisco-Sun)
11Project Development, Supervising Dec-3 KLM Developing
12Project Development, Supervising Dec-10 KLM Developing
Final-Test 20-30-Des
References
Deitel, “Java How to Program” 6th Ed.,
Prentice Hall, ISBN:0131483986
Cisco & Sun, “Java Programming”, Cisco
Networking Academy
2
Lecture 1
Introduction to
Object Oriented Programming
3
Hardware components
Software and programming
Introduction to Java
Integrated Development Environment
(IDE
IDE)
IDE
Central Processing Unit (CPU)
Persistent Data Storage
◦ Hard Drive, CD, Diskette, ROM
Volatile Storage
◦ Random Access Memory (RAM)
Peripherals
◦ Mouse, Keyboard, Screen, etc
4
Instructions that tell the hardware
what to do
Three ways to obtain software
◦ Buy pre-written software
◦ Modify pre-existing software
◦ Write the software
Tools for the user
Usually a collection of programs
Provide a user interface
◦ Accept input
◦ React to requests
Examples: Microsoft Office, Netscape
Navigator
5
Program that controls the computer
hardware
Provides a consistent way for
applications to access the hardware
Many Operating Systems exist, mostly
incompatible with each other
Applications must be written
specifically for the target Operating
System
Digital CPUs require binary instructions
Early computers were programmed with
electrical switches
Very difficult to write programs
Early languages used mnemonics that
were translated to binary for the CPU
Higher-
Higher-level languages allow the
programmer to ignore the details
6
Early high-level languages were procedural
Programs were a list of sequential steps
Programmer had to think like the computer
Object-oriented Programming (OOP) uses
general purpose components
Components are then assembled in to an
application
Components are called ‘Objects
Objects’
Objects
Object perform specific functions
Objects interact by sending & receiving
messages
Programmer is focused on coordinating the
object interaction
Closely models human problem-
problem-solving
7
Punctuation – Symbols used
Vocabulary – The languages keywords
Identifiers – Used to reference data
Operators – Symbols representing commands
Syntax – Rules for combining the language’s
elements
Compiled – The program is translated in to
the CPU’s binary language once it is
completed
Interpreted – The individual instructions in
the program are translated immediately
before they are executed
8
Originally designed for consumer devices
Had to be small,
small simple,
simple portable
Ideal for use over the Internet
9
Java programs written as text files
Java compiler creates a program file
consisting of ‘Byte
Byte Code’
Code
The byte-code file is sent to the target
computer, which has a Java Virtual Machine
(JVM)
The JVM ‘interprets
interprets’
interprets the byte-code, one
instruction at a time
A Separate JVM is required for each
Operating System & CPU
10
Create Java Programs with a text editor or
Integrated Development Environment (IDE)
Use a compiler to create the ‘byte-code’ class
files (Such as JDK)
A Java Virtual Machine (JVM
JVM)
JVM on the target
computers
/**
* A Java Program Comments
* @author: Student
*/
// This program will say hello
Class definition
public class sayHello { Data & methods
public static void main(String args[]) {
String name = “Student”; The ‘main’ method
int number = 1;
System.out.println(“Hello”);
System.out.println(name); Punctuation
System.out.println(“Your lucky number is “ + number);
}
}
11
12
13