JAVA NOTES
OOPs BASICS:
Object Oriented Programming (OOP) is an approach to program organization and development, which attempts to eliminate some of the pitfalls of conventional programming methods by incorporating the best of structured programming features with several new concepts. However not all languages are suitable to implement the OOP concept easily. Languages that support OOP features include Smalltalk, C++, Ada and object pascal.
Object Oriented Paradigm:
The data of an object can be accessed only by the methods of
associated with that objects. However methods of one object can access the
methods of other objects. Some of the features of object-oriented paradigm are:
1. Emphasis
is on data rather than procedure.
2. Programs
are divided into objects.
3. Data
structures are designed such that they characterize objects.
4. Methods
that operate on the data of an object are tied together in the data structure.
5. Data
is hidden and cannot be accessed by external functions.
6. Objects
may communicate with each other through methods.
7. New
data and methods can be easily added whenever necessary.
8. Follow
bottom-up approach in program design.
OOPS CONCEPTS:
Object Oriented Program is an approach that provides a way
of modularizing programs by creating partitioned memory area for both data and
functions that can be used as templates for creating copies of such modules on
demand.
Objects and Classes
- Object is an instance of a class, that physically exist.
Objects are the basic runtime entities in an object oriented system. Each object contains data and code to manipulate that data
class: Class is a grouping of Objects having identical properties, common behavior and shared relationship.
example:
Flower, is class,
Rose, lily, Jasmin etc., are called objects of Flower class.
Encapsulation:
The wrapping up of data and methods into a single unit called class is known as Encapsulation. The data is not accessible to the outside the wrapper and only those methods which are wrapped in the class can access it. These methods provide the interface between the object’s data and the program. This insulation of the data from the direct access by the program is called data hiding.
Abstraction
Abstraction refers to the act of representing essential
features without including the background details and explanations. Classes use
the concept of abstraction and are defined as a list of abstract attributes
such as size, weight and cost, and methods that operate on these attributes.
Inheritance
Inheritance is the process by which object of one class
acquired the properties of objects of another class. The concept of inheritance
provides the idea of reusability. This means that we can add additional
features to an existing class without modifying it. This is possible by
deriving a new class from an existing one. A new class will have the combined
features of both the classes. The derived class is known as subclass.
Polymorphism
Polymorphism is a feature that allows one interface to be
used for a general class of actions. The specific action is determined by exact
nature of the situation. Polymorphism places an important role in allowing
objects having different internal structures to share the same external
interface.
Dynamic Binding
Binding refers to the linking of a procedure call to the
code to be executed in response to the call. Dynamic binding means that the
code associated with a given procedure call is not known until the time of the
call at runtime. It is associated with polymorphism and inheritance. A
procedure call associated with a polymorphism reference depends on the dynamic
type of that reference.
Comments
Post a Comment