In this tutorial, we will discuss the all basics and advanced features or characteristics of Java programming language.
We know that Java is an object-oriented and platform-independent language.
In addition to these two popular buzzwords (features), there are many other buzzwords that we need to know.
This is because the history of Java cannot be complete without a look at the features of Java.
Therefore, it is important to know Java buzzwords (i.e. features of Java) because they played important roles in modeling Java language.
There are a total of 11 Java buzzwords that are as follows:
Java is designed as a simple programming language. When Java was developed, the Java team wanted it to be simple for the professional programmer to learn and use effectively.
This is because it has to work on various electronic devices or on small machines where less memory is available. At that time, the size of basic interpreter and class support is only 40 KB.
Now, the question arises here, how Java was made simple?
First of all, several difficult, clumsy, and confusing features of other programming languages such as C and C++ had been omitted in Java.
For example, the feature of pointers that is very difficult for both learners and programmers. Therefore, this feature had been completely eliminated from Java.
Second, the JavaSoft team maintained the same syntax of C and C++ in Java so that a programmer who knows C or C++ will find Java already familiar and require very little effort in learning.
Why Pointer feature is eliminated from Java?
There are mainly three reasons to eliminate the pointer concept from Java. They are as follows:
1. The concept of Pointer leads to confusion for a programmer.
2. Pointer may break a program easily. For example, when we add two pointers, the program can crash immediately.
3. The use of Pointer feature can break security because harmful programs like virus and other hacking programs can be developed using pointer.
Because of the above reasons, the pointer feature has been completely eliminated from Java technology.
Java is a purely object-oriented programming language (OOP). This means that Java program is developed by using classes and objects. In other words, to write a program in java, we need at least a class or an object.
Now, the question is what is an object in java?
An object is anything that exists in the real world. For example, every human being, a book, a tree, pen, pencil, and so on.
Every object has properties and shows certain behavior (action). Let us understand this statement with the help of an example.
Consider a dog. The properties of a dog are name, height, color, age, etc. These properties are represented by variables in java. The object dog has several behaviors (actions) such as running, barking, eating, sleeping, etc.
These behaviors or actions are represented by various methods (functions) in java programming. So, we can say that an object contains variables and methods.
The second question is what is a class in Java?
A class defines the name of a group given to several objects having the same properties and behaviors (actions).
Let’s understand this statement with the help of examples.
a) Consider a mobile. A mobile can be the brand name of Samsung, Nokia, Motorola, and Vivo. All these four mobiles show the same behaviors like messaging, calling, surfing, etc.
Hence, they will belong to the same group called mobile. So, the class name is mobile that contains four objects.
In other words, a class in java can be defined as a model or a blueprint for creating objects. We write the properties and actions of objects in the class: “Mobile”.
It means that a class can be defined as a model in the creation of objects. A class also contains properties and actions, i.e. variables and methods like objects.
Look at the below figure to understand better the concepts of class and objects.
b) Let us understand one more example. Flower is a class but if we consider Lily, Rose, Jasmine then all these are objects of class Flower. The class flower does not exist physically but its objects such as Lily, Rose, Jasmine exist physically in the world.
Note: C++ is not a pure object-oriented programming language because it is possible to write programs in C++ without using a class or an object.
Java is designed to support the distributed environment of the Internet because it handles TCP/IP and UDP protocols.
Using Java, we can make a program to get information and can distribute it on various computers on a network. Java also supports Remote Method Invocation (RMI) feature that enable a program to distribute methods across a network.
The meaning of Robust is “strong”. This means that Java programs are strong because they do not crash easily like C or C++ programs. There are mainly three reasons to be robust.
Firstly, Java has an excellent inbuilt feature named exception handling. An exception is an abnormal condition or error that occurs at run time.
If an exception occurs in a java program, the program terminates abruptly and rises to problems like loss of data.
To overcome such types of problems, we can use exception handling mechanism. This means that even though an exception occurs in a program, no harm (i.e. loss of data) will happen.
Second reason is that Java has a robust memory management feature. Most of the C and C++ programs crash in the middle because of not allocating sufficient space in the memory for a program.
Such problems will not occur in Java because we do not need to allocate or deallocate the memory in Java. Everything is taken care of by JVM only. For example, JVM allots the required memory by a Java program.
Third reason is that Java supports an error checking feature at various stages: Early checking at compile-time and dynamic checking at run time.
Since Java supports the distributed environment of the internet, it also provides multiple security features. Security problems like tampering, impersonation, and virus threats can be eliminated or reduced by using Java on Internet.
6. System independence (Architecture neutral):
Java compiler compiles the source code into byte code that is independent of any machine architecture.
In other words, the byte code of Java program is not machine-dependent. It can be run on any system machine with any processor and any operating system that implements Java Virtual Machine.
The goal of JavaSoft was to “write once; run anywhere, any time, forever”. To a great extent, JavaSoft accomplished this goal.
If a program gives the same result on every system machine, that program is called portable. Java programs are portable.
During compilation, Java compiler converts the source code of the program into byte code. This byte code can be executed on any system machine with the help of Java interpreter in JVM.
If we take any other programming language, only a compiler or an interpreter is used to run programs. But in Java, we use both compiler and interpreter for the execution of the program.
9. High Performance:
The speed of interpreter inside JVM to execute a program is slow. To overcome this problem, JavaSoft team has introduced JIT (Just In Time) compiler which improves the performance of interpreting byte code by caching interpretations.
Due to which the speed of execution of java program is enhanced. So, both interpreter and JIT compiler in JVM work together to run the program.
Java supports multi-threading programming that allows to write programs to do several works simultaneously. A thread is an individual process to execute a group of statements.
JVM utilizes multiple threads to execute different blocks of code. Creating multiple threads is called ‘multithreaded’ in Java.
Before the development of Java, only static text was displayed in the browser. But using applet program, we can also create animation dynamically on the Internet.
Hope that this tutorial has covered enough points to elaborate features of Java with realtime examples. I hope that you will have understood the features of Java technology.
Thanks for reading!!!
Next ⇒ What is JDK