OOPS

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Object-Oriented

Programming
OOPS is abbreviated as Object Oriented Programming
system in which programs are considered as a collection of
objects. Each object is nothing but an instance of a class.

Why we use Object-Oriented Programming ?

OOPS, make the development and maintenance of


projects easier.

OOPS provide the feature of data hiding that is good for


security concern.

We can provide the solution to real-world problems if we


are using object-oriented programming.
Classes in Java
A class is simply a representation of a type of object .It is the
blueprint/plan/template that describes the details of an
objects.
class ClassName{
Syntax //Attributes
//methods
}

Object
Object in Java

A object is an instance of a class .It has own state,behaviour


and identity.

State:It is represented by attributes of an object.


Behaviour:It is represented by methods of an objects.
Identity:It gives a unique name to an object.

Car obj=new Car(); //Creating an object

We can create an object by using the new keyword.The new


Keyword is used to allocate memory of an object dynamically
and return a reference to it.
Four Pillars Of OOPS
Encapsulation

Encapsulation is like a school bag that holds everything


together: books, lunchbox, pencils, and more, keeping
them safe and organized. In programming, it bundles data
and methods into one unit, protecting the inner details
from outside access
Polymorphism

Cash
draw
With

lance
ck Ba
Che

Polymorphism is like an ATM button that works for both


checking balance and withdrawing cash: it performs different
actions based on the context. In coding, it allowsone function
to behave differently depending on the input or object.
Inheritance

Inheritance is like a son inheriting traits from his father, such


as eye color or height. In coding, it allows one class to inherit
properties and methods from another.
Abstraction

Abstraction is like using an ATM where you can check


balance,deposit cash, withdrawmoney, or print a receipt
without knowing the complexworkings behind it. In coding,it
hides the details and shows only the essential functions

You might also like