Introduction to OOP and Java
Introduction to OOP and Java
2. Software: is a set of programs that are used to activate and supervise the working of various
hardware devices and also to get various tasks done for us.
3. Programming Languages: These are computer languages which are used to develop different
applications to get the work done from a computer.
4. Types of Programming Languages : The programming Languages can be broadly classified as (a) Low
Level Languages (b) High Level Languages
5. Low Level Languages : These are machine-oriented and require extensive knowledge of computer
circuitry. These were the first generation computer languages and are further divided as:
(i) Machine Language : Machine language is the one in which instructions are written using
Binary Digits (Bits - 0’s and 1’s) . The code thus written is known as Source Code and is directly
understood and executed by a computer.
(ii) Assembly Language: This is development over Machine Language in which instructions are
given using special words (known as Mnemonics). These words are to be converted to
machine code using a translator known as Assembler.
6. High Level Languages : These are user-friendly programming languages in which instructions are
written using simple English-like statements. However , we need to use special translators like
Compiler / Interpreter to convert them to machine readable form.
ii) Second Generation Programming Language (2GL) : is a term that refers to some form of
assembly language. It requires use of an assembler to convert the Mnemonics to Machine
Code(Object Code)
v) Fifth Generation Programming Language (5 GL) : is based around solving problems using
constraints entered by the programmer, which the computer uses to solve the given problem.
These are mostly used in Artificial Intelligence research. Eg: Prolog, Mercury
8. Programming Paradigm : It is an approach to programming. It refers to organising principle of a
program. Some of the paradigms available are – Procedural programming, Modular programming,
structural programming, Object oriented programming
10. Modular Programming : is a program that consists of a number of modules that work independently
of all others. Each module can work with its own data as well with data passes to it.
11. Object Oriented Programming (OOP) : In this approach, a program is viewed as a collection of object
with variables and related methods: The concentration is on DATA i.e. what to do rather than how to
do. Code maintenance is simple due to the modularity feature. Eg: C++, Java, Small Talk, Simula, Eiffel
etc..
12. Concepts of OOP : Class – Object – Abstraction- Message Passing- Data hiding
a) Class : is a prototype or blueprint that defines objects of a particular type with similar state and
behavior. It is a logical construct and doesn't occupy any memory. It is termed as an Object
factory as it is used to create objects. It is considered user efined/derived/reference/composite
data type as it is created out of objects with different types of variables and related methods.
b) Object : is a physical entity with its own state and behavior. An object requires memory for
storage. The state is implemented through the variables and behavior is implemented through
methods. All objects of a particular class will exhibit similar traits.. As all the objects of a given
class share the similar characteristics, object is called as an instance of class.
d) Message passing : Objects communicate with each other by passing a request and providing a
reply thus making the java programs dynamic. The communication happens using
Parameters/Arguments.
e) Modularity : the process of dividing the entire code into smaller and controllable blocks. It is a
block of instructions that can be independently maintained for other objects.
f) Information hiding : It is one of the advantages provided by Encapsulation. It protects data from
unnecessary changes and damages.
a) Encapsulation The wrapping up of data and functions/code into a single unit called class. It is a
way to implement Data Abstraction. It acts as a protective layer from DATA being mishandled and
helps in DATA HIDING.
b) Inheritance the property by which an object of a class derives the properties of another class
while retaining its own features is known an Inheritance. It helps in code reusability and reducing
the code redundancy as well as complexity.
a) Advantages : (i) Existing Code can be reused an d(ii) Easy redesign and extension
b) LImitatations : (i) Proper planning is needed for design and (ii) classes tend to be generalised.
POP OOP
1. Focus is on CODE i.e. how to do 1. Focus is on DATA i.e. what to do
2. Program is viewed as a series of 2. Program is viewed as a set of
instructions instructions
Eg: Pascal, C Eg: C++, Java
Class Object
1. Is a logical construct and 1. Is a physical entity that occupies
doesn’t occupy any memory memory
2. Is a collection of objects and is 2. Is an instance of class as it is created
known as Object factory out of a class