0% found this document useful (0 votes)
48 views

Object Oriented Concept

Object oriented programming is a programming paradigm that emphasizes the use of objects. Some key concepts of OOP include classes, objects, inheritance, polymorphism, encapsulation, and abstraction. A class defines the template for objects, while an object is an instance of a class. Constructors allow objects to be initialized when they are created. Methods can be overloaded and classes can inherit functionality from other classes through inheritance. Encapsulation groups data and methods together within a class and controls access to prevent misuse. Polymorphism allows different objects to respond to the same message differently depending on their type.

Uploaded by

Khagesh Josh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Object Oriented Concept

Object oriented programming is a programming paradigm that emphasizes the use of objects. Some key concepts of OOP include classes, objects, inheritance, polymorphism, encapsulation, and abstraction. A class defines the template for objects, while an object is an instance of a class. Constructors allow objects to be initialized when they are created. Methods can be overloaded and classes can inherit functionality from other classes through inheritance. Encapsulation groups data and methods together within a class and controls access to prevent misuse. Polymorphism allows different objects to respond to the same message differently depending on their type.

Uploaded by

Khagesh Josh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

OBJECT ORIENTED

CONCEPT
PRESENTED BY Amit Basan
Object Oriented Concept

■ Central concept of OOP is object.


■ Emphasize on data.
■ Object is entity that has its own internal state and behavior.
■ Most powerful paradigm of programming.
■ E.g. Java, C++, Ruby, Python etc.
Characteristics of OOP

■ Class
■ Object
■ Inheritance
■ Polymorphism
■ Encapsulation
■ Data Abstraction
■ Message Passing
Classes vs Objects

■ Classes and objects are fundamental components of OOP’s.


■ Class is blue print of Object.
■ Object is instance of class.
■ Class is logical entity while object is physical entity.
■ Class declaration only creates a template; it does not create an actual object.
Creating a simple class
Declaring Object

■ Obtaining objects of a class is a two-step process.


• First, we must declare a variable of the class type.
• Second, we must acquire a physical copy of the object and assign it to that
variable.
■ “new” operator is used.
■ The new operator dynamically allocates memory for an object.
■ Creating an object of the class “Box” :
Box mybox = new Box();
Introducing method
Constructor

■ Block of code similar to method.


■ Called automatically when instance object is created.
■ Same name as the class.
■ No return type, not even void.
■ If not defined explicitly then java creates default constructor for class.
■ Types of constructor :
– Default constructor
– Parameterized constructor
Default Constructor

■ If we don’t define a constructor then compiler creates a default constructor for class.
■ The default constructor automatically initializes all instance variables to their default
values, which are zero, null, and false, for numeric types, reference types, and Boolean,
respectively.
■ Also known as no-argument constructor or zero-argument constructor.
Parameterized Constructor

■ that accepts one or more parameters is known as Parameterized constructor.


■ Used to provide different values to the distinct objects.
■ Similar to parameter passing to method.
Parameterized Constructor
“this” keyword

■ A method will need to refer to the object that invoked it.


■ This can be used inside any method to refer to the current object.
Abstraction

■ Abstraction refers to the act of representing essential features without


including background detail or explanations.
■ Humans manage complexity through abstraction.
■ In OOP, abstraction is achieved by the help of class, where data and
methods are combined to extract the essential features only.
■ It focuses the outside view of an object, separating its essential behavior
from its
implementation.
Encapsulation

■ the process of combining the data and functions into a single framework
called class.
■ preventing the modification of data from outside the class by properly
assigning the access privilege to the data inside the class.
■ the term data hiding is possible
Polymorphism

■ Polymorphism means “having many forms”.


■ The polymorphism allows different objects to respond to the same message in different
ways, the response specific to the type of object.
■ The specific action is determined by the exact nature of the situation.
■ There are two types of polymorphism in java: compile time polymorphism and runtime
polymorphism.
■ We can perform polymorphism in java by method overloading and method overriding.
Method Overloading
■ If two or more method in a class have same name but different parameters, it is known
as method overloading.
■ In Java, it is possible to define two or more methods within the same class that share the
same name, as long as their parameter declarations are different.
■ Method overloading is one of the ways that Java supports polymorphism.
■ Overloaded methods must differ in the type and/or number of their parameters.
■ While overloaded methods may have different return types, the return type alone is
insufficient to distinguish two versions of a method.
Constructor overloading

■ In addition to overloading normal methods, you can also overload constructors


■ Constructor overloading is a concept of having more than one constructor with different
parameters list, in such a way so that each constructor performs a different task.
Recursion

■ Recursion is the process of defining something in terms of itself.


■ As it relates to Java programming, recursion is the attribute that allows a method to call
itself.
■ A method that calls itself is said to be recursive method.
Access Control
■ Encapsulation provides another important attribute: access control.
■ Through encapsulation, you can control what parts of a program can access the members of
a class.
■ By controlling access, you can prevent misuse.
■ The access modifiers in java specifies accessibility (scope) of a data member, method,
constructor or class.
■ There are four access modifiers in java which are :
■ 1. Default Access Modifier - No Keyword
■ 2. Private Access Modifier - private
■ 3. Protected Access Modifier – protected
■ 4. Public Access Modifier – public
Access Control
THANK YOU

You might also like