You are on page 1of 4

Introduction to Object Oriented programming concepts

Paradigm:-Paradigm means organizing principle of a program. It is an approach to programming


Two types of paradigm:- OOP(Object Oriented Programming) and POP(Procedural Oriented Programming)
Difference:-
POP(Procedural Oriented Programming) OOP(Object Oriented Programming)

Traditional approach Modern approach


Top to bottom approach Bottom to top approach
Concentrates on code(code-centered) Concentrates on data(Data centered)
Complex code maintenance Easy code maintenance

Limitations of Procedural programming approach:-


i)Emphasis on code or procedure rather than on data.
ii)Change in a data type being processed needs to be propagated to all the functions that use the same data
type. This is frustrating and time-consuming process.
iii)It does not model real world very well.
Object Oriented Programming:-
The object oriented programming approach views a problem in terms of objects involved rather than
procedure for doing it.
Two most important concepts associated with OOP:-Class and Object
Class:- A class is a blueprint representing a group of objects that share common properties and relationships.
Object:-An object is an identifiable entity with some characteristics and behavior. It represents an entity that
can store data and its associated functions.
Difference between class and object:-
class object
A class is a blueprint representing a group of An object is an identifiable entity with some characteristics
objects that share common properties and and behavior. It represents an entity that can store data and
relationships. its associated functions.

Logical entity Actual entity


Does not occupy memory space Occupies memory space
Basic concepts of OOP:-
Data abstraction:-Data abstraction refers to the act of representing essential features without including the
background details or explanations.
Data Hiding:-Is a related concept. When abstraction exposes the necessary or required details, it hides the rest
of the details, it is known as data hiding.
Principles of OOP:-
1.Encapsulation:- The wrapping up of data and operations/functions(that operate on the data ) into a single
unit called class is known as encapsulation.
Advantage:-Prevents accidental or intentional changes
2.Inheritance:- Inheritance is the capability of one class of things to inherit capabilities or properties from
another class.
A base class is a super class from which another class inherits properties. Inheriting class is called
subclass(derived class).
Advantage:-Promotes code reusability and reduces code redundancy(Rewriting code)
3.Polymorphism:- It is the ability for a message or data to be processed in more than one form. For eg:- ‘+’
with numbers gives sum, while with strings concatenates them.
Eg of class:- Bird is a class but parrot is an object.
Advantages of OOP:-
1.Re-use of code:- Encapsulation allows class definitions to be re-used in other applications. The availability of
a consistent interface to objects lessens code duplication and therby improves code reusability.
2. Ease of comprehension:- OOP codes are more near to real-world models than other programming
methodologies’ codes.
3.Ease of fabrication and maintenance:- The concepts such as encapsulation, data abstraction allow for very
clean designs. When an object is going into disallowed state, which are not permitted, only its methods need
to be investigated.
4.Easy redesign and extension:- The OOP concepts facilitate easy redesign and extension.
Disadvantages of OOP:-
1.OOP classes tend to be overly generalized.
2.The relations among classes become artificial at times.
3.The OOP programs’ design is tricky.
4.Also one needs to do proper planning and proper design for OOP programming.
5.To program with OOP, programmer need proper skills such as design skills, programming skills, thinking in
terms of objects etc..

Introduction To JAVA

Short note on JAVA:-JAVA is an Object Oriented Programming(OOP) language developed at Sun Micro Systems
by James Gosling and Team. It was initially called Oak. It was initially used to design electronic circuits but later
on applied to develop Web based application.

Features of JAVA :-

i)Object Oriented:-Programs in JAVA are executable through the objects, which interact with each other by
passing messages using different methods and thus make a program more dynamic

ii)Both Compiled and Interpreted:- JAVA uses both compiler and interpreter JAVA complier (Javac) converts
the source code to Byte code, which is platform independent (JVM-Java Virtual Machine) converts the Byte
code to Object Code(machine readable).

iii) Strongly Typed:- All the variables and methods must be defined with all legal data type before actually
using them. Eg a=5, will be wrong, int a=5 will be correct.

iv)Case sensitive:-Java understands uppercase and lowercase characters in different senses. Eg variables a and
A are treated separately; int a=5; String A=”School”;

v)Robust and secure:- JAVA’s inbuilt Exception Handling(error correction) mechanism makes the programs
platform independent . Byte code generated by the java compiler is converted into machine code by the JVM
depending on the operating system the program is run, thus making the program portable and platform
independent.

