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

Lesson 1 - Introduction to Object Oriented Programming Concepts _ Introduction to Java

The document provides an introduction to Object Oriented Programming (OOP) concepts, covering procedural and object-oriented programming, and detailing the four principles of OOP: data abstraction, encapsulation, inheritance, and polymorphism. It also discusses Java as an object-oriented programming language, its history, types of Java programs, the compilation process, and key features such as platform independence and security. The document emphasizes the differences between procedural and object-oriented programming and explains how Java operates through a virtual machine.

Uploaded by

k.anany1750
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Lesson 1 - Introduction to Object Oriented Programming Concepts _ Introduction to Java

The document provides an introduction to Object Oriented Programming (OOP) concepts, covering procedural and object-oriented programming, and detailing the four principles of OOP: data abstraction, encapsulation, inheritance, and polymorphism. It also discusses Java as an object-oriented programming language, its history, types of Java programs, the compilation process, and key features such as platform independence and security. The document emphasizes the differences between procedural and object-oriented programming and explains how Java operates through a virtual machine.

Uploaded by

k.anany1750
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Introduction to Object

Oriented Programming
Concepts
Topics to be covered
a. Procedural Oriented
Programming
b. Object Oriented programming
c. Principles of Object Oriented
Programming ->
i) Data Abstraction
ii) Encapsulation
iii) Polymorphism
iv) Inheritance
Recapitulation
As, you have already learnt about Java
Programming Language in std VIII, could you
please think about the answers for the
following?
1.What is a program?
2.What is a programming language?
3. Name some Programming languages.
4. What is a source code?
5. What is an object code?
A computer program is commonly defined as a set of
instructions to be followed on the computer to perform a
particular task.

A programming language is a software where we write


computer programs. For Example : C, C++, VB, Ruby, Perl,
.Net, Java

The source code is the program written by the programmer


using programming language.

This source code is not understood by the computer. So, the


translator converts the source code into the object code. The
object code is also known as binary code. There are mainly
three types of translator -> Assembler, Compiler and
Interpreter.
Types of Programming
Language
1) Procedural Programming Language
2) Object Oriented Programming
Language
Procedural Oriented
Programming Language
Procedures are known as functions in a programming
language. The ‘function’ word means to do some work.
Here, we follow the instructions to perform some tasks.

For Example: The steps which we follow to do addition


of three numbers:

1. Take three numbers.


2. Find the sum of those three numbers.
3. Display the sum.

Here, we have followed the step by step instructions to


perform task.
Object Oriented
Programming Language
The programming language which works on the
basis of object.
Now, what is an object? An object is anything in the
world which has some characteristics and functions.
For Example: Table is an object which has
characteristics like height, thickness, material and
function like to keep the books.
In this language, instead of writing function, we
create objects and these objects perform task.
More examples of objects are: Bag, Laptop, Chair,
Car, Bird etc
Difference between Procedural Oriented
Programming Language and Object
Oriented Programming Language

Procedural Oriented Object Oriented


programming Programming
In this, the importance In this, the importance
is given to functions but is given to the objects
not to objects. rather than procedures
or functions because it
works as a real world.
Example of POP are : Example of OOP are :
C, VB, FORTRAN, C++, JAVA, VB.NET,
Pascal. C#.NET.
PRINCIPLES OF OBJECT
ORIENTED PROGRAMMING
There are four principles of OOP->
1) Data Abstraction
2) Encapsulation
3) Inheritance
4) Polymorphism
Data Abstraction
• Data Abstraction is the act of representing the
essential features without knowing the
background details. It is always relative to the
purpose or user.

• For Example: We use a switch board daily for


