0% found this document useful (0 votes)
21 views27 pages

General OOP Concepts

Uploaded by

ayushchamoli6397
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views27 pages

General OOP Concepts

Uploaded by

ayushchamoli6397
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

General OOP

Concepts
TYPES OF PROGRAMMING LANGUAGES, PROGRAMMING PARADIGMS,
BASIC CONCEPTS OF OOP
Types of Programming languages

 Low Level Languages


 Machine Language
 Machine oriented
 Require extensive knowledge of computer circuitry
 Instructions are written in binary code (using 1 and 0)
 Assembly Language
 Instructions are written using symbolic names for machine operations and
operands
 It makes programming less tedious than machine language programming
 Assembly program is then convert into machine language using assembler
software.
Types of Programming languages

 High Level Languages


 It offer English like keywords, constructs for sequence, selection
(decision) and iteration (looping) and use of variables and constants.
 It is very easy to program with such languages compared to low level
languages.
 A program written in HLLs are converted into machine language using
compiler or interpreter.
Types of Programming languages

 A programming language should serve two related purposes:


 It should provide a vehicle for the programmer to specify actions to be
executed and
 It should provide a set of concepts for the programmer to use when
thinking about what can be done.
 Both Aspect:
 First requires a language that is “close to the machine”
 Second requires a language that is “close to the problem to be solved”
Types of Programming languages

 The low level languages serve only the first aspect i.e., they are
close to the machine.
 The high level languages serve only the second aspect i.e., they are
close to the programmer.
 However, the languages ‘C’ and ‘C++’ serve both the aspects,
hence can be called as ‘middle level languages’.
Programming Paradigms

 By Paradigm, one means a way of thinking or doing things.


 Paradigm means organizing principle of a program. It is an
approach to programming.
 Different Programming Paradigms are following:
 Procedural Programming
 Modular Programming
 Object Oriented Programming
Procedural Programming

 A program in a procedural language is a list of instructions where


each statement tell the computer to do something.
 The focus is on the processing, the algorithm needed to perform the
desired computation.
 This paradigm is: “Decide which procedures you want ; use the best
algorithms you can find”.
Modular Programming

 With the increase in program size, a single list of instructions


becomes unwieldy. Thus a large program is broken down into
smaller units i.e., functions (sub-programs).
 The idea of breaking a program into functions can further extended
by grouping a number of functions together into a larger entity
called a module.
 This programming paradigm, also known as ‘data-hiding principle’
states: “Decide which modules you want ; partition the program so
that data is hidden in modules.”
Object Oriented Programming

 All available programming languages are divided into three types


based on the features they are supporting.
 Monolithic
 Structured or Procedural
 Object Oriented programming language
Object Oriented Programming
Monolithic Structured Object Oriented
Programming Programming Programming
Features languages languages (C) languages
(Machine and (JAVA)
Assembly)
Modularity No Yes Yes

Security No No Yes

Platform No No Yes
Independent
Object Oriented No No Yes

Integration with No No Yes


other languages
Object Oriented Programming
System
 Why OOPS?
 OOPS stands for “Object Oriented Programming System”.
 It is a technique, not technology.
 It means, It does not provide any syntaxes or API, instead it
provides suggestions to design and develop objects in
programming languages.
 This technique is introduced to represent real world object in
programming languages, the objects such as Person, Animal,
Shape, Vehicle etc and further to achieve security and to
communicate with other programming languages.
Object Oriented Programming
System
 OOP is an approach that provides a way of modularizing a program
by creating partitioned memory area for both data and methods
that can be used as template for creating copies of such modules
(objects) on demand.
 In the OOP programming model, programs are organized around
objects and data rather than actions and logic.
 Building blocks of OOP: The building blocks of OOP are –
 Class
 Object
 Every Java program must start with a class, because using class only we
can represent real-world objects like Person, Bike, Animal etc.
Class and Object

 Definition of Class:
 A class is a group of objects that share common properties and
relationships.
 A class is a specification or blue print or template of an object
that defines what goes to make up a particular sort of object.
 Thus a class is a logical construct, an object has physical reality.
Class and Object
 Definition of Object:
 Object is an identifiable entity with some characteristics and
behavior.
 Object is the physical reality of a class.
 Technically object can be defined as “It is an encapsulated form
of all non-static variables and non-static methods of a particular
class”.
 An instance of a class is the other technical term of an object.
 The process of creating objects out of a class is called
instantiation.
 Two objects can be communicated by passing messages
(arguments).
Class and Object

 How can we create object in Java?


Ans. Object can be created - means non-static variables memory
location - by using new keyword and constructor of that class.
Syntax:-
<Access Specifier> <modifier> <class name> <variable name> = new
<class name> ();
 We can define object oriented programming paradigm as :
