Some times ago, many people believed that Java was slower than C because Java had to run through a virtual machine. Today however, Time and speed are not really affected by the programming language but it is important that an application developed in any language must be supported on cross platforms (Windows, Linux, etc.).
As a result, programmers and developers have started for the most powerful and easy way to 'learn and work? with programming language. Consequently they came for Object Oriented methodology with the multi-platform support, and other great capabilities and features.
OOP stands for Object Oriented Programming. This is a technique used to develop programs revolving around the real world entities. In OOPs programming model, programs are developed around objects rather than actions and logics. In OOPs, every real life object has properties and behavior, which is achieved through the class and object creation. They contain properties (variables of some type) and behavior (methods).
OOP provides a better flexibility and compatibility for developing large applications.
Java is a statically typed object-oriented language that uses syntax similar to C, but is not compatible with it. It was designed, with the goal of being easy to use for developer and accessible to wider spectators.
Java language comes in light from a language named Oak. Language Oak was developed in the early the nineties at Sun Microsystems as a platform-independent language aimed at allowing entertainment projects such as video game consoles and VCRs to communicate. Now Java has been improved by the newest releases of the implementation for the virtual machine.
Features of Java over C
There are a number of important differences between C and
Java, which are summarized in the following list:
Java does not support a preprocessor such as #define, #include, and #if def directives because it has no header files. Java has class files that contain both the class API and the class implementation.
No global variables
In Java, there is no possibility of namespace collisions among the variables because it defines a very clean namespace in the form of Packages. The Packages contain classes, which contain fields and methods in which local variables are declared.
Well-defined primitive type sizes
In C, the size of short, int, and long types is platform-dependent, which obstruct portability. While in Java, all the primitive Data types have well-defined sizes.
In C, pointers are a disreputable source of bugs. Classes and arrays in Java are reference types. These references to objects and arrays are similar to pointers in C. There is no way to convert a reference to a primitive type, and it cannot be incremented or decremented also. Java programs eliminate the pointer to simplify the language and make it more robust and secure.
Java programmers do not have to explicitly manage the memory used by all objects and arrays because the Java Virtual Machine (JVM) performs garbage collection implicitly. This feature eliminates another entire category of common bugs and memory leaks from Java programs.
No Need of Data Structure
Java supports a pre-built interface known as Collection. This interface allows programmers to have their own data structure with less of codes. Unlike C, they don?t need to write complex algorithms to make a data structure.
Provides String class
Variable declarations anywhere
C always requires local variable declarations to be made at the beginning of a method or block, while Java allows them anywhere in a class, method or block.
Java provides a feature of method overloading where you can define multiple methods with the same name, but having different parameter lists. While, it is not possible in C.
Support Native interfaces
Posted on: October 7, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles