Total Pageviews

Thursday, 16 June 2011

An Overview OF Java.

 By the end of the 1980's ,object oriented programing using c++ took hold. Indeed, for brief moment it seemed as if programmers had finally found the perfect language.Because C++ blended the high efficiency and stylish elements of c with the object oriented paradigm, it was a language that could be used to create a wide range programs. However , just as in the past ,forces were brewing that would ,once again drive,once again drive computer language evolution forward. Within a few years, the World Wide Web and the Internet would reach critical mass. This event would precipitate another revolution in programming.


# How  JAVA  differs from C and C++.


                       Java is a lot like c but the major difference between java and c is that java is an object oriented language and has a mechanism to define a classes and objects.Java doesnot include some features that are available in c.

=> java does not include the c unique statement keywords sizeof, and typedef.
=> java does not contain the data types struct and union.
=> java does not define the type modifiers keywords auto,             externs,register,signed, and unsigned.
=> java does not support an explicit pointer type.
=> java does not have a preprocessor and therefore we cannot use #define, #include,       and #ifdef statement.
=> java requires that the functions with no arguments must be declared with empty paarenthesis and not with the void keywords done in c.

OBJECT ORIENTED PROGRAMMING PARADIGM 

The major motivating factor in the invention of object-oriented approach is to remove some of the flaws encountered in the procedural approach. OOP treats data as a critical element in program development and does not allow it to flow freely around the system.It ties data and more closely to the function that operate on it , and protect it from accidental modification from outside function. OOP allows decomposition of a program into many entities objects and there builds data and function around this objects. The data of an object can be accessed only by the functions associated with that object. However function of one object can use another the funtion of other objects.
                                   We define " object oriented programming as 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 " .

Some of the striking features of OOPs are : 
* Emphasis is given on data rather than procedure.
* Programs are divided into what are known as objects.
* Data structures are designed such that they characterize the objects.
* Data is hidden and cannot be accessed by external functions.
* Objects may communicate with each other through functions.
* New data and functions can be easily added whenever necessary.


BASIC CONCEPTS OF OBJECT-ORIENTED PROGRAMMING
some of the concepts used in oops are :
   1. Object
   2. Classes
   3. Data abstraction and encapsulation
   4. Inheritance
   5. Polymorphism
   6. Data binding
   7. Message passing

1. OBJECTS : 
 - Objects are the basic runtime entities in an object oriented system.
 - programming problem is analyzed in terms of objects and the nature of communication between them.
 - objects take up space in memory and have associated address like a structure in c.
 - objects can interact without having to know details of each other's data or code. It is sufficient to know the type of message accepted, and the type of reponse returned by the objects.

2. CLASSES : 
 - The entire set of data and code of an object can be made a user defined data type with the help a class.
 - objects are the variable of type class. Once a class has been defined we can create any number of objects belonging to that class.

Example :  we can say, the word " fruit" is a class , which is nothing but a blue print / template representing a group of objects like apple ,orange, banana etc having similar characteristics.







3. DATA ABSTRACTION AND ENCAPSULATION : 
- The wrapping up of data and function into a single unit (called class) is known as encapsulation.
 - These function provide the interface between the object's data and the program.This insulation of the data from direct access by the program is called data hiding /information hiding.
 - Abstraction refers to the act of representing essential features without including the background details or explanations.

Example : a company A and company B are engaged in transaction with each other but it is not necessary for the company B to know what is the salary of the manager of the company A is getting to run the transaction smoothly.
company B only requires the knowledge regarding the business transaction for further processing.


4. INHERITANCE : 
 - Inheritance is the process by which objects of one class acquire the properties of the objects of another class.
suppose we are having a class , and  due to some reasons we have to update the software as per our requirement.So to solve this problem , we have to make a derived class of the previous class which contains all the changes required.This new class will have the combined features of both the classes.
 NOTE : java dose not support multi-inheritance.






5. POLYMORPHISM : 
 - polymorphism , a greek term, means ability to take more than one form. Polymorphism plays an important role in allowing objects having different internal structures to share the same external interfaces . This means that a general class of operation may be accessed in the same manner even though specific actions associated with each operations may differ. Polymorphism is extensively used in implementing inheritance.


There are mainly two types of polymorpism :
*  compile time polymorphism - which is being implemented by the use of super keyword.
*  run time polymorphism - it is implemented by using the base class reference and passing the derived  class object reference to the base class reference. 



6. DYNAMIC BINDING :
 - Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic Binding(late binding) means that the code associated with a given procedure call is not known untill the time of call at run-time.It is associated with polymorphism and inheritance.

7. MESSAGE PASSING : 
 - An oop consist of a set of objects that communicate with each other. The pocess of programming in an object-oriented language, therefore , involves the folloeing basic steps :

1. Creating classes that define objects and their behaviour,
2. Creating objects from class defination, and
3. establishing communicating objects.

Objects communicate with one another by sending and receiving information much the same way as people pass message to one another. A message for an object is a request for execution of a procedure, and therefore will invoke a function in the receiving object that generates the desired results. Message passing involves specifying the name of the object , the name of the function and the information to be sent,


No comments:

Post a Comment