How is Java different than other programming languages?
Hello Developers, In this article, I have explained many things regarding Java and I have also explained some important features of Java which played important role for making Java different and better than other programming languages. Now, without further ado, let's dive right into it.
A bit about Java
Java is a programming language, it is a technology which is used for software development. Java is an Object Oriented programming language which is developed by James Gosling and it was published by Sun Microsystems in 1995.
There are many programming languages which are also used for software dovelopment. Now, you might be thinking that why java is getting popularity compared to other programming languages?
Why Java is popular?
As we know java is high level, object-oriented programming language. One of the most important feature of java is that, it is platform indepentent. Java gets more popularity because of this feature.
Ok Guys, One question arise, what is a platform? After learning what is platform we will discuss about platform indepentent feature of Java.
Platform: An environment in which a program can be executed is known as a Platform. Platform can be a hardware or a software or may be both.
- Hardware platform means any physical machine. Which is used for executing the code.
- Software is a set of instructions which is developed for executing a particular task which is installed in physical machine.
Ok Guys now we try to understant about platform indepentent.
Platform independent means that java code does not depend on any machine. Bascially here machine word is used for Operating System.
Write your java code on one machine and you can excute the same code on other machine as well without making any changes in your code.
For Example: If you have written Java code on one machine, suppose Windows, than it can also be executed on Linux, Unix, Macintosh platform without making any changes. But this is not the case with langauges like C and C++, these languages are platform dependent. It is not required to make any changes in code if you are executing your same Java code on different operating system. That's why we can say java code is write once and run anywhere.
How java is platform indepentent?
Most of the programming languages are platform dependent. These languages code can't be executed on multiple machines without any change in code. If you want to run the code on other machine, you must perform change in your code.
For Example, you can't run the code of C and C++ on Unix if the code was created on windows because both are different operating system. C ,C++ code is machine dependent while Java is platform indepentent because of JVM.
JVM stands for Java Virtual Machine which is platform dependent. Every operating system has its own JVM which has its own implementation of Java as per operating system. JVM is vital part of java, it takes byte code as an input and converts it into machine code.
The byte code is generated by the compiler (JavaC). Java compiler compiles the java source code and converts it into byte code after that code is handed over to JVM.
You can learn more about JVM on our article JVM Architecture Introduction | JVM Internals
Does java use pointer or restricted pointer?
C and C++ use pointer but java does not use pointer. Actually java has pointer only for internal work and it did not provide access of pointer to external users because of security, java user can't use pointer in java program. Java has internal pointer which is used only by java, this feature is called restricted pointer.
Why Java uses Internal Pointer?
Array internally uses pointer. Java uses Array and array takes continous memory storage. We can't move one element of Array to next element without pointer because we need address of next element and this address is provided by pointer.
Does java use Compiler or Interpreter?
Java uses both compiler as well as interpreter while other programming language use only one, that may be compiler or may be an interpreter.For Example C and C++ use only compiler to compile the code and python uses only interpreter. Java uses both Compiler and interpreter, it first uses compiler then interpreter.
Does java support Multiple Inheritance?
Java does not support multiple inheritance through class, because java is based on real world entity and multiple inheritance does not possible in real world. That's why java does not support multiple inheritance through class but multiple inheritance is an important concept for programming that's why java supports multiple inheritance through interface.
Does Java support goto Statement?
Java does not support goto statement while C and C++ supports goto statement. Goto statement is jumping statement. If you want to make simple program then you should not use goto statement, use of goto statement in any program make the program very complex. So a programmer should try to ignore the use of goto statement, java focus to create a simple code. That's why Java does not support goto statement.
You can also read more about differences between c and c++ on our article C++ Introduction | C vs C++.
That's all for this topic. If you guys have any suggestions or queries, feel free to drop a comment. We would be happy to add that in our post. You can also contribute your articles by creating contributor account here.
Happy Learning 🙂
About the Author
Comments and QueriesIf you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
<pre><code class="java"> String foo = "bar"; </code></pre>For more information on supported HTML tags in disqus comment, click here.