JavaScript Programming language–
Almost all programs, though, are written in high-level programming languages such as Java, Pascal, or C++. A program written in a high-level language cannot
be run directly on any computer. First, it has to be translated into machine language. This translation can be done by a program called a compiler.
First Java Program:
Let us look at a simple code that would print the

Javascript (JS) is a scripting language, primarily used on the Web. It is used to enhance HTML pages and is commonly found embedded in HTML code. JavaScript is an interpreted language. Thus, it doesn’t need to be compiled. JavaScript renders web pages in an interactive and dynamic fashion. This allowing the pages to react to events, exhibit special effects, accept variable text, validate data, create cookies, detect a user’s browser, etc.

Java is a programming language and a platform. Java is a high-level, robust, object-oriented, and secure programming language.
Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was already a registered company, so James Gosling and his team changed the Oak name to Java.
Application | Java Platforms / Editions | Types of Java Applications |
Desktop Applications such as acrobat reader, media player, antivirus, etc. | Java SE (Java Standard Edition) | Standalone Application |
Web Applications such as irctc.co.in, javatpoint.com, etc | Java EE (Java Enterprise Edition) | Web Application |
Enterprise Applications such as banking applications. | Java ME (Java Micro Edition) | Enterprise Application |
Mobile | JavaFX | Mobile Application |
Embedded System | – | – |
Smart Card | – | – |
Robotics | – | – |
Games, | – | – |
comparison Index | C++ | Java |
---|---|---|
Platform-independent | C++ is platform-dependent. | Java is platform-independent. |
Mainly used for | C++ is mainly used for system programming. | Java is mainly used for application programming. It is widely used in Windows-based, web-based, enterprise, and mobile applications. |
Design Goal | C++ was designed for systems and applications programming. It was an extension of the C programming language. | Java was designed and created as an interpreter for printing systems but later extended as a support network computing. It was designed to be easy to use and accessible to a broader audience. |
Goto | C++ supports the goto statement. | Java doesn’t support the goto statement |
Difference between Java and JavaScript :
Java | JavaScript |
---|---|
Java is a strongly typed language and variables must be declared first to use in the program. In Java, the type of a variable is checked at compile-time. | JavaScript is a weakly typed language and has a more relaxed syntax and rules. |
Java is an object-oriented programming language. | JavaScript is an object-based scripting language. |
Java applications can run in any virtual machine(JVM) or browser. | JavaScript code used to run only in the browser, but now it can run on the server via Node.js. |
Objects of Java are class-based even we can’t make any program in java without creating a class. | JavaScript Objects are prototype-based. |
Java program has the file extension “.Java” and translates source code into bytecodes which are executed by JVM(Java Virtual Machine). | JavaScript file has the file extension “.js” and it is interpreted but not compiled, every browser has the Javascript interpreter to execute JS code. |
Java is a Standalone language. | contained within a web page and integrates with its HTML content. |
Java program uses more memory. | JavaScript requires less memory therefore it is used in web pages. |
Java Program Example
1. Using console.log()
Source Code
// the hello world program
console.log('Hello World');
Output
Hello, World!
Example 1: Add Two Numbers
const num1 = 5;
const num2 = 3;
// add two numbers
const sum = num1 + num2;
// display the sum
console.log('The sum of ' + num1 + ' and ' + num2 + ' is: ' + sum);
Output
The sum of 5 and 3 is: 8
Example 2: Add Two Numbers Entered by the User
// store input numbers
const num1 = parseInt(prompt('Enter the first number '));
const num2 = parseInt(prompt('Enter the second number '));
//add two numbers
const sum = num1 + num2;
Output
Enter the first number 5 Enter the second number 3 The sum of 5 and 3 is: 8
Java Variables:
We would see the following types of variables in Java:
- Local Variables
- Class Variables (Static Variables)
- Instance Variables (Non-static variables)
Local variables:
Example:
This would produce the following result:
Java Basic data Type
There are two data types available in Java:
- Primitive Data Types
- Reference/Object Data Types
Primitive Data Types:
Byte | Byte Data is an 8-bit signed two’s complement integer Example byte a= 100, byte b=-50 |
Short | Short data type is a 16-bit singed two’s complement integer Example: short s=10000 short r =-20000 |
Int | int data type is 32-bit signed two’s complement integer Example: int a =10000, int b = -20000 |
long | long data type is 64-bit signed two’s complement integer Example: int a =100000L , int b = -200000L |
Float | Float data type is a single-precision 32-bit FEE 754 floating point Example: Float f1 = 234.5f |
Double | Double data type is a double-precision 64-bit IEEE 754 floating point example : double d1= 123.4 |
Boolean | Boolean data type represents one bit of information. example: boolean one = true |
Char | Char data type is single 16-bit uncode character char letterA = ‘A’ |

Install Javascript/Java
The installation process starts. Click the Install button to accept the license terms and to continue with the installation.
click the Next button to continue the installation.

JavaScript in Visual Studio Code Download vscode

Settings for the JDK

Creating a source code file


Book Pdf for Java & Javascript