vi)Write Once Run Anywhere(WORA)- The java programs need to be written just once,which can be run on
different platforms without making changes iin the java program.

vii)Light weight code:- With java, no huge coding is required.

viii) Security:-Java offers many enhanced security features.

ix)Object oriented Language:-Java is object oriented language,thereby,very near to real world.

Types of java:-
Internet applets:- They are small programs that are embedded in web pages and are run on the viewer’s
machine in a secured manner. Applets are designed to be delivered to internet web browsers and that is why
an applet has a built-in graphical window. But java applets have some security restrictions.

Standalone applications:- It is generally a software application that does not require low level operating
system or hardware access. This includes must off the usual desktop applications such as word processors or
spreadsheets. Standalone java application of java begins executing with a main method.

Blue J a quick introduction:- Basically BlueJ is an IDE(Integrated Development environment)-

i) An editor-which you can use to write your program.


ii) A debugger-Which helps you find mistakes.
iii) A viewer:-Which lets you see parts of your program graphically.

Ordinary compilation process:- The process of converting a source code into machine code is called
compilation. The converted machine code depends a lot on the platform it is executing upon. That means for
different platforms different machine code is produced. The resultant machine code is called native executable
code.

Java compilation:-

i) Java programs are written in “.java” file(source code) and then compiled by java compiler.
ii) Byte code:- Byte code is the code generated after the java program is compiled.(.class file)
iii) Java virtual machine:- This is virtual machine which reads the byte code and interprets into
machine code depending upon the underlying operating system and hardware combination.
iv) Just in Time (JIT) compiler”- Just in time compiler is part of the Java Virtual Machine(JVM) and it
compiles byte code into executable code in real time, on a piece-by-piece, demand basis.

Difference:-

Ordinary compilation Java compilation


Ordinary compilation converts source code to Java compilation converts source code to byte
object code in one step code, and then byte code is converted to object
code by the JVM.
Done in one step by other HLL Done in two steps by JAVA
Creates native executable code Creates byte code
Not platform independent Platform independent

Elementary Concept of Objects and Classes


Class:- A class is a blueprint representing a group of objects that share common properties and relationships.
Object:-An object is an identifiable entity with some characteristics and behavior. It represents an entity that
can store data and its associated functions.
An object is an identifiable entity with some characteristics (or properties or attributes), a state and behavior.
The properties defining an object are also termed as attributes of object or characteristics of object.

Example:- Orange is an object


*It’s characteristics are: it is spherical shaped, it’s colour is orange etc..
* It’s behavior is: it is juicy and it tastes sweet-sour.
* It’s state is: it is half-eaten(a specific case)

The properties defining an object are also termed as attributes of object or characteristics of object.
How are objects implemented in software terms:-
An object is implemented in software terms as follows:-
i) Characteristics/attributes are implemented through member variables or data items of the object.
ii) Behaviour is implemented through member functions called methods.
iii) Data and methods are encapsulated into one unit and given a unique name to give it identity.

How do objects encapsulate state and behaviour:-


An object is an identifiable entity with some characteristics i.e., attributes and behavior. The state of an object
depends upon the values of it’s attributes at any given point of time. Since state and behavior of objects are
interwoven, they are said to encapsulate state and behavior. For instance, a car object has characteristics like
number of wheels,seats, make etc. It’s state is represented as halted, moving or stationary. And it’s behavior is
: it can move,stop,blow horn etc. Now all theses things are wrapped up together in the form of ‘car’. We
cannot segregate them. Thus, we can say that objects encapsulate their ‘state’ and ‘behaviour’ as their stae
and behavior are interlinked, they canot exist separately.

Why are objects instances of a class:-


From a class, multiple objects can be created, which are known as instances of the class.

Message passing between objects:-


In simple terms, is a value that is passed to a function to get a task performed by it. Technically, message
passing makes the objects dynamic by allowing the objects to interact with each other by passing the requests
and providing the replies.

Object factory:-
An object factory is a producer of objects. It accepts some information about how to create an object, such as
values depicting its state, and then returns an instance of that object. Valid representation and the nature of
the information that are determined by the object factory and are closely tied to the abstraction represented
by the class as object factory.

How is class an object factory:-


Basically the class is an object maker or object factory. It contains all the statements needed to create an
object, its attributes, as well as the statements to describe the operations that the object will be able to
perform. Based on the specifications of the class. Hence, we can say that a class is an object factory.

You might also like