Docsity

OOPS characteristics in java programming, Lecture notes of Java Programming

Partial preview of the text

Download OOPS characteristics in java programming and more Lecture notes Java Programming in PDF only on Docsity!

Introduction to Object

Oriented Design

Overview

Understand Classes and Objects.

Understand some of the key

concepts/features in the Object

Oriented paradigm.

Benefits of Object Oriented Design

paradigm.

Examples of Objects

Figure 1. 9 : Examples of objects

CAR

VDU

BOY GIRL

BOOK TREE

CLOCK

TRIANGLE

Classes: Objects with the same

attributes and behavior

Person Objects Vehicle Objects Polygon Objects

Abstract Person^ Class

Attributes:

Operations:

Name, Age, Sex Speak(), Listen(), Walk()

Into

Abstract Vehicle^ Class

Attributes:

Operations:

Name, Model, Color Start(), Stop(), Accelerate()

Into

Abstract

Polygon Class

Attributes:

Operations: Draw(),^ Erase(),^ Move()

Vertices, Border,

Into^ Color,^ FillColor

Figure 1. 12 : Objects and classes

Java’s OO Features

OOP

Paradigm

Encapsulation

Multiple Inheritance

Genericity

Delegation

Persistence

Polymorphism

Single Inheritance

Data Abstraction

Java

Encapsulation

It associates the

code and the data

it manipulates into

a single unit; and

keeps them safe

from external

interference and

misuse.

OOP

Paradigm

Encapsulation

Multiple Inheritance

Genericity

Delegation

Persistence

Polymorphism

Single Inheritance

Data Abstraction

Data

Functions

Abstract Data Type (ADT)

A structure that contains both

data and the actions to be

performed on that data.

Class is an implementation of an

Abstract Data Type.

Class- Example

class Account {

private String accountName;

private double accountBalance;

public withdraw();

public deposit();

public determineBalance();

} // Class Account

Objects

An Object Oriented system is a

collection of interacting Objects.

Object is an instance of a class.

Classes/Objects

Student

:John

:Jill

John and Jill are

objects of class

Student

Circle

:circleA

:circleB

circleA and

circleB are

objects of class

Circle

Object

Objects have state and classes don’t.

John is an object (instance) of class Student.

name = “John”, age = 20, studentId = 1236

Jill is an object (instance) of class Student.

name = “Jill”, age = 22, studentId = 2345

circleA is an object (instance) of class Circle.

centre = (20,10), radius = 25

circleB is an object (instance) of class Circle.

centre = (0,0), radius = 10

Encapsulation

All information (attributes and methods)

in an object oriented system are stored

within the object/class.

Information can be manipulated through

operations performed on the object/class

– interface to the class. Implementation is

hidden from the user.

Object support Information Hiding – Some

attributes and methods can be hidden

from the user.

Data Abstraction

The technique of creating new data

types that are well suited to an

application.

It allows the creation of user defined

data types, having the properties of

built in data types and more.

Abstraction - Example

class Account {

private String accountName;

private double accountBalance;

public withdraw();

public deposit();

public determineBalance();

} // Class Account

Creates a data

type Account

Account acctX;