Introduction to Object-Oriented
Programming
Chapter 1
Object-Oriented Programming
 Object-oriented programming (OOP) involves
programming using objects.
 The major objective of OOP is to eliminate the
some of the flaws encountered in the procedural
approach
 OOPs treat data as critical element in the
program development and not allow to flow freely
around the system.
 An object represents an entity in the real world
that can be distinctly identified.
 For example, if student is class then behaviors
and characteristics are said to be objects,
Object-Oriented Programming
Paradigms
 A set of concepts, principles, and rules is called a
programming paradigm.
 Types of paradigms are
 Imperative paradigm
 Object Oriented Paradigm
 Declarative programming paradigm
 Functional programming Paradigm
Imperative paradigm
 Imperative programming is a
programming paradigm in which statements are
written to change the state of the program. (Such
as Algorithm)
 Example (Getting of friend to your place)
 We'll explain to him how to get there in an
imperative way:
 From the Central Station, take train 1.
 Get off the train at the third station.
 Walk to the right, toward Sixth Avenue, until
you reach
the third junction.
Object Oriented Paradigm
 In practice, both functional and object-oriented
paradigms can coexist.
 Java is living proof that supports this collaboration
such as Classes and Objects.
Declarative programming and
Functional programming paradigm
 Declarative programming is a programming
paradigm that specifies what a program should
do
 example instead of telling our friend how to get
to the specific location, we can simply give him
the address and let him figure out how to get
there.
 The functions can be regarded more as
sequences of instructions, routines, or
procedures. (Data type, methods and functions )
Overview of OO principles
Four principles of object oriented programming:
 Data Abstraction
 Encapsulation
 Inheritance
 Polymorphism
Data abstraction
 Data abstraction refers to providing only
essential information about the data to the
outside world, hiding the background details or
implementation.
Encapsulation
 Encapsulation in Java is a mechanism of wrapping
the data (variables) and code acting on the data
(methods) together as a single unit.
 The technique of keeping together data structures
and the methods (procedures) which act on them.
 The user can only perform a restricted set of
operations on the hidden members of the class by
executing special functions commonly called
methods.
Inheritance
 Inheritance in Java is a mechanism in which one
object acquires all the properties and behaviors of
a parent object.
Polymorphism
 Polymorphism in Java has two types: Compile time
polymorphism (static binding) and Runtime
polymorphism (dynamic binding).
Java applications
 Java is a programming language that runs on any
platform. Its open-source' ecosystem is healthy and
strong. Being a fast and powerful language
Java is being used in:
 Real-time Systems
 Simulation and Modeling
 object oriented Databases
 Artificial Intelligence and Expert Systems
 CIM/CAD/CAM Systems
 Neural Networks and Parallel Programming
Java Applets
 An applet is a special kind of Java program that is
designed to be transmitted over the Internet and
automatically executed by a Java-compatible web
browser
 They are typically used to display data provided
by the server, handle user input, or provide
simple functions, such as a loan calculator, that
execute locally, rather than on the server
Editing, Compiling and
interpreting
class First
{
public static void main(String[] args)
{
System.out.println("Hello Java");
System.out.println("My First Java Program");
}
}
Compile and Execute Java Code
To compile: javac First.java
To execute: java First
Output
Hello Java

Chapter 1.pptx

  • 1.
  • 2.
    Object-Oriented Programming  Object-orientedprogramming (OOP) involves programming using objects.  The major objective of OOP is to eliminate the some of the flaws encountered in the procedural approach  OOPs treat data as critical element in the program development and not allow to flow freely around the system.  An object represents an entity in the real world that can be distinctly identified.  For example, if student is class then behaviors and characteristics are said to be objects,
  • 3.
    Object-Oriented Programming Paradigms  Aset of concepts, principles, and rules is called a programming paradigm.  Types of paradigms are  Imperative paradigm  Object Oriented Paradigm  Declarative programming paradigm  Functional programming Paradigm
  • 4.
    Imperative paradigm  Imperativeprogramming is a programming paradigm in which statements are written to change the state of the program. (Such as Algorithm)  Example (Getting of friend to your place)  We'll explain to him how to get there in an imperative way:  From the Central Station, take train 1.  Get off the train at the third station.  Walk to the right, toward Sixth Avenue, until you reach the third junction.
  • 5.
    Object Oriented Paradigm In practice, both functional and object-oriented paradigms can coexist.  Java is living proof that supports this collaboration such as Classes and Objects.
  • 6.
    Declarative programming and Functionalprogramming paradigm  Declarative programming is a programming paradigm that specifies what a program should do  example instead of telling our friend how to get to the specific location, we can simply give him the address and let him figure out how to get there.  The functions can be regarded more as sequences of instructions, routines, or procedures. (Data type, methods and functions )
  • 7.
    Overview of OOprinciples Four principles of object oriented programming:  Data Abstraction  Encapsulation  Inheritance  Polymorphism
  • 8.
    Data abstraction  Dataabstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.
  • 9.
    Encapsulation  Encapsulation inJava is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit.  The technique of keeping together data structures and the methods (procedures) which act on them.  The user can only perform a restricted set of operations on the hidden members of the class by executing special functions commonly called methods.
  • 10.
    Inheritance  Inheritance inJava is a mechanism in which one object acquires all the properties and behaviors of a parent object.
  • 11.
    Polymorphism  Polymorphism inJava has two types: Compile time polymorphism (static binding) and Runtime polymorphism (dynamic binding).
  • 12.
    Java applications  Javais a programming language that runs on any platform. Its open-source' ecosystem is healthy and strong. Being a fast and powerful language Java is being used in:  Real-time Systems  Simulation and Modeling  object oriented Databases  Artificial Intelligence and Expert Systems  CIM/CAD/CAM Systems  Neural Networks and Parallel Programming
  • 13.
    Java Applets  Anapplet is a special kind of Java program that is designed to be transmitted over the Internet and automatically executed by a Java-compatible web browser  They are typically used to display data provided by the server, handle user input, or provide simple functions, such as a loan calculator, that execute locally, rather than on the server
  • 14.
    Editing, Compiling and interpreting classFirst { public static void main(String[] args) { System.out.println("Hello Java"); System.out.println("My First Java Program"); } } Compile and Execute Java Code To compile: javac First.java To execute: java First Output Hello Java