0 votes
in JAVA by
What is the difference between java and javascript?

1 Answer

0 votes
by

What is the difference between java and javascript?

The main differences between JavaScript and Java are:

1. JavaScript is used for Front End development while java is used for Back End Development. i.e.

JavaScript is responsible for the dynamic behaviour of a webpage. Mainly, JavaScript handles events, cookies, ajax (Asynchronous JavaScript and XML), etc. in a website. JavaScript is the heart of a Dynamic User Interface of a Web Page while Java is the best programming language for software engineers and can be used with JSP (Java Server pages) for handling back end.

2. Java Script is dynamically typed language and Java is Statically typed language: i.e

In JavaScript, datatype of one variable can be changed:

var string = “hello world”;

string = 4;

document.write(string); //OUTPUT IS 4

document.write( ) will now print ‘4' on the browser.

But in Java, the datatype of one variable cannot be changed and Java shows the error.

int number = 45;

number = “hello world”; //ERROR!!!!!!!

3. JavaScript is a scripting language while Java is a programming language:

Like other languages, Java also needs a compiler for building and running the programs while JavaScript scripts are read and manipulated by the browser.

4. Java and JavaScript are very different in their SYNTAX.

For example:

Hello World Program in JAVA:

public class hello 

        public static void main(String[] args) 

        { 

                System.out.println("Hello World"); 

        } 

Hello World Program in JavaScript:

<script> 

        document.write("Hello World"); 

</script> 

5. Both languages are Object Oriented but JavaScript is a Partial Object Oriented Language while Java is a fully Object Oriented Langauge. JavaScript can be used with or without using objects but Java cannot be used without using classes.

Related questions

0 votes
asked Oct 10, 2020 in JAVA by Robindeniel
0 votes
asked May 2, 2021 in JAVA by sharadyadav1986
...