Sunday, 29 January 2017

Introduction History of Java

History of Java
Java is the higher level computer programming language developed by Sun Microsystems in 1991. It is a general purpose object oriented language initially called “Oak” by James Gosling one of the team members of inventors of the language and later in 2005 it was renamed as “Java”. Java was designed to develop software for home appliances like TVs, VCRs, Toasters and other consumer electronic devices.
1996: Java Development Kit 1.0 (JDK 1.0) was released by Sun Microsystems. With JDK 1.0 Java was established as internet programming language as well as general purpose objects oriented programming language.
1997: Java Development Kit 1.1 (JDK 1.1) was released by Sun Microsystems.
1998: Java 2 and Software Development Kit 1.2 (SDK 1.2) was released by Sun Microsystems.
1999: Java 2 Standard Edition (J2SE) and Java 2 Enterprise Edition (J2EE) ) was released by Sun Microsystems.
2000: J2SE with SDK 1.3 was released.
2002: J2SE with SDK 1.4 was released.
2004: J2SE with JDK 5.0 (Instead of JDK 1.5) was released with name J2SE5.0.
2006: JDK 6 was released.
Features of Java
Compiled and Interpreted: Generally computer programming languages uses either compiler or interpreter to convert higher level program source code in to machine language. But java uses both, in first step java compiler converts source code into bytecode which is not executable. In second step java interpreter generates machine code which is directly executable.
Portable: Java is platform independent language; it supports various platforms like Windows, Macintosh and various flavors of Linux and UNIX. Upgrade in Hardware or operating system will not require any change or modification in java program. Java ensures portability in two ways; first bytecode generated by java complier can be implemented on nay machine. Second the size of java primitive data types are machine independent.
Object Oriented: Object oriented design is a programming technique that focus on the data (objects) and interfaces to that data (object). Almost everything in java is an object. In java all data, program code resides in the classes and objects. Java comes with set of classes arranged in packages. We can use these classes in our programs by inheritance.
Robust: Java is a robust language; the java programs are reliable in many ways. It has strict compile time and run time checking for data types and errors in the program. It can relieve all memory management related problems very well. Java also incorporates the concept of exceptional handling which captures the errors and eliminates the risk of crashing the software.
Secure: Security is very important for the language which is used to develop programs for network or distributed environment like internet. Java enables development of virus free and tamper free software. Java system also verifies memory access and ensures virus free communication. Java doesn’t support pointers which ensure that programs can’t access memory locations without proper authorization.  
Distributed: Java is designed as distributed language to support development of application on internet. Java has ability to share both program and data. Java applications can access remote objects using internet just like they can access on local machine. This allows many programmers to work on many projects on remote locations and work together on a single project.
Simple: Java is a cleaned up version of C++ which can be programmed easily without any special training. Many features of C++ which are redundant or source of unreliable code are not available in java. For example java does not support pointers, preprocessors header files, structures, unions, operator overloading, multiple inheritance and many others. Java is designed similar to the C and C++ which makes it familiar to the existing C and C++ programmers. Java uses many constructs of C and C++ therefore Java code looks like C++ code.
Multithreaded: Multithreaded means handling multiple tasks simultaneously. Java supports multithreading. This means the execution of a new task of an application need not to wait to finishing of already executing task. A new task of an application can be started even if many other tasks of that application are already running. For example we can listen music while writing something in word document and downloading something from a web site.
High Performance: Performance of java is impressive due to the intermediate bytecode. The performance of java is high as compared to the performance of C or C++. Byte code can be converted on the fly (at runtime) into machine code for the particular CPU on which program is running. Java architecture is also designed to reduce overhead at runtime. Multithreading feature of java also enhances the overall execution speed of the java application.
Dynamic and Extensible: Java is more dynamic as compared to C or C++ in many ways. Java is capable of dynamically linking in new class libraries, methods and objects. Libraries can freely add new methods and instance variables without affecting their clients. This is an important feature of java in the situation in which code needs to be added in the running program.
A Java program supports the functions written in other languages like C o C++. These functions are known as native methods. This feature of java allows programmers to use efficient functions available in other languages like C and C++.
Ease of Development: Java 2 Standard Edition (J2SE) 5.0 supports various features like Generics, Enhanced for loop, Autoboxing or unboxing, Typesafe enums, Varargs, Static import and Annotations. This feature reduces the work of the programmer by shifting the responsibility of creating reusable code to the java compiler.  The code created by compiler is almost bugs free because compiler makes fewer mistakes as compared to the programmer.
Scalability and Performance: J2SE 5.0 assures the significant increase in scalability and performance of the java program. It improved the startup time and reduced the amount of memory used in Java 2 runtime environment. For example data sharing in the Hotspot Java Virtual Machine (JVM) improves the startup time by loading the core classes from the jar file into the shared archive. Memory utilization is reduced by sharing data in the shared archive among multiple JVM processes.
Monitoring and Manageability: Java supports various monitoring and manageable APIs such as JVM Monitoring and Management API to track the information at application level and JVM level when deploying a large application, Sun Management Platform Extension, Logging, Monitoring and Management Interfaces, and Java Management Extension (JMX) to Monitor and manage java applications. Java provides tools such as Jconsole is used to monitor JVM, Jps, Jstat and Jstatd to make use of monitoring and management facilities.   
Desktop Client: J2SE 5.0 Provides enhanced features to meet the challenges and requirement of the java desktop users. This feature is mainly used for development of graphical applications that requires OpenGL hardware acceleration.
Miscellaneous Features
Core XML Support: J2SE 5.0 provides various powerful XML support features to the java platform. Java has some special packages for interface, to instantiate Simple API for XML (SAX) and Document Object Model (DOM) parsers to parse XML document. Transform the content of an XML document, and validate the XML document against the schema.     
Supplementary Character Support: Java adds 32 bit supplementary character support as a part of Unicode 4.0 support. The supplementary character are encoded with UTF-16 values to generate a different character called surrogate codepoint.
JDBC RowSet: Java supports JDBC RowSet to send data in tabular form between the remote components of distributed enterprise application. RowSet contains CachedRowSet object which is a JavaBean component and acts like a container. This object contains the number of rows of the data which are retrieved from the database. The data stored in CachedRowSet can be directly accessed from it without connecting to the database. JDBC RowSet also contains WebRowSet objects which can operate without connecting to the data base or any other data source. WebRowSet uses XML format to read and write the RowSet.    