switching on or off the electrical devices. We
know how to use that whereas we don’t know
the background functionality of this.
Abstraction:
Real World Example(Switch board)
Encapsulation
Encapsulation is the wrapping (binding) of data
and functions into a single unit. Moreover, the
data is kept hidden which cannot be accessed
directly outside the class although it is available
in the program.
•For Example: Automatic vending machine
contains both data and operations and they are
wrapped/integrated all together under a single
unit Vending Machine. This is called
Encapsulation.
Encapsulation
Vending machine
Inheritance
Inheritance is a method to share common
properties of base class with the derived class.
This can be done by extending the object of
one class into another class and using through
it.
For Example: A child inherits the traits of
his/her parents. With inheritance, we can
reuse the fields and methods of the existing
class. Hence, inheritance facilitates
Reusability and is an important concept of
OOPs.
Inheritance
Polymorphism
Polymorphism is the process of defining a
function in multiple forms. Here,
Polymorphism comes from two words ->
‘Poly’ means many and ‘morphism’ means
changing from one form into another form.
For Example: draw() can be used to perform
three shapes: triangle, rectangle and circle.
Polymorphism Example
Chapter 1(b) –
Introduction to JAVA
Topics to be covered
1. History of Java
2. Types of Java programs
3. Compilation process
4. JVM(Java Virtual Machine)
5. Features of Java
Recapitulation
As, you have learnt about Object Oriented
Programming in your previous class, could you
please think about the answers for the
following?
1.What do you mean by Object Oriented
Programming?
2. Name four principles of Object Oriented
Programming.
3. Differentiate between Encapsulation and
Data Abstraction
History of Java
Java is an Object Oriented
programming language developed
by James Gosling and colleagues
at Sun Microsystems in the early
1990s.
Java was started as a project called
"Oak" by James Gosling in June
1991. Gosling's goals were to
implement a virtual machine and a
language that had a familiar C-like
notation but with greater uniformity
and simplicity than C/C++. The first
public implementation was Java 1.0
in 1995. It made the promise of
"Write Once, Run Anywhere", with
free runtimes on popular platforms.
Types of Java programs
There are two types of Java programs:
1) Stand Alone Application
2) Applet Programs
1) Stand Alone Application : These types of
programs are written to carry out specific tasks on
a stand alone local computer.

2) Applet programs : These types of programs


are used on multiple devices and they act as the
internet applications. The Java applet will be
placed on the web by embedding into a HTML file.
Compilation Process
Compilation Process in Java
Java is a platform independent programming
language. It doesn’t work on one-step-
compilation. Instead, it involves a two-step
execution, first through an OS independent
compiler; and second, in a virtual machine
(JVM) which is custom-built for every
operating system. There are two compilation.
These are :-
a) Compilation
b) Execution
a) Compilation
First, the source ‘.java’ file is passed through the
compiler, which then encodes the source code
into a machine independent encoding, known as
Byte code.

b) Execution
The class files generated by the compiler are
independent of the machine or the OS, which
allows them to be run on any system. To run, the
main class file (the class that contains the method
main) is passed to the JVM and it converts the
byte code into the object code which can be
understood by that operating system.
JVM
(Java Virtual Machine)

A JVM is a virtual
machine that enables a
computer to run Java
programs as well as
programs written in
other languages that are
also compiled to Java
byte code.
Features of Java
Object Platform
Oriented Independent
Programming

Secured
Simple to
learn

Multi-
threaded
Important features of
Java
1) Java is an Object-Oriented programming language:
Java is a fully object-oriented programming language. It has all OOP
features such as Abstraction, Encapsulation, Inheritance and
Polymorphism

2) Java is Simple:
The Java programming language is easy to learn. Java code is easy to
read and write.

3) Java is Secure:
The Java platform is designed with security features built into the
language and runtime system such as static type-checking at
compile time and runtime checking (security manager), which let
you creating applications that can’t be invaded from outside.
4) Java is Platform Independent:
Java code is compiled into intermediate format
which can be executed on any systems for which
Java virtual machine is ported. That means you
can write a Java program once and run it on
Windows, Mac, Linux or Solaris without re-
compiling.

5) Java is Multi-threaded:
The Java platform is designed with multithreading
capabilities built into the language. This means
that we can build applications with many
concurrent threads of activity.

You might also like