0 votes
142 views
in Javascript by (2.0k points)
edited

What are the key differences between Java and JavaScript? / How is JavaScript different from Java?

1 Answer

0 votes
by (2.0k points)
selected by
 
Best answer

JavaScript is a lightweight programming language (most commonly known as scripting language) developed by Netscape, Inc. It is used to make web pages interactive. It is not a part of the Java platform. Following is a list of some key differences between Java and JavaScript

A list of key differences between Java and JavaScript

Java JavaScript
Java is a complete and strongly typed programming language used for backend coding. In Java, variables must be declared first to use in the program, and the type of a variable is checked at compile-time. JavaScript is a weakly typed, lightweight programming language (most commonly known as scripting language) and has more relaxed syntax and rules.
Java is an object-oriented programming (OOPS) language or structured programming languages such as C, C++, or .Net. JavaScript is a client-side scripting language, and it doesn't fully support the OOPS concept. It resides inside the HTML documents and is used to make web pages interactive (not achievable with simple HTML).
Java creates applications that can run in any virtual machine (JVM) or browser. JavaScript code can run only in the browser, but it can now run on the server via Node.js.
The Java code needs to be compiled. The JavaScript code doesn't require to be complied.
Java Objects are class-based. You can't make any program in Java without creating a class. JavaScript Objects are prototype-based.
Java is a Complete and Standalone language that can be used in backend coding. JavaScript is assigned within a web page and integrates with its HTML content.
Java programs consume more memory. JavaScript code is used in HTML web pages and requires less memory.
The file extension of the Java program is written as ".Java" and it translates source code into bytecodes which are then executed by JVM (Java Virtual Machine). The JavaScript file extension is written as ".js" and it is interpreted but not compiled. Every browser has a JavaScript interpreter to execute the JS code.
Java supports multithreading. JavaScript doesn't support multithreading.
Java uses a thread-based approach to concurrency. JavaScript uses an event-based approach to concurrency.

Related questions

0 votes
1 answer 119 views
0 votes
1 answer 104 views
0 votes
1 answer 129 views
asked Aug 9, 2022 in Discuss by Doubtly (98.9k points)
0 votes
1 answer 239 views
0 votes
1 answer 125 views
asked Oct 1, 2022 in Tailwind by Doubtly (98.9k points)

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

538 users

...