Fundamentals of Object Oriented Programming in Java
The main objective of object oriented approach is to eliminate some weaknesses present in the procedural approach. Data is considered as critical part of the program in OOP. Data is closely tied with methods which operate on that data, that way data is protected from unintentional modification by other functions. Means data can be modified only using the methods associated with the data. The combination of data and methods which operates on the data makes an object.
Data
Methods
           


                       
Object = Data + Methods
Data in object oriented programming is hidden and can’t be accessed by external functions. Objects can communicate with each other using methods only.               
Objects and Classes
Objects are the most important part of object oriented programming. We can see many examples of real world objects around us: our dogs, our car, our television etc.
Basically there are two characteristics of real world objects: State and Behavior. Car has state (brand, color, current speed) and behavior (changing gear, applying breaks). The characteristics of software objects are also similar to real world objects.
A class can be considered as a blueprint or template of an object. Object is an instance of the class. We can create many objects (instances) of a class. Example of a Class
___________________________________________________________________________
public class Car {
     String brand;
     String color;
     int current_speed;
    
     void changing_gear(){
     }
     void applying_breaks(){
     }
}
___________________________________________________________________________________
In this example Car is a class which has data or stat (String brand; String color; int current_speed) and methods or behavior (void changing_gear() and void applying_breaks()).
Class Car is a type; we can now take object of this class just like we take variables of type int or string. Example of object of class Car
              Car myCar = new Car();
           Car yourCar = new Car();
               
Here myCar and yourCar are the objects (instances) of class type Car.

Encapsulation and Data Abstraction
Encapsulation is one of the three fundamental principles of OOP. Other two are inheritance and polymorphism.
As we have seen above data and methods are wrapped together in a single unit (class) is known as encapsulation. The data encapsulated in a class is not accessible to outside functions. The methods which are wrapped in the same class can only access the data of that class. The methods of a class provide interface between data of the object and program. The data of a class is invisible to the outside world so it is also called as data hiding.
Abstraction means representing essential features of an object without including the background details of the object. Class uses the concept of abstraction and includes the list of abstract attribute such as brand, color, name etc and methods operates on these abstracts.
Inheritance
Inheritance is the process in which an object of a class adopts properties of object of another class. It supports the concept of hierarchical classifications. For example sports car, sedan, suv all shares the characteristics of Car (brand, color, current speed). Each type is a car but they have additional feature also like sports car has only two seats, sedan has special design and 5 seats etc.
OOP allow classes to inherit commonly used properties (state and behavior) from another class. In this example Car has become sports car, sedan and suv. In java each class can have direct one superclass. Each super class can support unlimited number of subclasses.
           


 










Inheritance provides the concept of reusability. It means we can add new features to a class without modifying or changing existing features. A new class can be added from the existing class as shown in above figure new class sedan is derived from existing class Car. The new class sedan has combined feature of both the classes Car and Sedan.  More on inheritance…
Polymorphism  
Polymorphism is the ability of OOP to take more than one form. Polymorphism is the capability of the method of a class to do different things based on the object on which it is acting. Polymorphism allows us to define one method and have various implementations of the method. For example: a method addition as shown in diagram below. For two integer values passes as parameters, the method Addition will return sum (Addition) of two values and for string values passed as parameters, the method Addition will return concatenation of two strings. It means there are two methods of same name Addition, having different type of parameters and return values. It is just like a word having different meaning depending of context.  
 


int Addition (int a, int b)
String Addition (String x, String y)

 
                                   





More on polymorphism…

No comments: