0% found this document useful (0 votes)
18 views

Basics of Java

The document discusses the basics of Java including what Java is, its features and applications. It also covers creating a simple Hello World program in Java, compiling and running Java code, and variables in Java.

Uploaded by

Rutuja Kadam
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Basics of Java

The document discusses the basics of Java including what Java is, its features and applications. It also covers creating a simple Hello World program in Java, compiling and running Java code, and variables in Java.

Uploaded by

Rutuja Kadam
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Basics of Java

BATCH 5
What is Java?

Java is a programming language and a platform. Java is a high level, robust, object-oriented and
secure programming language.

Application
1.Desktop Applications such as acrobat reader, media
player, antivirus, etc.
2.Web Applications such as irctc.co.in, javatpoint.com, etc.
3.Enterprise Applications such as banking applications.
4.Mobile
5.Embedded System
6.Smart Card
7.Robotics
8.Games, etc.
Features of Java

A list of the most important features of the Java language is


given below.

1. Simple
2. Object-Oriented
3. Portable
4. Platform independent
5. Secured
6. Robust
7. Architecture neutral
8. Interpreted
9. High Performance
10. Multithreaded
11. Distributed
12. Dynamic
Creating Hello World Example

Let's create the hello java program:

class Simple
{
public static void main(String args[])
{
System.out.println("Hello Java");
}
}

Save the above file as Simple.java.

javac
To compile:
Simple.java

To execute: java Simple


Compilation Flow:

When we compile Java program using javac tool, the Java compiler converts the source code
into byte code.
Parameters used in First Java Program

•public: So that JVM can execute the method from


anywhere.
•static: The main method is to be called without an
class Simple
object. The modifiers are public and static can be
{
written in either order.
public static void main(String args[])
•void: The main method doesn’t return anything.
{
•main(): Name configured in the JVM. The main
System.out.println("Hello Java");
method must be inside the class definition. The
}
compiler executes the codes starting always from the
}
main function.
•String[]: The main method accepts a single
argument, i.e., an array of elements of type String.
Internal Details of Hello Java Program
In the previous section, we have created Java Hello World program and learn how to
compile and run a Java program. In this section, we are going to learn, what happens while
we compile and run the Java program. Moreover, we will see some questions based on the
first program.

What happens at compile time?


At compile time, the Java file is compiled by Java Compiler (It does not interact with OS) and
converts the Java code into bytecode.
What happens at runtime?

At runtime, the following steps are performed:

Classloader: It is the subsystem of JVM that is used


to load class files.
Bytecode Verifier: Checks the code fragments for
illegal code that can violate access rights to objects.

Interpreter: Read bytecode stream then execute the


instructions.
Java Variables
A variable is a container which holds the value while the Java program is executed. A variable is
assigned with a data type.

A variable is the name of a reserved area allocated in memory. In other words, it is a name of the
memory location. It is a combination of "vary + able" which means its value can be changed.

int data=50;//Here data is variable


Types of Variables

There are three types of variables in Java:

•local variable
•instance variable
•static variable

1.public class A
2.{
3. static int m=100;//static variable
4. void method()
5. {
6. int n=90;//local variable
7. }
8. public static void main(String args[])
9. {
10. int data=50;//instance variable
11. }
12.}//end of class
Data Types in Java

Data types specify the different sizes and values that can be stored in the variable. There are two types
of data types in Java:

1.Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and
double.
2.Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays.

You might also like