What is Java? What are the important features of Java every Java programmer must know?
Well, go through this tutorial and you will get a better understanding of it. This is a simple and definitive guide for beginners to take the first step in learning the Java programming language.
Next Topic: Top 5 Reasons Why Java is Popular
What is Java?
James Gosling is known as the father of the Java programming language.
James Gosling and his team members Mike Sheridan and Patrick Naughton were known as the Green Team.
The green team initiated the development of a programming language for digital devices like televisions and set-top boxes, etc in 1991.
Firstly, it was named as Green Talk with the file extension ‘.gt‘. Later it was named Oak.
Why they gave the name ‘Oak‘ to their programming language?
There was an oak tree standing outside James Gosling’s office. Well, that could not be the only reason. Right?
Oak is not just a tree. It is a symbol of strength and endurance.
Oak is the national tree of many countries like the U.S.A., Germany, France, Jordan, Poland, Romania, and many more. Hence they chose the name ‘Oak’.
It was a pretty good name for a programming language. Right?
But in 1995 they renamed ‘Oak’ to ‘Java’.
Why the green team discontinued ‘Oak’?
The reason is that the name oak was already a trademark by Oak Technologies back then. So the green team had to find another name for their programming language.
Why they chose the name Java?
The name JAVA was chosen from the JAVA coffee.
What is java coffee?
JAVA is the name of an island in Indonesia. The first Indonesian coffee was grown in JAVA.
JAVA island was famous for its coffee beans. The coffee was called JAVA Coffee.
The green team used to drink coffee made from the java coffee beans, which was so famous at that time.
One of the teammates suggested the name ‘JAVA’ along with many other names.
Other names suggested by the Green Team were silk, dynamic, DNA, etc.
Finally, they chose the name JAVA because it is small, simple, and fun. Also, we can see that the logo of JAVA is a cup of coffee.
Java is now owned by Oracle Corporation. Oracle acquired Sun Microsystems on January 27, 2010.
Now hopefully you have got an idea about ‘what is JAVA’ and the history of java. If yes, let’s look at the most important features of java.
Most Important Features Of Java
1. Java is Object-Oriented.
Java is an object-oriented programming language.
What is an object?
An object is an entity that has some properties and behaviors. A book, laptop, pen, chair, dog, cat, apple, you & me, everything we see around us is an object.
Everything in java is also an object. Just like real-world objects.
In java, we create objects, and these objects communicate with each other to perform a certain task.
These Objects can also be related to each other like a parent-child relationship.
To understand it better, Just imagine Java as a ‘world’.
We are the Programmers. We create objects in this ‘Java world’ and we define properties and behaviors to the objects.
Well, now our objects are ready to perform their tasks using their properties and behaviors.
If the objects perform their task well, we get the output. Else we get an error. We will correct the objects until we get the result we want.
Object-oriented programming(OOPs) is a concept that makes software development easier.
The 6 basic OOPs concepts are :
Java follows this OOPs concept that makes java a simple programming language to use.
2. Java is Simple
Java is designed to be easy to use.
We know that JAVA is an object-oriented programming language. Everything in JAVA is an Object. This object-oriented concept itself is simple. Because the objects in JAVA is identical to the real-world objects.
So, If we know what an object in the real world is, then obviously we will understand this object-oriented concept easily.
Another point is that java doesn’t use complex programming features like Pointers (unlike C and C++), Operator overloading, and Multiple-Inheritance.
Java uses Pointers implicitly. It is not visible to the programmer, So we don’t have to worry about it much.
Java provides some basic conventions to write programs. These conventions are also easy to learn. And by learning these conventions, it will be even easier to use Java.
Note: Multiple-Inheritance is there in Java with Java interfaces since Java 8.
3. Java is Secure
Why is Java known as a secure programming language? There are some key features of Java that make it more secure than other languages like C, C++.
No explicit use of pointers:
Yes, pointers are not just complex they are a little unsafe too.
Why do we use pointers?
Pointers are used to store the address of a memory location.
Since Pointers provides direct access to the memory location of an object, it can be used for unauthorized read and write operations on the object. So by eliminating the explicit use of pointers, Java becomes more secure than the programming languages that use pointers implicitly.
Java compiler is so powerful that it detects many errors at compile time. Let’s look at a very simple example.
Let’s take the case of the private access-modifier.
Note: If you don’t know, Java provides 4 access-modifiers/access-specifiers(used to specify the visibility of an object and everything inside the object; i.e., its properties and behaviors). ‘private’ is one of the access-modifiers.
We can use the private access modifier to limit the visibility of a variable or a constant or a method or anything which is defined inside a java class.
If the programmer tries to access a private property outside its limit, the Java compiler will detect that and raise it as an error.
Compile-time error-detection is a powerful tool of java.
Before running the Java program, JVM will verify the byte-code to ensure that the operations performed by the programs are safe to execute.
Note: Byte-code is briefly explained below.
Java Exception Handling
An exception is an event that breaks the normal flow of our programs, which may cause the program to produce an undesirable output or lead to the termination of the program.
There are 2 types of exceptions in java.
- compile-time/checked exceptions: The java compiler will capture these exceptions at compile-time, which is a great thing.
- run-time/unchecked exceptions: These exceptions are encountered at run-time
Java has provided a solid exception handling mechanism.
When an exception occurs, the programmer must have to use the java exception handling mechanism. Otherwise, the program will not run. This makes java programs much more secure.
Java has its own memory management system. Java has a garbage collector. The java garbage collector removes the unused objects and releases the memory.
The Programmer doesn’t have to worry about clearing the memory. The garbage collector will do it automatically.
These are only a few of the important features of java that make it more secure. Let’s move on to the next feature of Java.
4. Java is Robust
Java is considered a Robust programming language.
What is a robust programming language?
If a programming language is considered robust, that means it can handle unexpected errors and actions at run time.
Why is Java called robust?
- The memory management system of Java is strong. Java has a garbage collector.
- Java doesn’t use pointers explicitly. There is an abstract layer between programmers and pointers in Java.
- Java has type checking mechanisms.
- Java has an exception-handling mechanism.
All these features make Java a Robust programming language.
5. Java is Platform Independent
First, we need to know:
What is a platform?
In real life, we can see many platforms. For example, a ‘stage’. A stage is a platform that creates an environment for everyone who performs on that stage.
Likewise, in programming also a platform is something that creates an environment to run our applications.
operating systems like Windows, Linux, IOS all are platforms.
Now we know what a platform is. Then let’s try to understand how java is platform-independent.
Why is Java known as platform-independent?
To understand this, first, you need to know about byte-code.
To run any Java program, you need to compile the source code first.
compiling is the process to check the syntactic errors in the source code and generates the executable code if no errors found.
In Java, compiling is done by the Java compiler.
The Java compiler compiles the source code and creates a file called ‘byte code‘.
Byte code is the executable file in Java. To run a Java program, we execute the byte code of the program.
Byte code is not machine dependant. It is not bound to any Platform. byte code is verified and executed by the java virtual machine (JVM).
The byte code is what makes Java a platform-independent programming language.
Byte code can be run on any platform if JVM is present. This is why Java is a ‘Write once, run anywhere‘ language.
6. Java is Portable
Java is portable because the byte code created by the java compiler is platform-independent.
Thus, it can be transferred from one platform/hardware to another and can be run there easily if a Java Virtual Machine(JVM) is installed there.
7. Java is Interpreted.
There are compiled programming languages and interpreted programming languages.
What is the difference between the two? Well, Let’s look into it.
Compiled Programming Languages
In the case of compiled languages, the compiler compiles the source code and creates a file that can be read and run by the native machine. The compiled file is directly executed by the machine itself.
Interpreted Programming Languages
In the case of interpreted languages, the compiler compiles the source code and creates a file that can be read and run by some other program, not by the native machine.
The compiled file is not directly executed by the machine. Instead, it is read and executed by the interpreter.
Now, Let’s look at the case of Java,
Java compiler compiles the source code and creates a byte code. Byte code is the intermediate code between the source code and the machine code. Byte code cannot be executed directly by a native machine. It is read and executed by the JVM. JVM is the interpreter here.
8. Java is Multi-Threaded
What is a thread in Java?
A thread is a sequence of executed statements. A thread is a small part of a process. i.e., there can be multiple threads in a single process.
Threads in a program run concurrently. ie, If a thread in a program is currently running, other threads won’t wait for the currently running thread to finish.
Threads in a process use a shared memory area.
Threads are like ‘running athletes’ on a track. Athletes are not supposed to wait for each other in a race. Right? They all run at the same time.
Now we know what a thread is.
What is a Multi-threaded program?
A multi-threaded program is a program that has two or more threads in it. Each thread in the program can handle a different task at the same time.
In every Java program, there is at least one thread. i.e., the main thread. Main is the first Java thread, and we can create multiple threads from it.
Java has built-in features to create multi-threaded applications.
9. Java is Architecture-Neutral
The Java compiler compiles the source code and generates byte code.
Byte code is not dependent on the hardware architecture of any machine. Byte code needs JVM present on the Machine to execute it.
JVM executes the byte code in the same way on a 32-bit machine and a 64-bit machine. There aren’t any implementation-dependent features.
10. Java is Distributed
Java is a distributed programming language. Using Java, we can create distributed applications.
What is Distributed Programming?
Let’s imagine we have multiple computers with us and these computers are connected through a network. Every computer has a JVM present there.
We know that java is platform-independent and portable.
We create a java program and split this program into different parts.
Each part is stored/distributed to different computers on the network.
When we run our java program, it can access other java programs running on the other machines on the network. This can be considered as a distributed program.
Java achieves distributed programming using RMI(Remote Method Invocation) and EJB(Enterprise Java Bean) concepts.
Well, these are the most important features of Java.
Please don’t worry if you haven’t understood terms like OOPs, access-modifiers/ access-specifiers, JVM, Byte code, Exceptions, java interfaces, RMI, EJB, etc.
I know that it is not easy for you to understand these things in the beginning.
I will explain all these terms in detail in the coming Java tutorials.
This is only the first step in learning the Java programming language.
This Java tutorial is all about understanding ‘What is Java?’ and the important features of Java.
Hope You found this helpful. If yes, share it with your friends and also check out the next topic: Top 5 Reasons Why Java is Popular.
What is Java?
JAVA is an object-oriented programming language developed by James Gosling and his teammates at Sun Microsystems in the early ’90s.
James Gosling and his team members Mike Sheridan and Patrick Naughton were known as the Green Team.
The green team initiated the development in 1991.
It was initially developed for digital devices like televisions and set-top boxes, etc.
It was first named as green talk, later as Oak, and finally as Java.
What are the most important features of Java?
Easy to Use