object orented programing in java for the

freeonlineearnldr 8 views 16 slides May 21, 2024
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

object orented


Slide Content

Contents

OG

ca Define OOP

ca OOP Vs. Structured Programming
ca Main principle of OOP

ca Encapsulation

ca Abstraction

ca Inheritance

ca Polymorphism

ca Overview

What is OOP ?

cg Object-oriented programming is a method of
implementation in which programs are organized as
cooperative collections of objects, each of which
represents an instance of some class, and whose classes
are all members of one or more hierarchy of classes united
via inheritance relationships.

Y Ca

er À. ca

Building Dog Computer

iit A ei __

Empire state Lassie, Your computer

al

Structure Programming Vs. OOP

OS

Structure Programming

Top to Bottom Design

Object Oriented Programming

Object focused design

Structure determines execution flow

Conversion determines execution flow.

Moderately complex program

Very Complex Program

Less data security

Less flexible

More security

More flexible

Less reusability

More reusability

Less abstraction

More abstraction

Client/Sever Application

Graphical User Interface

Design Pattern

Portability (WORA)

WORA
CB

ca Write Ones Run Anywhere

Main principle of OOP

(4 = =

ca Fundamental Principles of Object Oriented Programming:

Ds
3:
4.

Encapsulation.
Abstraction.
Inheritance.
Polymorphism.

Encapsulation
OG

cz Encapsulation is the mechanism that binds together

code and the data it manipulates, and keeps both
safe from outside interference and misuse.

class)

Methods
_

=
Variables

Advantages of Encapsulation
OS
nn —

i. Protection
ii, Consistency
iii. Allows change

Abstraction

«E abstraction is a process of hiding the implementation
details from the user, only the functionality will be
provided to the user. In other words, the user will have the
information on what the object does instead of how it
does.

ca In Java, abstraction is achieved using Abstract classes and
interfaces. Interfaces us. Abstract Classes

Gor PYY\

Abstract Class Vs. Abstract

Method
CS

ce An abstract class is a class that is declared with abstract keyword.

ca An abstract method is a method that is declared without an
implementation.

ca An abstract class may or may not have all abstract methods. Some
of them can be concrete methods.

ca A method defined abstract must always be redefined in the subclass,
ca Any class that contains one or more abstract methods must also be
declared with abstract keyword.

c& There can be no object of an abstract class. That is, an abstract class
can not be directly instantiated with the new operator.

Inheritance
CB

«2 Inheritance is the process by which one object acquires the properties
of another object.

@& A class that is derived from another class is called a subclass(also a
derived class, extended class, or child class).

c& The class from which the subclass is derived is called a super class
(also a base class or a parent class).

Son Vain Base
Class ae

EA
( Papalam >)
‘Drive Class

277 inheritance

Cont'd
cg

The sub-class inherits the base class’ data members and member
functions.
ca A sub-class has all data members of its base-class plus its own.

ca A sub-class has all member functions of its base class (with changes)

plus its own.
AA — — 5]

= x Parent Class

Benefits of Inheritance
(5 =

Inheritance has a lot of benefits

ca Extensibility

ca Reusability

ca Provides abstraction

cg Eliminates redundant code

GR Use inheritance for building a relationships
E.g. dog is--a animal (dogs are kind of animals)

Polymorphism

ce Polymorphisms comes from Greek word that means ‘many forms'.

ca More precisely Polymorphisms means the ability to request that
the same methods be performed by a wide range of different types
of things.

Cont'd

@ It is achieved by using many different techniques named

1 1 overridit

Just eat!

Call eat action!

[Eat] eat(void)

M [Eat] eat(withBeverage)
- 7 [1] eat(withSnack)

Overview

CS

ca Discuss about OOP.

cx Differentiate Structure Programming and OOP.
ca Main principles of OOP.

ca Encapsulation.

ca Abstraction.

ca Inheritance.

ca Polymorphism.