Subject Name: Skill Based Lab OOPM
Unit No:1
Unit Name: Introduction to C++ and Java
Faculty Name : Mr.Gajendrasingh Rajput
Index
Lecture 1 – Basic Concepts of Object-Oriented Programming, Need of OOP, Object Oriented
6
Programming Paradigm
Lecture 2 – Benefits of OOP, Introduction to OOP languages : C++ and Java 30
2
Course Schema
Teaching Scheme
Evaluation Scheme
3
Course Objectives
1. To understand the object-oriented programming basics and its
features.
2. Able to use a programming language to resolve problems.
3. To understand and apply Object Oriented Programming (OOP)
principles using Java.
4. To study various java programming concept like multithreading,
exception handling, packages etc.
5. To explain components of GUI based programming.
2
Course Outcomes
Students will be able to :
1. Understand basics of OOP and apply fundamental programming
constructs.
2. Understand and illustrate the features of classes and objects.
3. Elaborate the concept of strings, arrays and vectors.
4. Develop a program that implements the concept of inheritance,
interfaces and packages.
5. Implement the notion of exception handling and multithreading.
6. Develop GUI based application.
5
Module No 1: Introduction to C++ and Java
Lecture No: 1
Basic Concepts of Object-Oriented
Programming, Need of OOP, Object Oriented
Programming Paradigm
Introduction to Programming
▪ Program:
▪ Program (also software or application) is a sequence of
instructions written to perform a specified task with a computer.
▪ Programmer:
▪ A person who practices this skill of writing program is referred to
as a computer programmer or software developer or coder.
▪ Programming:
▪ Programming is the iterative process of writing or editing source
code. Editing source code involves testing, analyzing, refining and
sometimes coordinating with other programmers on a jointly
developed program.
7 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Hierarchy of Programming Languages
8 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Why to Learn High Level Languages
9 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Programming Approaches
▪ Procedure-Orineted: Top-Down Approach
▪ Object-Oriented: Bottom-Up Approach
Programming
Approaches
Procedure-Oriented/
Object-Oriented
Structured
Figure: Programming Approaches
10 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Procedural Programming
▪ Traditional programming languages were
procedural.
▪ E.g. C, Pascal, BASIC, Ada and
COBOL
▪ Programming in procedural languages
involves choosing data structures
(appropriate ways to store data),
designing algorithms, and translating
algorithm into code.
▪ In procedural programming, data and
operations on the data are separated.
▪ This methodology requires sending data Figure: Procedural Programming
to procedure/functions.
11 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Structure of Procedure-oriented Programming
12 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Structured Programming Approach
▪ The program is made as a single structure i.e. the code will execute
the instruction by instruction one after the other.
▪ It doesn’t support the possibility of jumping from one instruction to
some other with the help of any statement like GOTO, etc.
Therefore, the instructions in this approach will be executed in a
serial and structured manner.
▪ C is called a structured programming language because to solve a
large problem, C programming language divides the problem into
smaller structural blocks each of which handles a particular
responsibility.
▪ These structural blocks are –
• Decision making blocks like if-else-elseif, switch-cases,
• Repetitive blocks like For-loop, While-loop, Do-while loop etc
• Subroutines/Procedures - functions
13 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Advantages of Structured Programming
▪ C structured programming is simple and easy to understand and
implement.
▪ It is well sited for small size implementation. However this is not
restricted. A good design can extend it to large size implementation.
▪ Programmers do not require to know complex design concepts to
start a new program.
▪ Easier to Debug
▪ These are mainly problem oriented rather than machine based.
▪ Program written in a higher level language can be translated into
many machine languages and therefore can run on any computer
for which there exists an appropriate translator.
▪ It is independent of machine on which it is used i.e. programs
developed in high level languages can be run on any computer.
14 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Disadvantages of Structured Programming
▪ A high level language has to be translated into the machine language
by translator and thus a price in computer time is paid.
▪ Since it is Machine-Independent, So it takes time to convert into
machine code.
▪ The code generated by a translator might be inefficient compared to
an equivalent assembly language program.
▪ Data type are proceeds in many functions in a structured program.
When changes occur in those data types, the corresponding change
must be made to every location that acts on those data types within
the program. This is really a very time consuming task if the program
is very large.
▪ Data and methods are not bind together in a module.
15 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Object Oriented Approach
• Object oriented approach organizes a
program in the form of objects
• Focus on data
• Program is organized around data
• Data and operations are grouped
together
Objects = Data+ Methods
16 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Object-Oriented Programming
• Object-oriented programming is centered on creating objects rather
than procedures/ functions.
• Objects are a melding of data and procedures that manipulate
that data.
Figure: Object-Oriented Programming
17 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Procedural vs Object oriented programming
▪ Procedural ▪ Object Oriented
Withdraw, deposit, transfer Customer, money, account
18 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Difference between Structured and Object Oriented
Approach
E.g: C, VB, FORTRAN, Pascal E.g: C++, JAVA, VB.NET, C#.NET
19 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Object Oriented Paradigm
20 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Basic Concepts of OOP
▪ Classes
▪ Objects
▪ Abstraction
▪ Encapsulation
▪ Inheritance
▪ Polymorphism
▪ Dynamic Binding
▪ Message Passing
21 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Classes and Objects
➢ Classes
• Basic building blocks OOP and a single
entity which has data and operations on
data together.
• Classes are user-defined data types and
behave like the built-in types of a
programming language.
➢ Objects
• Objects are the basic run-time entities.
• The instances of a class which are
used in real functionality(properties and
methods)
• When a program is executed the
objects interact by sending messages
to one another.
22 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Abstraction
• Abstraction refers to the act of
representing essential features without
including the background details or
explanations.
• Specifying what to do but not how to do.
• It is a flexible feature for having a overall
view of an object’s functionality.
• Classes use the concept of abstraction
and are defined as a list of abstract
attributes such as size, weight and cost,
and functions to operate on these
functions.
• Since the classes use the concept of data
abstraction, they are known as Abstract
Data Types.
23 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Encapsulation
• The wrapping up of data and functions into a single unit is known as
Encapsulation.
• The data is not accessible to the outside world and only those
functions which are wrapped in the class can access it.
• This insulation of the data from direct access by the program is
called data hiding or information hiding.
24 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Inheritance
• Inheritance is the process by
which objects of one class
acquire the properties of objects
of another class.
• The principle behind this sort of
division is that each derived class
shares common characteristics
with the class from which it is
derived.
• In OOP the concept of inheritance
provides the idea of reusability.
• This means that we can add
additional features to an existing
class without modifying it.
25 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Polymorphism
• Polymorphism means the ability to
take more than one form.
• Multiple definitions for a single name.
• Functions with same name with
different functionality
• That is an operation may exhibit
different behaviours in different
instances.
• saves time in investing many function
names
• The behaviour depends upon the
types of data used in the operation.
• Operator and Function overloading
• Example: Operation of addition.
26 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Dynamic Binding
• Dynamic binding refers to the linking of a procedure call to a
specific sequence of code.
• The code to be executed for a specific procedure call is not known
until run-time.
• Dynamic dispatch is generally used when multiple classes contain
different implementations of the same method.
• It provides a mechanism for selecting the function to be executed
from various function alternatives at the run-time.
• It is associated with polymorphism and inheritance.
27 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Message Communication
• Object communicate with one
another by sending and receiving
information much the same way as
people pass message to one
another.
• Objects communicates through
invoking methods and sending
data to them.
• This feature of sending and
receiving information among
objects through function
parameters is known as Message
Passing.
28 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Benefits of OOP
29 Lecture No:1 Basic Concepts of Object-Oriented Programming, Need of OOP,
Object Oriented Programming Paradigm
Module No 1: Introduction to C++ and Java
Lecture No: 2
Benefits of OOP, Introduction to OOP
languages : C++ and Java
C++ as Object Oriented Programming
• Developed by Bjarne Stroustrup in
1979.
• an extension / superset of C Classes
language.
Objects
• Supports both procedural and
object oriented paradigm Inheritance
• The prime purpose of C++
programming was to add object Data Encapsulation
orientation to the C programming
language. Data Abstraction
• While designing C++ modules, we
try to see whole world in the form of Polymorphism
objects.
31 Lecture No:2 Benefits of OOP, Introduction to OOP languages : C++ and Java
Difference Between C and C++
32 Lecture No:2 Benefits of OOP, Introduction to OOP languages : C++ and Java
Thank You