“Decide which classes and objects are needed; provide a full set of
operations for each class.”
Basic Concepts of OOPS or OOPS
Principles
 Definition of OOPS Principles-
 OOPS Principles are design pattern those suggest how we should
develop program to organize and reuse it from another
programs effectively with high scalability.
 Different Concept of OOPS-
 Encapsulation
 Inheritance
 Polymorphism
 Abstraction
Basic Concepts of OOPS or OOPS
Principles
 Encapsulation: The process of hiding internal data from the outside
world and accessing it only through publicly exposed methods
known as data encapsulation.
Example: We deposited money in bank to protect it and withdrawing it
later with proper authentication.
 How can we develop encapsulation in JAVA?
Ans. “Hiding class data from the outside world; and accessing it only
through publicly exposed methods”.
It means restricting direct access of class variables to outside class
members and providing accessibility those variables through public
methods.
Basic Concepts of OOPS or OOPS
Principles
 In Java, encapsulation can be implemented
 By declaring variables as private, to restrict direct access, and
 By defining one pair of public setter and getter methods to give access
private variables.
Basic Concepts of OOPS or OOPS
Principles
 Inheritance:
 As the name suggests, inheritance means to take something that
is already made.
 It is one of the most important features of Object Oriented
Programming.
 It is the concept that is used for reusability purpose.
 Inheritance is the mechanism through which we can derive
classes from other classes.
 Inheritance is the process of reusing class members from another
class as if they were defined in that class. Through inheritance we
can obtain one object property to another object.
 Example: Reusing father’s money in our own business to get more
money or just spending it for enjoyment as if it was earned by us.
Basic Concepts of OOPS or OOPS
Principles
 How inheritance can be implemented in JAVA using below two
keywords:
 extends
 implements
 ‘extends’ is used for developing inheritance between two classes or
two interfaces, and
 ‘implements’ keyword is used to developed inheritance between
interface, class.
 Syntax:
 class Example()
 class Sample extends Example()
Basic Concepts of OOPS or OOPS
Principles
 The class followed by extends keyword is called super class, here
Example is super class, and the class that follows extends keyword is
called sub class, here Sample is sub class.
 Super class is also called as Parent/Base class.
 Sub class is also called as Child/Derived class.
Basic Concepts of OOPS or OOPS
Principles
 Polymorphism:
 Having multiple forms is called polymorphism. The meaning of the word
polymorphism is something like one name, many forms.
 Polymorphism is a key to the power of object oriented programming. It is so
important that languages that don’t support polymorphism cannot
advertise themselves as OO languages.
 Languages that support classes but not polymorphism are called object-
based languages. Ada is such a language.
 Polymorphism is the concept that supports the capability of an object of a
class to behave differently in response to a message or action.
 Polymorphism is a property by which the same message can be sent to
objects of several different classes, and each object can respond in a
different way depending on its class.
 Polymorphism is the ability of a programming language to process object
differently depending on their data type or class.
Basic Concepts of OOPS or OOPS
Principles
 We can develop polymorphism using below concepts:
 Method Overriding
 Method Overloading
 Types of polymorphisms
 Compile-time polymorphism (Method Overloading)
 Runtime polymorphism (Method Overriding and Upcasting)
Basic Concepts of OOPS or OOPS
Principles
 Abstraction:
 Abstraction refers to the act of representing essential features without
including the background details or explanations.
 Abstraction is a process of developing a class by hiding or removing non-
essential details relevant to user. Here non essential details mean method
body and logic.
 It means abstraction principle telling us provide only method prototypes and
hide method implementation details.
 Abstraction has two forms:
 Hiding non-essential details and
 Removing non-essential details
 Hiding non-essential details can be developed using concrete methods.
 Removing non-essential details can be developed using abstract
methods
Basic Concepts of OOPS or OOPS
Principles
 Basically Abstraction provides a contract between a service
provider and its clients.
 Have you ever think of the logic of System.out.println() method?
Basic Concepts of OOPS or OOPS
Principles
 Modularity:
 The act of partitioning a program into individual components is called
modularity.
 The justification for partitioning a program is that:
 It reduces its complexity to some degree and
 It creates a number of well defined, documented boundaries within the
program.
 Modularity is a property of a system that has been decomposed into a
set of cohesive and loosely coupled modules.
 A module is a separate unit in itself. It can be compiled separately
though it has connection with other modules.
 Modules work hand in hand in order to achieve the program’s goal.
Basic Concepts of OOPS or OOPS
Principles
 What is meant by loose coupling and tight coupling?
Ans. If a product is functioning correctly even after changing one of its
parts with another company given part, it is called loosely coupled
way of manufacturing and vice versa.
 Coupling describes the relationship between modules and cohesion
describes the relationship within them.

You might also like