3. SELF INTRODUCTION
• EDUCATION: B. E. (Computer Sci. & Engineering)
M. E. (Computer Engineering)
PhD (Pursuing in Computer Sci. & Engineering)
• EXPERIENCE:
o Industry Experience: 6 Month (S. L. Computers, Mumbai)
o Teaching Experience: 27 Years ( SSGMCE, Shegaon)
• Operation Research and Management (3U)
• Programming Language (FORTRAN-77) (3U)
• Application Software (3R)
• Computer Oriented Operation Research (3R)
• Visual Computing (3R)
• Professional Ethics(3R)
• SUBJECT TOUGHT:
• Object Oriented Programming (C++) (2R, 2N)
• Object Oriented Programming(Java)(2R)
• Programming Methodology (Java) (2R)
• Object Oriented Analysis and Design (4R)
• Object Oriented System (M. E.)
• Software Engineering (4R)
• Data Structures (2R)
• Network Security (4R)
• System Security (M. E.)
• Introduction to Cyber Security(3R)
• Cryptography
• System and Software Security
• Discrete Structure
• Theory of Computation
• Database Management System (3R)
Prof. V. S. Mahalle
Area of Interest: Machine Learning, Deep Learning
5. Introduction and Importance of Subject
• OBJECT ORIENTED:
Programming Technique / Programming Approach
• PROGRAMMING LANGUAGE:
Solving problems using Computer, it requires Programming Language.
Java: “Object Oriented Programming Language”.
Demand of IT Industry to develop Applications.
OBJECT ORIENTED PROGRAMMING
6. • Human to Human Communication:
• We need a language to communicate
with each others.
We can use Marathi, Hindi, English ….
What is Programming Language?
• Human to Computer(M/C) Communication.
• We need a language to communicate between
Human & Machines. (M/C perform complex operations in easy way.
We can use C, C++, Java … programming Language.
“Communication is Possible because of Languages”.
What is Language?
7. Classification of Programming Language:
Programming Languages
Machine Language Assembly Language High Level Languages
• Low Level Language
• Binary Language (0 & 1)
• Translator: Not Required
• Computer understand Lang.
• Symbolic Language
• Mnemonic Language
• Symbols like:
Load, Move, Add, Store …
• Translator: Assembler
• Just like English Language
• BASIC, Pascal, FORTRAN,
COBOL, C, C++, Java, Python,
C#, PROLOG, .NET …
• Translator: Compiler
00010001100100001001
00010011000110001111
00010010100…
Executable Machine Code
LOAD R1, b
LOAD R2, h
MUL R1, R2 <= Middle Level
DIV R1, 2 L. Program
RET
Class demo {
int rno;
public:
void read();
void display(); }
8. Advantages and Disadvantages:
MACHINE LANGUAGE
• Advantages:
o It does not require any translator, It is directly understood by Computer.
o It makes fast and efficient use of the computer.
• Disadvantages:
o Difficult to write and understand the code.
o Program is written at h/w level, So Knowledge of hardware is necessary.
ASSEMBLY LANGUAGE
Advantage:
o Writing programs in Assembly Language is easier & faster than
writing program in Machine Language.
• Disadvantage:
o Difficult to write complex programs fastlly.
o If program is too large then it is difficult to spot the errors.
o Machine dependent, i.e. a Program written in one computer can not
be run on another computer.
HIGH LEVEL LANGUAGE
• Advantage
o Easy to understand the Programs.
o Writing program in HLL is faster
than writing program in Assembly
Language. It is programmer friendly.
• Disadvantage:
o It takes additional translation time
to translate it into machine code.
9. Classification of High Level Languages
H.L. Programming Languages
Procedure Oriented
Programming Languages
Object Oriented
Programming Languages
• These are two different approaches/ways for writing programs.
for example: How you earn money?
Different ways: -Doing Job
-Doing Business
-Taking Tution classes
- Making videos on YouTube.
Similarly, Writing programs in procedure oriented ways & writing programs in object oriented ways.
.
These are different ways or
approaches to earn money.
• Two different approaches of Program writing.
• Two different ways to build programs
• Two different program organization & development techniques.
• Two different program writing styles.
10. Programming Languages:
Procedure Oriented
Programming Languages:
• BASIC
• Pascal
• FORTRAN
• C
• C++
Object Oriented
Programming Languages:
• C++
• Java
• Python
• C#
• VB.Net
• PHP
• When we write program in C, then we
follow POP approach.
• When we write program in Java, then we
follow OOP approach.
When we write program in C++, then we can follow POP or OOP approach.
• That means
• C is a Procedure Oriented Programming Language.
• Java is a Object Oriented Programming Language.
• C++ is both Procedure Oriented as well as Object Oriented Programming Language.
11. Language Name of Father (Inventors)
C “Dennis Richie”
American computer scientist
C++ ” Bjarne stroustrup”
is a Danish computer scientist,
Java “James Gosling ”
Canadian computer scientist
Javascript ” Brendan Eich “
American technologist
Ruby “Yukihiro Matz”
Japanese computer scientist
Father of Languages
12. JAVA : Most demanding programming language of IT Industries:
JAVA : More popular programming Language:
13.
14. JAVA: Most dominating programming language in variety of domains:
Web Application Development:
JavaScript
Servlets, JSP
Android Application Development
Java Android Studio
Enterprise Application Development
J2EE
Big Data
Hadoop
15. Unit-I
Introduction to Object Oriented Programming:
• Introduction, Need of OOP
• Principles of OOP Languages
• Procedural Language Vs OOP
• Application of OOP
Java Virtual Machine(JVM)
Java Features,
Program Structure.
Java Programming Constructs:
•Variables, Primitive data types, Identifier, Literals
•Operators, Expressions, Precedence Rules and Associativity
•Primitive Type Conversion and Casting,
•Flow of Control
Syllabus
16. Unit-II
Classes and Objects:
• Classes, Objects, Creating Objects
• Methods, Constructors, Cleaning up Unused Objects
• Class Variable and Methods
• this keyword
• Arrays
• Command Line Arguments
17. Unit-III
Inheritance:
• Inheritance vs. Aggregation
• Method Overriding
• super keyword, final keyword
• Abstract class
Interfaces, Packages and Enumeration:
• Interface
• Packages, java.lang package
• Enum type
18. Unit-IV
Exception:
• Introduction
• Exception handling techniques
• User-defined exception
• Exception Encapsulation and Enrichment
Input/Output:
• The java.io file class
• Reading and Writing data
• Randomly Accessing a file
• Reading and Writing files using I/O package.
19. Unit-V
Applets:
• Introduction, Applet class, Applet structure, Applet Life cycle.
• Common Methods used in displaying the output: paint(), update() and
repaint().
• More about applet tag, get Document Base() and get Code Base() methods.
• Applet Context Interface, Audio clip.
• Graphic class, Color, Font, Font Metrics.
20. Unit-VI
Event Handling:
• Introduction
• Event delegation Model
• Java.awt.event
• Sources of events,
• Event Listeners,
• Adapter classes
• Inner classes.
Abstract Window Toolkit:
• Introduction
• Components and Containers
• Button, Label, Checkbox, Radio Buttons, List Boxes, Choice Boxes, Textfield and Textarea
• Container class
• Layouts
• Menu, Scrollbar.
21. Text Books:
1. Sachin Malhotra and Saurabh Choudhary: Programming in Java, Oxford
University Press 2010.
2. Herbert Schildt: Java Complete References (McGraw Hill)
Reference Books:
1. H. M. Dietel and P. J. Dietel, “ Java How to Program” Pearson Education
2. E. Balagurusamy: Programming with Java (McGraw Hill)
3. Dr. R. K. NageswaraRao: Core Java An Integrated Approach (Dreamtech)
4. Khalid Mughal: A Programmer’s Guide to Java Certification, 3rd Edition (Pearson)
5. Sharnam Shah and Vaishali Shah: Core Java for Beginners,(SPD),2010.
22. Unit-I
Introduction to Object Oriented Programming:
• Introduction, Need of OOP
• Principles of OOP Languages
• Procedural Language Vs OOP
• Application of OOP
Java Virtual Machine(JVM)
Java Features,
Program Structure.
Java Programming Constructs:
•Variables, Primitive data types, Identifier, Literals
•Operators, Expressions, Precedence Rules and Associativity
•Primitive Type Conversion and Casting,
•Flow of Control
23. 1. Introduction to Object Oriented Programming
2. Need of OOP
Objectives
24. • Procedure Oriented and Object Oriented are
programming approaches/Paradigms of Programming.
ways to build programs
two different
program organization & development techniques
program writing styles.
1. Introduction to Object OrientedProgramming
25. What is Procedure Oriented Programming Approach?
• Writing list of sequence of statements/Instructions for computer to follow to solve a
particular problem.
OR
• In Procedural Language,
A program is a list of sequence of statement/instruction for computer to execute.
Computer execute statements one after another.
Example 1:
To withdraw money from ATM. To solve this problem, we use following sequence of steps.
(i) Insert ATM card in ATM m/c.
(ii) Enter Pin Number.
(iii) Enter amount to withdraw.
(iv) Collect money and ATM card.
(v) end
We required to follow certain procedure.
From top to bottom.
When we want, Computer execute statements
sequentially, then we apply POP approach.
26. Example 2: Write a program to read test marks of two subjects of a student and find the average marks.
C
#include<stdio.h>
void main()
{
int ms1, ms2, total, avg;
printf(“Enter marks in test1 and test2n”);
Scanf(“%d %d”, &ms1, &ms2);
total = ms1+ms2;
avg = total/2;
printf(“%d Average=”, avg);
}
C++
#include<iostream.h>
void main()
{
int ms1, ms2, total, avg;
cout<<“Enter marks in test1 and test2n”;
cin>>ms1>>ms2;
total = ms1+ms2;
avg = total/2;
cout<<“Average=”<<avg;
}
POP is a top-down approach of Programming
C & C++ Programs written using POP approach.
27. What is object oriented programming approach?
• OOP is different programming approach than POP approach.
• It is a new way of
(i) decomposition of problem
(ii) Writing programming solutions.
• OOP approach, which deals with the concept of objects to build programs/ application
software.
• In OOP,
we organize software/program as a
collection of objects
&
that work together concurrently to
produce software.
Black Board
Teacher
Chalk
Chair
Object
Object
Object
• Object is the heart of Object Oriented Programming.
• Object is the major & most important entity in
object oriented programs. They interact with
each others by sending messages.
Object
28. C++
#include<iostream.h>
class Student
{ char name[25];
int rollno;
int ms1, ms2;
Public:
void read() {
cout>>”Enter name, roll no and marks in ms1, ms2n”;
cin>>name>>rollno>>ms1>>ms2; }
void display() {
cout<<name<<“ “ <<rollno<<“ “<<ms1<<“ “<< ms2;}
};
void main()
{
Student s1,s2;
s1.read();
s1.display();
s2.read()
s2.display();
}
JAVA
class Student
{ int rollno=10;
int ms1=28,ms2=18;
void m1()
{//instance area
System.out.println(rollno);
System.out.println(ms1);
System.out.println(ms2);
}
public static void main(String[]
args)
{
Student s= new Student();
System.out.println(s.rollno);
System.out.println(s.ms1);
System.out.println(s.ms2);
s.m1();
}
}
OOP is a bottom-up approach of Programming
29. C++
class Hello
{ int i;
public:
{
int j;
void f1()
{
cin>>i;
cout<<"Hello!n";
cout<<i;
}
}
};
void main()
{
Hello h;
h.j=10;
h.f1();
}
Java
// Prints a value & message
public class Hello
{
int a=100;
public static void main(String[] args)
{
Hello o = new Hollo();
System.out.println(o.a);
System.out.println("Hello!n");
}
}
OOP is Bottom-Up Programming Approach.
30. Real Life Example
Procedure Oriented Approach
• To withdraw money from ATM. To
solve this problem, we use
following sequence of steps.
(i) Insert ATM card in ATM m/c.
(ii) Enter Pin Number.
(iii) Enter amount to withdraw.
(iv) Collect money and ATM card.
(v) End.
Object Oriented Approach
31. 2. Needof Object OrientedProgramming
Why Object Oriented Programming approach was developed?
(I) To overcome limitations in earlier approach.
(II) OOP approach have number advantages.
(III)OOP have best programming concepts & several powerful
features that very closely maps with real world examples.
32. (I) To overcome difficulties & limitations in earlier POP approach.
• Writing program using Procedure Oriented approach and When length of program increases,
then its complexity also increases.
So
(i) it is very difficult to maintain a very large program in earlier POP approach.
This problem is overcome by dividing large program into different functions, but it
gives birth to other problems.
(ii) Functions have unrestricted access to global data.
(iii) They provide poor mapping to real world entities.
• Other Problems:
(iv) More importance given to procedure/algorithms rather than data.
(v) Data is not secure, it moves openly from function to function.
33. Concepts and features of OOPs closely maps with real world entities.
• Features or characteristics of OOP:
(i) More importance is given to data rather than procedure.
(ii) Programs are divided into objects
(iii)Data is hidden and can not be accessed by external functions.
(iv) New functions and data can easily be added whenever needed.
(v) Follow bottom-up approach in program design.
34. (II) Benefits/Advantages of Object Oriented Programming Approach:
• Faster Development of Software.
• Adapt to changing requirements
• Reusability: reuse existing code to extend functionality of software.
• Easier to maintain
• Increased software quality.
35. (III) OOP have best programming concepts & several powerful features
that very closely maps with real world examples.
Object Oriented
Programming
Concepts & Features
1. Object
2. Classes
3. Encapsulation
4. Abstraction
5. Inheritance
6. Polymorphism
36. 1. What is Object Orientated/Orientation?
OR
What is Procedure Oriented Programming Approach?
AND
What is Object Oriented Programming Approach?
37. 2. Why Object Orientated Programming Approach was developed?
3. What are the different characteristics/features of
o Procedure Oriented programming approach
and
o Object Orientated Programming Approach?
38. o Some Characteristics exhibited by Procedure Oriented Programming are:
• Emphasis is on doing things (Algorithms).
• Large programs are divided into smaller programs known as functions.
• Most of the functions share global data.
• Data move openly around the system from function to function.
• Employ top-down approach in program design.
39.
40. o Some Characteristics exhibited by Object Oriented Programming are:
• Emphasis is on data rather than procedure.
• Programs are divided into what are known as Objects.
• Functions that operate on the data of an object are tied together in the data structure.
• Data is hidden and cannot be accessed by external functions.
• Objects may communicate with each other through functions.
• New data and functions can be easily added whenever necessary.
• Follows bottom-up approach in program design.
41.
42. 1. Principles of OOP LANGUAGES.
2. Procedural Languages Vs OOP Languages
3. Applications of OOP
43. 3. Principles of Object Oriented Programming
4. Procedural Languages Vs OOP Languages
5. Applications of OOPs
Objectives
44. 3. Principles of OOP Languages
• OOP languages ==> follow certain principles.
• It has ==> Some new best programming concepts & several powerful features.
Language that has this concepts & features, then
that Language is called Object Oriented
Programming Language.
Different OOP concepts & features:
1.Classes
2.Objects
3.Encapsulation
4.Abstraction
5.Inheritance
6.Polymorphism
OOP concepts & features are widely used in almost
all modern programming Languages except C.
Pillars of any OOP Language.
If you want to start programming in C++, Java or Python, then you must understand the concepts & features of
OOPs as these languages are Object Oriented Programming Languages.
45. • Class is the description of similar type of objects.
• Abstract things are called class and they do not have any physical existence.
• Class is a logical entity which contains logic of an application.
• Class is a blue print, it decide object creation and without class, there is no object.
Class is not a real world entity. It is just a template or blueprint or prototype from which objects are
created)
• Based on single blueprint multiple objects are possible.
• Class is a user defined datatype and it contains attributes (data members) &
1. Classes:
46. What is class?
Class is a description of similar type of Objects.
ANIMALS
FURNITURE
FRUITS
• Class is a description of similar objects, that shares common attributes & behaviors.
Student
name
class
rollno
read()
display()
Class Diagram
47. • Example:
• Teacher:
Dr. P. K. Bharne, Prof. J. M. Patil, Prof. Ms. K. P. Sable…
• Animal:
• Classes Dog, Cat, Cow, Tiger…
• Furniture:
Chair, Table, Black Board…
• Vehicle:
Car, Bus, Train, Boat, Plane…
• Objects
• Q Chair, Table, Black Board… belongs to which class? Ans: It belongs to Furniture class
• Q Dog, Cat, Cow… belongs to which class? Ans: It belongs to Animal class
We can not say, it
belongs to Vehicle
Abstract Things are called ==> Classes.
Specific or Concrete things are called ==> Objects.
Specific Things
Abstract Things
48. • Suppose, I ask you, call to teacher.
then you will confuse ==> Which teacher? Teacher is there, but something is hidden
& you do not guess.
• Suppose, I ask, show me a Animal ==> confuse, which Animal?
Teacher, Animal, Furniture … ===> They do not have any Physical existence.
Classes are logical in nature and they do not have any existence.
Example: Furniture do not have any existence but Chair, table… do exist.
Class is a description of similar type of objects.
Example: Furniture: Chair, table, black board…
Animal: dog, cat, cow…
We can not say ‘Tiger’ is a Furniture.
49. A Class can also defined as the blue print for an Objects. Or A class serves as template for Object
Once class is defined, then we can create any number of objects of that class.
A Class is defined as a user defined data type.
int, float, char …. ===> Predefined data types
Int a, b, c; ==> a, b, c of type int
Fruit, Animal, Shape… ==> classes
Fruit mango, orange, apple; ===> mango, orange, apple of type Fruit. (User defined).
A Class contains two things:
Data members & Methods
Once class is defined, then we can create any number of objects of that class.
50. • Graphical Notation for Class:
• Example===>
Name Compartment
(Mandatory)
Attribute Compartment
(Optional)
Operation Compartment
(Optional)
BankAccount
- accountNumber : string
- owner: string
- Balance: double = 0.0
+ deposite( amount: double)
+ withdraw (amount: double)
+ getOwner() : string
+ getBalance(): double
name
compartment
attribute
compartment
operation
compartment
class name
initial
values
visibility
adornment
Naming Convention:
Class Name:
Write in UpperCamelCase.
Attributes & Operations:
Write in LowerCamelCase
Visibility Adornment
• Highlight imp features, clarity & readability dig.
+ : public
- : private
# : Protected
• Graphical Notations of Class
called Class Diagram.
51. • Identify classes from following and then corresponding objects?
Vehicle, dog, bus, peckok, circle, cat, sham, Bird, Animal, Shape, car, ram,
parrot, Student, square
Classes Objects
Vehicle car, bus
Bird parrot, peckok
Animal cat, dog
Shape circle, square
Student ram, sham
52. Concrete/Specific thing is called ===> Object
.
Object is a real world entity & they have physical existence.
.
2. Objects :
53. It is a discrete & distinguishable entity with a well-defined boundary
that encapsulate states and behaviors.
Maker
Model
Color
Year
Price
Start()
Drive()
Park()
car
Breed
Color
Height
Weight
Yearofbirth
Eating()
Sleeping()
dog
Task Performed
54. It is a variable of type class.
C++
#include<iostream.h>
class Student
{ char name[25];
int rollno, ms1, ms2;
Public:
void read() {
cout>>”Enter name, roll no and marks in ms1, ms2n”;
cin>>name>>rollno>>ms1>>ms2;}
void display() {
cout<<name<<“ “ <<rollno<<“ “<<ms1<<“ “<< ms2; }
};
void main()
{ Student s1,s2;
s1.read();
s1.display();
s2.read()
s2.display();
}
It is a run time entity in OO Programs.
JAVA
public class Student
{ int rollno=10;
int ms1=28,ms2=18;
public static void main(String[] args)
{
Student s = new Student();
System.out.println(s.rollno);
System.out.println(s.ms1);
System.out.println(s.ms2);
s.m1();
}
void m1()
{
System.out.println(rollno);
System.out.println(ms1);
System.out.println(ms2);
}
}
• Just like we create variables of type integer i.e. int
a,b,c; Similarly, we can create variables of type
class, called Objects.
55. ANIMALS
Class is a collection of similar types of Objects.
Object-1
(Cat)
Object O1
Object-3
(Horse)
Cat is an instance of class ANIMAL
Each Object is an Instance of a Class.
Breed
Height
Weight
Object O2
Breed
Height
Weight
O1
O2
Object is an Instance of a Class.
Each Object takes
its own space in
Memory.
Object-2
(Dog)
56. • Characteristics of Objects:
All Objects have three characteristics:
(i) Identity
(ii) State
(iii) Behavior
57. (ii) State:
• It is determined by attribute value.
Example: If balance = -ve, then
state = “Overdrawn”
If balance = 0, then
state = “Empty”
If balance = +ve, then
state = “In-credit”
• May
change
over
time
(iii) Behavior:
The set of operations that an
object can perform.
(i) Identity:
• Each object must have its own unique name.
This property, distinguishes objects from one-another.
58. Example#1:
Attributes of the Object
Behaviors of the Object States of the Object
Attribute Value of Attribute
Name Hoda City ZX Car Starts - StartCar() Car is Moving - Moving State
Car Company Honda Car Stops - StopCar() Car us in Stop state - Stop State
Car Owner Ranjeet Deshmukh Change the speed - Accelerate()
Car Number MH-09 BD 4928
Car Color White
Tank Capacity 35 Liters
Seating Capacity
5
Mileage 12 Km/Lit
Car
59. Example#2: myBankAccount
Attributes of the Object
Behaviors of the Object States of the Object
Attribute Value of Attribute
Owner Name V. S. Mahalle Withdraw() incredit
Account Number 1234567 Deposite() empty
Date of Opening 20 Dec. 1994 Overdrawn
Current Balance 10 Lac
Attributes of the Object
Behaviors of the Object States of the Object
Attribute Value of Attribute
Name Deepika - speak() talking Sate
Birthdate 15 Aug. 1982 - walk() walking State
Address Nariman Point, Bombay - run() running State
Education MBA - dance() dancing State
Example#3:
60. Messaging
• In OO systems, Object interact with each others by sending messages.
• Objects send messages to each other over links.
• These messages cause an object to invoke an operation
60
Account object responds
by invoking its withdraw
operation. This operation
decrements the account
balance by 150.00.
Bank Object Account Object
withdraw( 150.00 )
Bank object sends
message
“withdraw
150.00” to an
Account object.
message
61. • Graphical Notation of Objects/(Syntax):
always underline
OBJECT IDENTIFIER
Name Compartment
Attribute Compartment
• Object Identifier: It consist of any of the following:
(i) Class name alone:
(ii) Object Name alone:
(iii) Object Name concatenated with class name:
:Account
sachinAccount
sachinAccount:Account
• Attribute Syntax:
VM attribute name: attribute type = Value
• Naming:
object and attribute names Write in
lowerCamelCase
62. Example of Object:
62
sachinAccount : Account
accountNumber : String = "1234567"
owner : String = “Sachin"
balance : double = 300.00
attribute
name
attribute
compartment
name
compartment
attribute
type
attribute
value
object
name
class
name
sachinAccount : Account
sachinAccount
: Account
object and
class name
object name
only
class name
only
an anonymous object
object identifier
(must be underlined)
• Attribute compartment is
omitted to simplify the diagram
63. Classes Objects
Class is not real world entity & they do
not have any physical existence.
Object is a real world entity & they have
physical existence.
Abstract things are called class.
Ex.-Furniture, Student, Animal
Concrete/Specific things are called objects.
Ex.- chair, table, anil, sunil, apple, orange…
Class is a logical entity, which contains
logic of application.
Object is a physical entity, which represent
memory.
Class is a blue print for an object. Object creation is not possible without class.
Class is a user defined data type. Object is an instance of a class. It is a run time
entity in OO programs
64. 3. DataEncapsulation
• The wrapping up (binding) of data and methods(functions) that operate on
it into a single unit(class) is termed as data encapsulation.
* Capsule in medical term
class Demo
{
variables data member
+
methods(behavior) member methods
}
Medicine is kept inside Capsule. Why? ==>To protect it from outside environment
(moisture, temperature, dust…).
• Cap is termed as a class in Object Oriented terminology & to keep data secure,
we place it in the class. (i) Data & functionality binding together within a class.
(ii) Access to data in controlled manner.
Two things Encapsulation have:=>
65. Data hiding:
Encapsulation is as a protective wrapper, that prevent the data & methods from accessing by
other methods defined outside the class.
Private
public
Data
method
method m
e
t
h
O
d
• Generally,
Data Members ==> Declared as Private
Member methods ==> Declared as Public
Private:
Restricted access
from outside class.
Public:
Can access anywhere
through class Object.
Private data members in class are hidden and not accessible to methods
defined outside of a class. It is accessible only through its public member
methods.
This process or mechanism is called as data hiding.
method
66. • Example1: When will you come to Shegaon, bring home made sweet for me.
4. Data Abstraction
Example2: Driving a Car
• We are happy with the abstraction
provided to us like steering, brakes,
gear etc.
• We interact with them without
knowing the internal details about:
how the car engine works and how the car stops
on applying brakes.(We don’t want to know this)
Highlighting only the essential features and hiding unnecessary details.
That reduces the complexity & increases the efficiency.
• Displaying only the useful information & hiding unnecessary details from the users.
67. • We follow the instruction given by GUI. We do not know
the necessary technology back site of it, we are not
interested.
• When we enter pin, we are not interested what is happen
internally, which code is executed, where it is executed.
• We are also not interested to know all the things in detail.
• Simply we are using the ATM by following the
Instructions.
• Advantage:
1. Hiding is there, the biggest advantage is Security.
2. Maintainability of application is improve.
Encapsulation: => Hiding data. Abstraction:=> Hiding implementation details.
Implementation of
abstraction in Java by:
abstract class
Interface
Example3: ATM
Highlighting set of services they are offering and hiding internal implementation.
68. • Relationship between classes
• Organization of classes into Super-Subclass hierarchy.
• Sharing of class members (attributes and methods) among classes based on hierarchical
relationship.
• Deriving a new class from existing class is called Inheritance.
• Base/Super/Parent class
• Derived/Sub/Child class
•
5. INHERITANCE
Class D
Class B Parent
Child
Vehicle
Car MotorCycle
Common features of classes are defined into
Super class.
Each sub-class inherits, all the features of its
super class & can add its own features.
• Inheritance increases the reusability of code.
• Inheritance increases the readability of code.
69. “IS A” Relationship:
• How can we find there is an Inheritance or not?
• Inheritance is one sided.
One Direction it is right.
Other Direction it is wrong.
• Father gives his property to child ,
so child is the taker and father is giver.
• child couldn’t give its property to father
so Inheritance is one sided
• Examples:
• Faculty is a Person.
• Student is a Person.
• Apple is a Fruit.
• Dog is a Animal
• Chair is Furniture.
• A car is a Vehicle.
There is “is a” relationship between Classes.
&
We are able to relate two classes, then
there is a Inheritance relationship.
extends keyword is used to implement
Inheritance in Java.
70. Types of Inheritance:
1. Single Inheritance
2. Multilevel Inheritance
3. Multiple Inheritance
4. Hierarchical Inheritance
5. Hybrid Inheritance
Class A
Class B
Class A
Class B
Class C
Class B2
Class B1
Class C
Class A
Class B1 Class B2
Class B1 Class B1
71. 6. polymorphism
Poly = Many and Morphism = Forms. Polymorphism = Many forms.
It can be defined as the same thing being used in different forms.
• Example: Student (If your are in class room that time you behave like a student)
• Yourself Customer (When you are in market at that time you behave like a customer)
Son/Daughter (When your at your home at that time you behave like a son/daughter)
• Here one person presents different-different behaviours.
• More than one behaviours(Methods) with same name is called Polymorphism.
• In Java, add two integers int a = 10, b = 20,c;
• + c = a + b;
concatenate two strings. System.out.println(“c=”+c);
72. Addition
add(int i, int j);
add( float a, float b)
Types of Polymorphism:
Polymorphism
1. Compile Time Polymorphism 2. Run Time Polymorphism
or or
Static Polymorphism / Early Binding. Dynamic Polymorphism / Late Binding
*Memory allocated only at Compile time. *Memory allocated at Run time.
Example of Compile time polymorphism is
Method Overloading
Example of Run time polymorphism is
Method Overriding
Shape
area()
appropriate method is invoked at compile time
by matching number, order & type of arguments
Method name -> Same
Signature-> Different
Method name -> Same
Signature-> Same
appropriate method is invoked at run time by
matching with reference object.
Circle
area()
Rectangle
area()
73. 4. PROCEDURAL LANGUAGE VS OOP
Difference Between Procedural and Object Oriented Programming Languages
Procedural Language OOP
1. Separate data from functions that operate on
them.
1. Encapsulate data and methods in a class.
2. Not suitable for defining abstract types. 2. Suitable for defining abstract types.
3 Debugging is difficult. 3. Debugging is easier.
4. Difficult to implement change. 4. Easier to manage and implement change.
5. Not suitable for larger programs/applications. 5. Suitable for larger programs and
applications.
6. Analysis and design not so easy. 6. Analysis and design made easier.
7. Faster. 7. Slower.
8. Less flexible. 8. Highly flexible.
9. Data and Procedure based. 9. Object oriented.
74. Procedural Language OOP
10. Less reusable. 10. More reusable.
11. Only data and procedures are there. 11. Inheritance, encapsulation and
polymorphism are the key features.
12. Use top-down approach. 12. Use bottom-up approach.
13. Only a function call to another. 13. Object communication is there.
14. Example:
Basic, FORTRAN, Pascal, C.
14. Example:
C++, JAVA, Python,VB.NET, C#.NET
15. Does not have access specifiers/modifiers. 15. Use public, private, protected access
specifiers/modifiers.
16. Overloading is not possible. 16. Supports Method Overloading.
17. Less secure.
(Data hiding is not possible)
17 Highly secure.
(Data hiding is possible)
18. More emphasis is given to Procedure/Algorithm. 18. More emphasis is given to data.
75. 5. APPLICATIONOF OOP
Y2K Problem:
Occurs due to the use of Procedural software development approach.
Occurs due to the writing convention of year attribute.
Programmer consider only two digits in year instead of four digits, when they specify
system date during implementation of software.
Because of consideration of two digits in year, all the computer in the world suddenly
stops their working on 31st December 99 at 12’O clock midnight.
(After year 98, it change to 99 but after 31st Dec. 99, year change to 2000).
Conversion of year in date, from 2 digit to 4-digit is not any easy task, when we use
Procedural Software Development Approach. It requires to analyze & make changes in
multiple lines of code.
But when Object Oriented Software Development Approach is used, then change is
made only in class and that change is automatically reflected in all objects. i.e. It easier
to over come any problem when OO software development approach is used. (There is
no need to make changed in whole system.
76. The applications of OOP, where Object Oriented Programming is suitable:
1. Real time system:
What is a real time system? It is a system where the parameters change every time.
Thus, output changes instantaneously.
It results in a dynamic system. So we can say run time system is a dynamic system.
For example: A Thermal Plants: temperature, water level & other parameters changes
frequently, so it is a dynamic system.
OOPs is used to develop such a system.
2. Simulation and modeling:
What is a Simulation? Simulation means imitation of real world product. Without
physical construction, we can develop a product & we can check how its looks like.
For example: A Car Industry, initially they develop a simulation & modeling system
instead of directly going to develop a real product.
This can easily be represented using OOP. 06 OOPS Benefits & Applications: 1341_004_KMM
77. 3. CAM/CAD Systems:
Computer Aided Manufacturing
Computer Aided Design
Here also we can make use of OOP.
4. Office Automation System:
Automation is a type of real system
Embedded systems makes it easy
Here also we make use of OOP to develop automation & embedded systems.
5. AI (Artificial Intelligence):
(Combination of both hypermedia and real time system)
6. Neural Network and Parallel Programming:
Refer to a network of biological neurons
Consists of artificial neurons or nodes
Large problems divided into smaller ones; solved concurrently (in parallel)