You are on page 1of 14

OOP

Concepts
By

Rajanikanth B

www.btechsmartclass.com
Introduction
OOP stands for Object Oriented Programming
Introduction
Majorly there are FOUR concepts in OOPs
Introduction
1. Encapsulation

2. Abstraction

3. Polymorphism

4. Inheritance
BEFORE… start these concepts

We must know the following

What is an Object?
What is a class?
ENCAPSULATION
Process of combining data and code

Encapsulation = Data + Code


Here Data represents Here Code represents
Variables in program functions in program
ENCAPSULATION
This concept can be implemented using class

Encapsulation
Class of variables =
= variables
Class is a collection Data + single
+ functions
and functions under Code unit
ENCAPSULATION
class BankAccount
BankAccount
Attributes
{
String name ;
String name ;
int accountNumber;
int accountNumber;
double balance ;
double balance ;
String dateOpened;
String dateOpened;
String accountType;
String accountType;
String branch;
String branch; Behavior
void open( ){….}
void open( ){….}
void close( ){….}
void close( ){….}
void deposit( ){….}
void deposit( ){….}
void withdraw( ){….}
void withdraw( ){….}
}
ABSTRACTION
Process of focusing on the essentials, ignoring the irrelevant
and unimportant things

Simply abstraction is hiding


information which is not required
ABSTRACTION
We use access modifiers to implement this concept

We use keywords like public, private, protected, friend….


ABSTRACTION
private

All the members which are declared under


private can be accessed by same class
members only. No other class can not access
the private members of any other class.
ABSTRACTION
public

All the members which are declared under


public, can be accessed by any class members
and from any where.
ABSTRACTION
protected

All the members which are declared under


protected, can be accessed by same class
members and its derived class members.
ABSTRACTION
Modifier Class Package Subclass World

public Yes Yes Yes Yes

protected Yes Yes Yes No

private Yes No No No

No modifier Yes Yes No No

You might also like