OBJECT ORIENTED
PROGRAMMING
WHAT IS OOP..
Object-Oriented Programming is a methodology or paradigm to design a program
using classes and objects. It simplifies software development and maintenance by
providing some concepts:
Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
2
Class
GrayWhite Black
3
A class is the blueprint from which the individual objects are created.
Class are templates that are used to create objects, and to define object data types
and methods
It includes-
attributes (its fields or properties) and the things it can do (behaviours,
methods, operations or features).
A class defines the characteristics of an object.
Object
GrayWhite Black
4
An Object can be defined as an instance of a class.
An objects have the behaviors of their class.
The class specifies how instances are created and how they behave.
method: a method is an action which an object is able to perform.
Method
GrayWhite Black
5
Method is behavior of an object
Methods define the abilities of an object
Method usually affects only one particular object.
Method is a collection of statements that are grouped together to perform an operation.
Message passing
GrayWhite Black
6
When two or more objects communicate with each other that means that those objects are
sending and receiving messages. This is often called Message passing (method calling).
In this example the main function call method myFunction(),and the method is return to main.there is
a communication between main and myFunction()
Inheritance
GrayWhite Black
7
Inheritance in Java is a mechanism in which one object acquires all the properties and
behaviors of a parent object.
The idea behind inheritance in Java is that you can create new classes that are built
upon existing classes. When you inherit from an existing class, you can reuse methods
and fields of the parent class and additional properties of child class.
Inheritance
Gray
8
Abstraction
9
Abstraction is a process of hiding the implementation details and showing only
functionality to the user.
It shows only essential things to the user and hides the internal details, for example,
sending SMS where you type the text and send the message. You don't know the internal
processing about the message delivery.
Abstraction lets you focus on what the object does instead of how it does it.
We only wants to watch tv ,not wants to know the user manuel.
Encapsulation
GrayWhite Black
10
Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting
on the data (methods) together as a single unit.
An object behaves differently at different place is called polymorphism.
Polymorphism is briefly described as "one interface, many implementations.
Polymorphism
11
Method overloading
GrayWhite Black
12
two or more methods can have same name if they differ in parameters (different number
of parameters, different types of parameters, or both). These methods are called
overloaded methods and this feature is called method overloading.
Method overriding
GrayWhite Black
13
if the same method is defined in both the superclass class and the subclass class, then
the method of the subclass class overrides the method of the superclass. This is known
as method overriding.
Abstract Class
GrayWhite Black
14
A class which is declared as abstract is known as an abstract class. It can have
abstract and non-abstract methods. It needs to be extended and its method implemented.
It cannot be instantiated.
An abstract class must be declared with an abstract keyword.
It can have abstract and non-abstract methods.
It cannot be instantiated.
It can have constructors and static methods also.
abstract method
A method which is declared as abstract and
does not have implementation is known as
an abstract method.
Interface
GrayWhite Black
15
An interface in Java is a blueprint of a class. It has static constants and abstract
methods.
all the methods in an interface are declared with the empty body, and all the fields
are public, static and final by default. A class that implements an interface must
implement all the methods declared in the interface.
Interface supports multiple inheritance.
Abstract class and Interface
16
Abstract class and interface both are used to achieve abstraction where we can declare
the abstract methods. Abstract class and interface both can't be instantiated.
Abstract class
.It can have abstract and non-abstract
methods.
.It doesn't support multiple inheritance.
.It can have final, non-final, static and
non-static variables.
.It can provide the implementation of
interface.
.It can extend another Java class and
implement multiple Java interfaces.
.It can be extended using keyword "extends".
.It can have class members like private,
protected, etc.
Interface
.It can have only abstract methods. it can
have default and static methods also.
.It supports multiple inheritance.
.It has only static and final variables.
.It can't provide the implementation of
abstract class.
.It keyword is used to declare interface.
.It can extend another Java interface only.
.It can be implemented using keyword
"implements".
.Members of a Java interface are public by
default.

