Professional Documents
Culture Documents
Topik 1
Topik 1
PROGRAMMING
TOPICS
1. INTRODUCTION 2. FUNDAMENTALS
TO OBJECT- OF THE JAVA 3. CLASSES AND
ORIENTED PROGRAMMING OBJECTS
PROGRAMMING LANGUAGE
5. MULTI-
4. INHERITANCE
THREADING AND
AND
EXCEPTION
POLYMORPHISM
HANDLING
TOPIC 1
INTRODUCTION TO
OBJECT-ORIENTED
PROGRAMMING
Sub Topics
a. Programming techniques.
b. Object Oriented concepts and
terminologies.
c. Notation that is used for OOAD by
Unified Modelling Language (UML).
d. Class diagram.
Topic 1
Understand the Programming
Programming Techniques
Techniques
History of Java technology
Unstructured Programming
Understand Java Features of Java programming language
• terminology
Small andandsimple programs
Anatomy ofconsisting only of one main
the Java programs
program
environment Programming style and documentation
Write, compile
• A sequence of commands and run javawhich
or statements programmodify
Errors in java
data (global) throughout the whole program
Procedural Programming
• A subtype of imperative programming as a programming
paradigm based upon the concept of procedure calls, in
which statements are structured into procedures (also
known as subroutines or functions).
• Break down a programming task into a collection of
variables, data structures, and subroutines
Topic 1
Understand the Programming
Programming Techniquest
Techniques
History of Java technology
Object Oriented Programming (OOP)?
Understand Java Features of Java programming language
terminology and Anatomy of the Java programs
• A type of
environment
programming in which programmers define not only
Programming style and documentation
the data type of Write,
a data structure,
compile and runbut
java also the types of
program
operations (functions) that
Errors in can
javabe applied to the data structure.
• In this way, the data structure becomes an object that includes
both data and functions.
Topic 1
Understand the Programming
Programming Techniquest
Techniques
History of
Unstructured Programming Java
Language technology
Structured Programming Language
Understand Java Features of Java programming language
terminology
Also known as and
Non-structured Anatomy
Programmingof the Java programs
Modular Programming
environment Programming style and documentation
None. It is the earliest programming
Subset of Write, compile and runProcedural
java program
Programming
paradigm.
Errors in java
To enforce a logical structure on the
program being written to make it more
Purpose Just to code.
efficient and easier to understand and
modify.
The entire program must be coded in one Divides the program into smaller units or
Programming
continuous block. modules.
Structured programming, specifically
Precursor to procedural programming and then object- Object-oriented programming (OOP)
oriented programming.
Producing hardly-readable (“spaghetti”)
Code Produces readable code
code
Sometimes considered a bad approach for Usually considered a good approach for
For Projects
creating major projects creating major projects
Topic 1
Understand the Programming
Programming Techniquest
Techniques
History of Java technology
Understand Java Features of Java programming
Unstructured Programming Language
language
Structured Programming Language
terminology and Anatomy of the Java programs
environment Programming
Offers freedom to programmers to program as theystyle and documentation
Freedom Has some limitations
Write, compile and run java program
want
Modify and
Very difficult to modify and to debug Easy to modify and to debug
debug
• What is an attribute?
– Characteristic of the object
– State of an object
• What is behavior?
– Process or operation of the object that usually modify the state
of an attribute.
Topic 1
Understand the Object Oriented
Object, attribute and behavior
Concepts & Terminologies
History of Java technology
•Understand
Examples Java of object, attributes and behavior.
Features of Java programming language
terminology and Anatomy of the Java programs
environment Programming style and documentation
Write, compile and run java program
Errors in java
Object Car
Attribute -Color
-No of tire
-No of door
-Chassis
Operation -Drive, stop, reverse
Topic 1
Understand the Object Oriented
Basic terminologies of OOP
Concepts & Terminologies
History of Java technology
Classes
Understand Java Features of Java programming language
• terminology
A class is a and Anatomy
blueprint or prototypeof the Javawhich
from programs
objects are created.
environment Programming style and documentation
Objects with similar properties and methods are grouped together
Write, compile and run java program
to form a Class Errors in java
• A set of objects that have similar attributes and methods.
• Attributes and methods of a class can be used by each object from
that class.
class Student class Box
{ String name, address, status; { double width, height, depth; data
data
int icno, sid;
double marks; double ComputeVolume()
method { return( width * height * depth ); }
char DetermineStatus() method
{ if marks >= 40 double ComputeArea()
status = “Pass”; { return( width * height ); }
else }
status = “Fail”; Class
}
} Example 2 : Definition of Class Box
Example 1 : Definition of Class Student
Topic 1
Understand the Object Oriented
Basic terminologies of OOP
Concepts & Terminologies
History of Java technology
Object
Understand Java Features of Java programming language
• terminology Anatomy
and has state
Any entity that of the Java programs
and behavior.
environment Programming style and documentation
• Object is the term used to explain many things. Example: student,
Write, compile and run java program
chair and circle. Errors in java
• An Object consists of data and method
• Properties of an object are called data. In the real world,
characteristics of an object can be divided into two types:
▪ Data that can be seen such as a human with two hands.
▪ Data that cannot be seen such as a human with a name.
• Method is a set of function that manipulates data, such as
method DetermineStatus() can determine exam result for object
student
Topic 1
Understand the Object Oriented
Basic terminologies of OOP
Concepts & Terminologies
History of Java technology
Encapsulation
Understand Java Features of Java programming language
terminology and
• Encapsulation Anatomy
is a process of of the all
tying together Java
dataprograms
and methods that form a
environment
class and control the accessProgramming style
to data by hiding itsand documentation
information.
Write, compile and run java program
• The wrapping up of data and its functions into a single unit is called
Errors in java
Encapsulation.
• It enables access to object just by using methods of that object.
• It is one of the security features in OOP.
• If the college management wants to
Class Student get the status whether a student “pass”
or “fail”, they only have to know the
Name, Student ID, Address, IC No
status without knowing how to
Calculate_result() determine or calculate the grade.
• So, this is a way of implementing
Determine_grade() encapsulation where the code in the
program is hidden thus to prevent from
Print_result() being modified.
Topic 1
Understand the Object Oriented
Basic terminologies of OOP
Concepts & Terminologies
History of Java technology
Inheritance
Understand Java Features of Java programming language
• terminology Anatomy
andclass from
Create a new of the class
an existing Java programs
together with new
environment Programming style and documentation
attributes and behaviours.
Write, compile and run java program
• Inheritance is the process
Errors of forming a new class from an existing
in java
class or base class.
• The new class will have the same ability as the base class.
• Use the concept of code reusability.
Class A Base class to class B
Example 1:
Message: Withdraw a money from bank
Action Object
Student1 : Using ATM machine from Bank account.
• OO Design
– To define software objects (attributes and operations) and how they
collaborate to fulfill the requirements that will be implemented in
an OO programming language.
– For example in the Library Information System, a Book is an object
that have a title as it attribute and getChapter as the method.
Topic 1
Understand the Object Oriented Object-oriented Analysis and Design
Concepts & Terminologies (OOAD)
History of Java technology
• OOAD
Understand Java Features of Java programming language
terminology and
– Object-oriented Anatomy
analysis andofdesign
the Java programs
(OOAD) is a software
environment Programming stylea and documentation
engineering approach that models system as a group of
Write, compile and run java program
interacting objects.
Errors in java
– Each object represents some entity of interest in the system being
modeled, and is characterized by its class, its state (attribute), and
its behavior.
– Various models can be created to show the static structure,
dynamic behavior, and run-time deployment of these collaborating
objects. There are a number of different notations for representing
these models, such as the Unified Modeling Language (UML).
• OO Programming
– Design components are implemented.
Topic 1
Understand the Object Oriented
Unified Modelling Language (UML)
Concepts & Terminologies
History of Java technology
• What is UML?
Understand Java
terminology and
Features of Java programming language
Anatomy of the Java programs
• The Unified Modeling
environment Programming style andor
Language documentation
UML is a language
Write, compile and run java program
for specifying, Errors
visualizing,
in java constructing and
documenting the artifacts of software systems, as
well as for business modeling and other non-software
system.
• It is also a graphical modeling language that is used to
express designs.
Topic 1
Understand the Object Oriented
Unified Modelling Language (UML)
Concepts & Terminologies
shirtID
Attributes Price
Description
Size
Operations colorCode R=Red, B=Blue, G=Green
calculateShirtID()
displayInformation()
Topic 1
Understand the Object Oriented
UML Class Diagram
Concepts & Terminologies
History of Java technology
• Include data type for data/ method
Features of Java programming language
Understand Java
terminology and Anatomy of the Java programs
•environment
Include notation for data Programming
access style and documentation
• + for public data/Write,
method compile and run java program
• - for private data/Errors
methodin java
Shirt
- shirtID : int
- Price : float
- Description : string
- Size : string
+ calculateShirtID() : int
+ displayInformation() : void
Topic 1
Understand the Object Oriented
Components of a class
Concepts & Terminologies
History of Java technology
•Understand
Structure Java
of a class
Features of Java programming language
terminology and Anatomy of the Java programs
environment
class Dog{ Programming styleClass declaration
and documentation
private int age; Write, compile and run
Variables java program
declaration
private String color; Errors in java
Student
- Name : String
+ displayName() : void