Javatpoint Logo
Javatpoint Logo

What is the difference between Java and JavaScript

Many users think that Java and java-script are similar languages, or they are two different names of the same language. But the user has to clear his doubt that java-script and java language are not similar languages, and java-script has nothing to do with the java programming language. The main reason for introducing the scripting language as JavaScript is the popularity of java programming language that was at its peak at that time. To get the advantage of the popularity of the term "java" in the java programming language, it was introduced as JavaScript.

To understand the difference between Java and JavaScript language, let's look at some of the key differences between them:

Java Language JavaScript Language
1. It is a Programming language. It is a scripting language.
2. Java is a pure Object Oriented Programming Language. JavaScript is Object-Based Language.
3. Java is a Standalone language. JavaScript is not a standalone language, as it needs to be integrated into an HTML program for execution.
4. Java is a strongly typed language, which means that the user has to decide the data type of the variable before declaring and using it.
Example "int a", the variable "a" can store the value of integer type only.
JavaScript is a loosely typed language, which means that the user does not have to worry about the data-type of the variable before and after the declaration.
Example "var a", the "a" variable can store the value of any data-type.
5. Java program should be compiled before execution. JavaScript needs to be integrated into the HTML program for the execution.
6. The web-browser is not required to run java programs. The web-browser is essential to run the JavaScript programs.
7. It is one of the complex languages to learn. It one of the easy languages to learn.
8. In Java, by utilizing the Multi-threading, users can perform complicated tasks. In JavaScript, user is not able to perform complicated tasks.
9. It requires a large amount of memory. It does not require that amount of memory.
10. Java programming language was developed by the "Sun Microsystems." JavaScript programming language was developed by the "Netscape."
11. In Java programming language, programs are saved with the ".java" extension. On the other hand, programs in JavaScript are saved with the ".js" extension.
12. Java is stored on the host machine as the "Byte" code. JavaScript is stored on the Host machine (client Machine) as the "source" text.

Let us see how programs are written in both the languages:

Program to print "Hello World" in Java

Output

Hell World

Program to print "Hello World" in JavaScript

Output

difference between Java and JavaScript




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA