In this tutorial you will learn about the Java Introduction and its application with practical example.
What is Java? – Introduction
Java is simply a general purpose, high performance object oriented programming language developed by Sun Microsystems in 1991 by James Gosling.The first publicly available version of Java (Java 1.0) was released in 1995. Java is originally designed for the development of applications that can be embedded into everyday household consumer electronic appliances like TVs, Washing Machines, Mobile Phones etc. The most striking feature of java is that it is a platform neutral language, this means program written in Java can be used on any computer running any operating system.
There are 2 basic types of Java applications –
- Stand-alone applications – Stand alone applications are simple java program developed to perform certain specific task on stand alone local computer.
- Web applets – Web applets are small java program developed for internet or network based applications. Applet program run inside a web browser.
Characteristics of Java
Platform neutral language – Java programs are platform neutral, this means program written in Java can be used on any computer running any operating system, this is possible by the help of java virtual machine.
Object-orientated programming language – In java programming language all the elements are object except the primitive data types.
Strongly-typed programming language – Java is strongly-typed programming language, means we must defined the type of the variable before using it and conversion to other objects is relatively strict, it must be done in most cases explicitly by the programmer.
Compiled and Interpreted language – Usually a computer programming language can be either compiled or interpreted, but in case of Java both of the approach is combined, thus it makes java a two stage system. In first stage source code is transferred into the bytecode format which is platform neutral. These bytecode instructions will be interpreted by the Java Interpreter in second stage.
Automatic memory management – Java programming language has the in built memory management capabilities, thus allocation and de-allocation for creating new objects is handled by java. Java program does not have direct access to the memory. There is a garbage collector deletes objects automatically which is not active in the program.
The Java syntax is much similar to C++. Java is case sensitive, e.g. the variables myValue and myvalue will be treated as different variables.
Applications of Java
Java can be used for any of following type of application:
- Real-time Systems
- Embedded Systems
- Simulation and Modelling
- Object Oriented Databases
- Artificial Intelligence and Expert Systems
- CIM/CAD/CAM Systems
- Neural Networks and Parallel Programming
- Decision Support Systems
Differences between Java 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 mechanism to define classes and objects.
- 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, extern, 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 statements.
- Java requires that the functions with no arguments must be declared with empty parenthesis and not with the void keyword as done in C.
- Java adds new operators such as instanceof and >>>.
- Java adds labelled break and continue statements.
- Java does not have “goto” control structure.
- Java adds many features required for object-oriented programming.
Differences between Java and C++
Java is a true object-oriented language while C++ is basically C with object-oriented extension.However, some object-oriented features of C++ make the C++ code extremely difficult to follow and maintain.
Listed below are some major C++ features that were intentionally omitted from Java or significantly modified.
- Java does not support operator overloading.
- Java does not have template classes as in C++.
- Java does not support multiple inheritance of classes. This is accomplished using a new feature called “interface”.
- Java does not support global variables. Every variable and method is declared within a class and forms part of that class.
- Java does not use pointers.
- Java has replaced the destructor function with a finalize() function.
- There are no header files in Java.