Oops presentation java

  • 1.
  • 2.
    WHAT IS OOP.. Object-OrientedProgramming is a methodology or paradigm to design a program using classes and objects. It simplifies software development and maintenance by providing some concepts: Object Class Inheritance Polymorphism Abstraction Encapsulation 2
  • 3.
    Class GrayWhite Black 3 A classis the blueprint from which the individual objects are created. Class are templates that are used to create objects, and to define object data types and methods It includes- attributes (its fields or properties) and the things it can do (behaviours, methods, operations or features). A class defines the characteristics of an object.
  • 4.
    Object GrayWhite Black 4 An Objectcan be defined as an instance of a class. An objects have the behaviors of their class. The class specifies how instances are created and how they behave. method: a method is an action which an object is able to perform.
  • 5.
    Method GrayWhite Black 5 Method isbehavior of an object Methods define the abilities of an object Method usually affects only one particular object. Method is a collection of statements that are grouped together to perform an operation.
  • 6.
    Message passing GrayWhite Black 6 Whentwo or more objects communicate with each other that means that those objects are sending and receiving messages. This is often called Message passing (method calling). In this example the main function call method myFunction(),and the method is return to main.there is a communication between main and myFunction()
  • 7.
    Inheritance GrayWhite Black 7 Inheritance inJava is a mechanism in which one object acquires all the properties and behaviors of a parent object. The idea behind inheritance in Java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of the parent class and additional properties of child class.
  • 8.
  • 9.
    Abstraction 9 Abstraction is aprocess of hiding the implementation details and showing only functionality to the user. It shows only essential things to the user and hides the internal details, for example, sending SMS where you type the text and send the message. You don't know the internal processing about the message delivery. Abstraction lets you focus on what the object does instead of how it does it. We only wants to watch tv ,not wants to know the user manuel.
  • 10.
    Encapsulation GrayWhite Black 10 Encapsulation inJava is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit.
  • 11.
    An object behavesdifferently at different place is called polymorphism. Polymorphism is briefly described as "one interface, many implementations. Polymorphism 11
  • 12.
    Method overloading GrayWhite Black 12 twoor more methods can have same name if they differ in parameters (different number of parameters, different types of parameters, or both). These methods are called overloaded methods and this feature is called method overloading.
  • 13.
    Method overriding GrayWhite Black 13 ifthe same method is defined in both the superclass class and the subclass class, then the method of the subclass class overrides the method of the superclass. This is known as method overriding.
  • 14.
    Abstract Class GrayWhite Black 14 Aclass which is declared as abstract is known as an abstract class. It can have abstract and non-abstract methods. It needs to be extended and its method implemented. It cannot be instantiated. An abstract class must be declared with an abstract keyword. It can have abstract and non-abstract methods. It cannot be instantiated. It can have constructors and static methods also. abstract method A method which is declared as abstract and does not have implementation is known as an abstract method.
  • 15.
    Interface GrayWhite Black 15 An interfacein Java is a blueprint of a class. It has static constants and abstract methods. all the methods in an interface are declared with the empty body, and all the fields are public, static and final by default. A class that implements an interface must implement all the methods declared in the interface. Interface supports multiple inheritance.
  • 16.
    Abstract class andInterface 16 Abstract class and interface both are used to achieve abstraction where we can declare the abstract methods. Abstract class and interface both can't be instantiated. Abstract class .It can have abstract and non-abstract methods. .It doesn't support multiple inheritance. .It can have final, non-final, static and non-static variables. .It can provide the implementation of interface. .It can extend another Java class and implement multiple Java interfaces. .It can be extended using keyword "extends". .It can have class members like private, protected, etc. Interface .It can have only abstract methods. it can have default and static methods also. .It supports multiple inheritance. .It has only static and final variables. .It can't provide the implementation of abstract class. .It keyword is used to declare interface. .It can extend another Java interface only. .It can be implemented using keyword "implements". .Members of a Java interface are public by default.